diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-07-16 11:45:35 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-07-17 08:59:23 +0000 |
commit | 552906b0f222c5d5dd11b9fd73829d510980461a (patch) | |
tree | 3a11e6ed0538a81dd83b20cf3a4783e297f26d91 /chromium/components/user_manager | |
parent | 1b05827804eaf047779b597718c03e7d38344261 (diff) | |
download | qtwebengine-chromium-552906b0f222c5d5dd11b9fd73829d510980461a.tar.gz |
BASELINE: Update Chromium to 83.0.4103.122
Change-Id: Ie3a82f5bb0076eec2a7c6a6162326b4301ee291e
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/components/user_manager')
-rw-r--r-- | chromium/components/user_manager/BUILD.gn | 12 | ||||
-rw-r--r-- | chromium/components/user_manager/fake_user_manager.cc | 10 | ||||
-rw-r--r-- | chromium/components/user_manager/known_user.cc | 61 | ||||
-rw-r--r-- | chromium/components/user_manager/known_user.h | 12 | ||||
-rw-r--r-- | chromium/components/user_manager/user.h | 5 | ||||
-rw-r--r-- | chromium/components/user_manager/user_manager_base.cc | 11 | ||||
-rw-r--r-- | chromium/components/user_manager/user_manager_base.h | 11 |
7 files changed, 86 insertions, 36 deletions
diff --git a/chromium/components/user_manager/BUILD.gn b/chromium/components/user_manager/BUILD.gn index 4132923e480..c4b12fd010b 100644 --- a/chromium/components/user_manager/BUILD.gn +++ b/chromium/components/user_manager/BUILD.gn @@ -20,9 +20,7 @@ component("user_manager") { "//ui/gfx", ] - deps = [ - "//google_apis", - ] + deps = [ "//google_apis" ] defines = [ "USER_MANAGER_IMPLEMENTATION" ] @@ -65,16 +63,12 @@ if (is_chromeos) { "//components/account_id", ] - deps = [ - "//chromeos/constants", - ] + deps = [ "//chromeos/constants" ] } source_set("unit_tests") { testonly = true - sources = [ - "user_unittest.cc", - ] + sources = [ "user_unittest.cc" ] deps = [ ":user_manager", "//components/account_id", diff --git a/chromium/components/user_manager/fake_user_manager.cc b/chromium/components/user_manager/fake_user_manager.cc index 263ed0810ba..68a49f9780d 100644 --- a/chromium/components/user_manager/fake_user_manager.cc +++ b/chromium/components/user_manager/fake_user_manager.cc @@ -9,22 +9,28 @@ #include "base/callback.h" #include "base/command_line.h" +#include "base/single_thread_task_runner.h" #include "base/system/sys_info.h" -#include "base/task_runner.h" #include "chromeos/constants/chromeos_switches.h" #include "components/user_manager/user_names.h" #include "components/user_manager/user_type.h" namespace { -class FakeTaskRunner : public base::TaskRunner { +class FakeTaskRunner : public base::SingleThreadTaskRunner { public: + // base::SingleThreadTaskRunner: bool PostDelayedTask(const base::Location& from_here, base::OnceClosure task, base::TimeDelta delay) override { std::move(task).Run(); return true; } + bool PostNonNestableDelayedTask(const base::Location& from_here, + base::OnceClosure task, + base::TimeDelta delay) override { + return PostDelayedTask(from_here, std::move(task), delay); + } bool RunsTasksInCurrentSequence() const override { return true; } protected: diff --git a/chromium/components/user_manager/known_user.cc b/chromium/components/user_manager/known_user.cc index a0c78f646d2..29998aa1d20 100644 --- a/chromium/components/user_manager/known_user.cc +++ b/chromium/components/user_manager/known_user.cc @@ -11,6 +11,8 @@ #include "base/logging.h" #include "base/metrics/histogram_macros.h" +#include "base/time/time.h" +#include "base/value_conversions.h" #include "base/values.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/scoped_user_pref_update.h" @@ -72,6 +74,9 @@ const char kIsEphemeral[] = "is_ephemeral"; // Key of the list value that stores challenge-response authentication keys. const char kChallengeResponseKeys[] = "challenge_response_keys"; +const char kLastOnlineSignin[] = "last_online_singin"; +const char kOfflineSigninLimit[] = "offline_signin_limit"; + // List containing all the known user preferences keys. const char* kReservedKeys[] = {kCanonicalEmail, kGAIAIdKey, @@ -86,7 +91,9 @@ const char* kReservedKeys[] = {kCanonicalEmail, kMinimalMigrationAttempted, kProfileRequiresPolicy, kIsEphemeral, - kChallengeResponseKeys}; + kChallengeResponseKeys, + kLastOnlineSignin, + kOfflineSigninLimit}; PrefService* GetLocalState() { if (!UserManager::IsInitialized()) @@ -602,6 +609,36 @@ base::Value GetChallengeResponseKeys(const AccountId& account_id) { return value->Clone(); } +void SetLastOnlineSignin(const AccountId& account_id, base::Time time) { + SetPref(account_id, kLastOnlineSignin, base::CreateTimeValue(time)); +} + +base::Time GetLastOnlineSignin(const AccountId& account_id) { + const base::Value* value = nullptr; + base::Time time = base::Time(); + if (!GetPref(account_id, kLastOnlineSignin, &value)) + return base::Time(); + if (!base::GetValueAsTime(*value, &time)) + return base::Time(); + return time; +} + +void SetOfflineSigninLimit(const AccountId& account_id, + base::TimeDelta time_delta) { + SetPref(account_id, kOfflineSigninLimit, + base::CreateTimeDeltaValue(time_delta)); +} + +base::TimeDelta GetOfflineSigninLimit(const AccountId& account_id) { + const base::Value* value = nullptr; + base::TimeDelta time_delta = base::TimeDelta(); + if (!GetPref(account_id, kOfflineSigninLimit, &value)) + return base::TimeDelta(); + if (!GetValueAsTimeDelta(*value, &time_delta)) + return base::TimeDelta(); + return time_delta; +} + void RemovePrefs(const AccountId& account_id) { PrefService* local_state = GetLocalState(); @@ -629,21 +666,13 @@ void CleanEphemeralUsers() { return; ListPrefUpdate update(local_state, kKnownUsers); - auto& list_storage = update->GetList(); - for (auto it = list_storage.begin(); it < list_storage.end();) { - bool remove = false; - base::DictionaryValue* element = nullptr; - if (update->GetDictionary(std::distance(list_storage.begin(), it), - &element)) { - base::Value* is_ephemeral = element->FindKey(kIsEphemeral); - if (is_ephemeral && is_ephemeral->GetBool()) - remove = true; - } - if (remove) - it = list_storage.erase(it); - else - it++; - } + update->EraseListValueIf([](const auto& value) { + if (!value.is_dict()) + return false; + + base::Optional<bool> is_ephemeral = value.FindBoolKey(kIsEphemeral); + return is_ephemeral && *is_ephemeral; + }); } void RegisterPrefs(PrefRegistrySimple* registry) { diff --git a/chromium/components/user_manager/known_user.h b/chromium/components/user_manager/known_user.h index edc8555dd25..2c0843ee4d7 100644 --- a/chromium/components/user_manager/known_user.h +++ b/chromium/components/user_manager/known_user.h @@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "base/time/time.h" #include "components/user_manager/user_manager_export.h" class AccountId; @@ -215,6 +216,17 @@ void USER_MANAGER_EXPORT SetChallengeResponseKeys(const AccountId& account_id, base::Value USER_MANAGER_EXPORT GetChallengeResponseKeys(const AccountId& account_id); +void USER_MANAGER_EXPORT SetLastOnlineSignin(const AccountId& account_id, + base::Time time); + +base::Time USER_MANAGER_EXPORT GetLastOnlineSignin(const AccountId& account_id); + +void USER_MANAGER_EXPORT SetOfflineSigninLimit(const AccountId& account_id, + base::TimeDelta time_limit); + +base::TimeDelta USER_MANAGER_EXPORT +GetOfflineSigninLimit(const AccountId& account_id); + // Removes all user preferences associated with |account_id|. // Not exported as code should not be calling this outside this component void RemovePrefs(const AccountId& account_id); diff --git a/chromium/components/user_manager/user.h b/chromium/components/user_manager/user.h index 2790b6d359d..7b4e6c07483 100644 --- a/chromium/components/user_manager/user.h +++ b/chromium/components/user_manager/user.h @@ -189,6 +189,11 @@ class USER_MANAGER_EXPORT User : public UserInfo { return CreatePublicAccountUser(account_id); } + static User* CreatePublicAccountUserForTestingWithSAML( + const AccountId& account_id) { + return CreatePublicAccountUser(account_id, /* is_using_saml */ true); + } + static User* CreateRegularUserForTesting(const AccountId& account_id) { User* user = CreateRegularUser(account_id, USER_TYPE_REGULAR); user->SetImage(std::unique_ptr<UserImage>(new UserImage), 0); diff --git a/chromium/components/user_manager/user_manager_base.cc b/chromium/components/user_manager/user_manager_base.cc index 3dbeae2a04b..03f7b33693d 100644 --- a/chromium/components/user_manager/user_manager_base.cc +++ b/chromium/components/user_manager/user_manager_base.cc @@ -18,10 +18,10 @@ #include "base/logging.h" #include "base/macros.h" #include "base/metrics/histogram_macros.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "base/task_runner.h" #include "base/values.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" @@ -107,8 +107,9 @@ void UserManagerBase::RegisterPrefs(PrefRegistrySimple* registry) { known_user::RegisterPrefs(registry); } -UserManagerBase::UserManagerBase(scoped_refptr<base::TaskRunner> task_runner) - : task_runner_(task_runner) {} +UserManagerBase::UserManagerBase( + scoped_refptr<base::SingleThreadTaskRunner> task_runner) + : task_runner_(std::move(task_runner)) {} UserManagerBase::~UserManagerBase() { // Can't use STLDeleteElements because of the private destructor of User. @@ -1049,8 +1050,10 @@ User* UserManagerBase::RemoveRegularOrSupervisedUserFromList( ++it; } } - if (notify) + if (notify) { OnUserRemoved(account_id); + NotifyLocalStateChanged(); + } return user; } diff --git a/chromium/components/user_manager/user_manager_base.h b/chromium/components/user_manager/user_manager_base.h index 94e57832668..feecb1f4a42 100644 --- a/chromium/components/user_manager/user_manager_base.h +++ b/chromium/components/user_manager/user_manager_base.h @@ -13,6 +13,7 @@ #include "base/feature_list.h" #include "base/macros.h" +#include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/synchronization/lock.h" @@ -27,7 +28,7 @@ class PrefRegistrySimple; namespace base { class ListValue; -class TaskRunner; +class SingleThreadTaskRunner; } namespace user_manager { @@ -40,9 +41,9 @@ class RemoveUserDelegate; // Base implementation of the UserManager interface. class USER_MANAGER_EXPORT UserManagerBase : public UserManager { public: - // Creates UserManagerBase with |task_runner| for UI thread and - // |blocking_task_runner| for SequencedWorkerPool. - explicit UserManagerBase(scoped_refptr<base::TaskRunner> task_runner); + // Creates UserManagerBase with |task_runner| for UI thread. + explicit UserManagerBase( + scoped_refptr<base::SingleThreadTaskRunner> task_runner); ~UserManagerBase() override; // Registers UserManagerBase preferences. @@ -391,7 +392,7 @@ class USER_MANAGER_EXPORT UserManagerBase : public UserManager { bool last_session_active_account_id_initialized_ = false; // TaskRunner for UI thread. - scoped_refptr<base::TaskRunner> task_runner_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; base::WeakPtrFactory<UserManagerBase> weak_factory_{this}; |