Chromium Code Reviews| Index: components/proximity_auth/screenlock_bridge.cc |
| diff --git a/chrome/browser/signin/screenlock_bridge.cc b/components/proximity_auth/screenlock_bridge.cc |
| similarity index 80% |
| rename from chrome/browser/signin/screenlock_bridge.cc |
| rename to components/proximity_auth/screenlock_bridge.cc |
| index c8db7a3c6d5dbfa360842ac4957e9961cf157a88..2c89aefa80cf69361a4de55ad50a6e594531be7d 100644 |
| --- a/chrome/browser/signin/screenlock_bridge.cc |
| +++ b/components/proximity_auth/screenlock_bridge.cc |
| @@ -2,23 +2,20 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/signin/screenlock_bridge.h" |
| +#include "components/proximity_auth/screenlock_bridge.h" |
| #include "base/logging.h" |
| #include "base/strings/string16.h" |
| -#include "chrome/browser/profiles/profile_window.h" |
| -#include "chrome/browser/signin/signin_manager_factory.h" |
| -#include "components/signin/core/browser/signin_manager.h" |
| +#include "components/proximity_auth/proximity_auth_client.h" |
| #if defined(OS_CHROMEOS) |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| #include "chromeos/dbus/session_manager_client.h" |
| #endif |
| -namespace { |
| +namespace proximity_auth { |
|
Ilya Sherman
2015/04/24 21:22:02
Optional nit: I'd omit this newline.
msarda
2015/04/27 11:29:25
Done.
|
| -base::LazyInstance<ScreenlockBridge> g_screenlock_bridge_bridge_instance = |
| - LAZY_INSTANCE_INITIALIZER; |
| +namespace { |
| // Ids for the icons that are supported by lock screen and signin screen |
| // account picker as user pod custom icons. |
| @@ -53,9 +50,12 @@ std::string GetIdForIcon(ScreenlockBridge::UserPodCustomIcon icon) { |
| } // namespace |
| -// static |
| -ScreenlockBridge* ScreenlockBridge::Get() { |
| - return g_screenlock_bridge_bridge_instance.Pointer(); |
| +ScreenlockBridge::ScreenlockBridge(ProximityAuthClient* client) |
| + : client_(client), lock_handler_(nullptr) { |
| + DCHECK(client_); |
| +} |
| + |
| +ScreenlockBridge::~ScreenlockBridge() { |
| } |
| ScreenlockBridge::UserPodCustomIconOptions::UserPodCustomIconOptions() |
| @@ -64,7 +64,8 @@ ScreenlockBridge::UserPodCustomIconOptions::UserPodCustomIconOptions() |
| is_trial_run_(false) { |
| } |
| -ScreenlockBridge::UserPodCustomIconOptions::~UserPodCustomIconOptions() {} |
| +ScreenlockBridge::UserPodCustomIconOptions::~UserPodCustomIconOptions() { |
| +} |
| scoped_ptr<base::DictionaryValue> |
| ScreenlockBridge::UserPodCustomIconOptions::ToDictionaryValue() const { |
| @@ -116,24 +117,8 @@ void ScreenlockBridge::UserPodCustomIconOptions::SetTrialRun() { |
| is_trial_run_ = true; |
| } |
| -// static |
| -std::string ScreenlockBridge::GetAuthenticatedUserEmail( |
| - const Profile* profile) { |
| - // |profile| has to be a signed-in profile with SigninManager already |
| - // created. Otherwise, just crash to collect stack. |
| - const SigninManagerBase* signin_manager = |
| - SigninManagerFactory::GetForProfileIfExists(profile); |
| - return signin_manager->GetAuthenticatedUsername(); |
| -} |
| - |
| -ScreenlockBridge::ScreenlockBridge() : lock_handler_(NULL) { |
| -} |
| - |
| -ScreenlockBridge::~ScreenlockBridge() { |
| -} |
| - |
| void ScreenlockBridge::SetLockHandler(LockHandler* lock_handler) { |
| - DCHECK(lock_handler_ == NULL || lock_handler == NULL); |
| + DCHECK(lock_handler_ == nullptr || lock_handler == nullptr); |
| // Don't notify observers if there is no change -- i.e. if the screen was |
| // already unlocked, and is remaining unlocked. |
| @@ -163,22 +148,23 @@ void ScreenlockBridge::SetFocusedUser(const std::string& user_id) { |
| } |
| bool ScreenlockBridge::IsLocked() const { |
| - return lock_handler_ != NULL; |
| + return lock_handler_ != nullptr; |
| } |
| -void ScreenlockBridge::Lock(Profile* profile) { |
| +void ScreenlockBridge::Lock(content::BrowserContext* browser_context) { |
| #if defined(OS_CHROMEOS) |
| chromeos::SessionManagerClient* session_manager = |
| chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| session_manager->RequestLockScreen(); |
| #else |
| - profiles::LockProfile(profile); |
| + client_->Lock(browser_context); |
| #endif |
| } |
| -void ScreenlockBridge::Unlock(Profile* profile) { |
| - if (lock_handler_) |
| - lock_handler_->Unlock(GetAuthenticatedUserEmail(profile)); |
| +void ScreenlockBridge::Unlock(content::BrowserContext* browser_context) { |
| + if (lock_handler_) { |
| + lock_handler_->Unlock(client_->GetAuthenticatedUsername(browser_context)); |
| + } |
|
Ilya Sherman
2015/04/24 21:22:02
nit: No need for curlies.
msarda
2015/04/27 11:29:25
Done.
|
| } |
| void ScreenlockBridge::AddObserver(Observer* observer) { |
| @@ -188,3 +174,5 @@ void ScreenlockBridge::AddObserver(Observer* observer) { |
| void ScreenlockBridge::RemoveObserver(Observer* observer) { |
| observers_.RemoveObserver(observer); |
| } |
| + |
| +} // namespace proximity_auth |