Chromium Code Reviews| Index: chrome/browser/chromeos/settings/device_settings_service.cc |
| diff --git a/chrome/browser/chromeos/settings/device_settings_service.cc b/chrome/browser/chromeos/settings/device_settings_service.cc |
| index 0895080c4f5b53dc585217054962ec7d632475bd..7249fde67fa8cddef90239db200e8bfb42ca3122 100644 |
| --- a/chrome/browser/chromeos/settings/device_settings_service.cc |
| +++ b/chrome/browser/chromeos/settings/device_settings_service.cc |
| @@ -10,6 +10,9 @@ |
| #include "base/stl_util.h" |
| #include "base/time/time.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| +#include "chrome/browser/chrome_notification_types.h" |
| +#include "chrome/browser/chromeos/login/user.h" |
| +#include "chrome/browser/chromeos/login/user_manager.h" |
| #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| #include "chrome/browser/chromeos/settings/owner_key_util.h" |
| #include "chrome/browser/chromeos/settings/session_manager_operation.h" |
| @@ -82,6 +85,9 @@ DeviceSettingsService::DeviceSettingsService() |
| waiting_for_tpm_token_ = !TPMTokenLoader::Get()->IsTPMTokenReady(); |
| TPMTokenLoader::Get()->AddObserver(this); |
| } |
| + registrar_.Add(this, |
| + chrome::NOTIFICATION_PROFILE_ADDED, |
| + content::NotificationService::AllSources()); |
| } |
| DeviceSettingsService::~DeviceSettingsService() { |
| @@ -279,6 +285,24 @@ void DeviceSettingsService::OnTPMTokenReady() { |
| EnsureReload(true); |
| } |
| +void DeviceSettingsService::Observe( |
| + int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + if (type != chrome::NOTIFICATION_PROFILE_ADDED) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + Profile* profile = content::Source<Profile>(source).ptr(); |
|
Mattias Nissler (ping if slow)
2014/05/12 08:26:43
chrome/browser/chromeos/settings deliberately does
ygorshenin1
2014/05/12 08:35:43
You mean to directly pass NSS slot instead of user
Mattias Nissler (ping if slow)
2014/05/12 08:40:31
Yes, my idea was indeed to pass the NSS slot refer
ygorshenin1
2014/05/12 08:56:54
SignAndStore() is implicitly called from DeviceSet
ygorshenin1
2014/05/13 09:46:13
All User/Profile-related things are extracted into
|
| + if (!profile || !UserManager::IsInitialized()) |
| + return; |
| + const User* user = UserManager::Get()->GetUserByProfile(profile); |
| + if (user && user->email() == username_ && user->is_logged_in()) { |
| + owner_key_ = NULL; |
| + EnsureReload(true); |
| + } |
| +} |
| + |
| void DeviceSettingsService::Enqueue(SessionManagerOperation* operation) { |
| pending_operations_.push_back(operation); |
| if (pending_operations_.front() == operation) |
| @@ -292,14 +316,17 @@ void DeviceSettingsService::EnqueueLoad(bool force_key_load) { |
| weak_factory_.GetWeakPtr(), |
| base::Closure())); |
| operation->set_force_key_load(force_key_load); |
| + operation->set_username(username_); |
| Enqueue(operation); |
| } |
| void DeviceSettingsService::EnsureReload(bool force_key_load) { |
| - if (!pending_operations_.empty()) |
| + if (!pending_operations_.empty()) { |
| + pending_operations_.front()->set_username(username_); |
| pending_operations_.front()->RestartLoad(force_key_load); |
| - else |
| + } else { |
| EnqueueLoad(force_key_load); |
| + } |
| } |
| void DeviceSettingsService::StartNextOperation() { |