Chromium Code Reviews| Index: chrome/browser/signin/easy_unlock_service.cc |
| diff --git a/chrome/browser/signin/easy_unlock_service.cc b/chrome/browser/signin/easy_unlock_service.cc |
| index 1afcbc9e128e45c78b357f083d75025b091eac08..ea74acb3e2025b2e697e429030c556048c6b8acb 100644 |
| --- a/chrome/browser/signin/easy_unlock_service.cc |
| +++ b/chrome/browser/signin/easy_unlock_service.cc |
| @@ -13,7 +13,9 @@ |
| #include "chrome/browser/extensions/component_loader.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" |
| #include "chrome/browser/signin/easy_unlock_service_factory.h" |
| +#include "chrome/browser/signin/screenlock_bridge.h" |
| #include "chrome/browser/ui/extensions/application_launch.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/pref_names.h" |
| @@ -45,7 +47,8 @@ EasyUnlockService* EasyUnlockService::Get(Profile* profile) { |
| } |
| EasyUnlockService::EasyUnlockService(Profile* profile) |
| - : profile_(profile), weak_ptr_factory_(this) { |
| + : profile_(profile), |
| + weak_ptr_factory_(this) { |
| extensions::ExtensionSystem::Get(profile_)->ready().Post( |
| FROM_HERE, |
| base::Bind(&EasyUnlockService::Initialize, |
| @@ -88,7 +91,7 @@ void EasyUnlockService::LaunchSetup() { |
| bool EasyUnlockService::IsAllowed() { |
| #if defined(OS_CHROMEOS) |
| - if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) |
| + if (!chromeos::UserManager::Get()->IsLoggedInAsRegularUser()) |
| return false; |
| if (!chromeos::ProfileHelper::IsPrimaryProfile(profile_)) |
| @@ -105,6 +108,12 @@ bool EasyUnlockService::IsAllowed() { |
| #endif |
| } |
| + |
| +EasyUnlockScreenlockStateHandler* |
| + EasyUnlockService::GetScreenlockStateHandler() { |
| + return screenlock_state_handler_.get(); |
| +} |
| + |
| void EasyUnlockService::Initialize() { |
| registrar_.Init(profile_->GetPrefs()); |
| registrar_.Add( |
| @@ -113,7 +122,7 @@ void EasyUnlockService::Initialize() { |
| OnPrefsChanged(); |
| } |
| -void EasyUnlockService::LoadApp() { |
| +bool EasyUnlockService::LoadApp() { |
| DCHECK(IsAllowed()); |
| #if defined(GOOGLE_CHROME_BUILD) |
| @@ -132,10 +141,13 @@ void EasyUnlockService::LoadApp() { |
| #endif // !defined(NDEBUG) |
| if (!easy_unlock_path.empty()) { |
| - GetComponentLoader(profile_) |
| + std::string id = GetComponentLoader(profile_) |
| ->Add(IDR_EASY_UNLOCK_MANIFEST, easy_unlock_path); |
| + return !id.empty(); |
| } |
| #endif // defined(GOOGLE_CHROME_BUILD) |
| + |
| + return false; |
| } |
| void EasyUnlockService::UnloadApp() { |
| @@ -143,8 +155,16 @@ void EasyUnlockService::UnloadApp() { |
| } |
| void EasyUnlockService::OnPrefsChanged() { |
| - if (IsAllowed()) |
| - LoadApp(); |
| - else |
| + if (IsAllowed()) { |
| + if (LoadApp()) { |
| + // If the app is loaded, set up screenlock_state_handler_. |
| + screenlock_state_handler_.reset(new EasyUnlockScreenlockStateHandler( |
| + ScreenlockBridge::GetAuthenticatedUserEmail(profile_), |
|
xiyuan
2014/08/12 21:51:49
I would prefer to what we have in PS24, where |scr
tbarzic
2014/08/12 22:12:52
ok, reverting this back. I'll keep reset before Un
xiyuan
2014/08/12 22:14:39
Sounds good.
|
| + profile_->GetPrefs(), |
| + ScreenlockBridge::Get())); |
| + } |
| + } else { |
| + screenlock_state_handler_.reset(); |
| UnloadApp(); |
| + } |
| } |