summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/login/app_launch_signin_screen.cc8
-rw-r--r--chrome/browser/chromeos/login/app_launch_signin_screen.h2
-rw-r--r--chrome/browser/chromeos/login/easy_unlock/bootstrap_user_flow.cc2
-rw-r--r--chrome/browser/chromeos/login/easy_unlock/easy_unlock_reauth.cc10
-rw-r--r--chrome/browser/chromeos/login/screens/user_selection_screen.cc18
-rw-r--r--chrome/browser/chromeos/login/screens/user_selection_screen.h16
-rw-r--r--chrome/browser/chromeos/login/ui/views/user_board_view.h9
-rw-r--r--chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc2
-rw-r--r--chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc32
-rw-r--r--chrome/browser/extensions/api/screenlock_private/screenlock_private_api.h21
-rw-r--r--chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc6
-rw-r--r--chrome/browser/signin/easy_unlock_auth_attempt.cc25
-rw-r--r--chrome/browser/signin/easy_unlock_auth_attempt_unittest.cc62
-rw-r--r--chrome/browser/signin/easy_unlock_screenlock_state_handler.cc73
-rw-r--r--chrome/browser/signin/easy_unlock_screenlock_state_handler.h25
-rw-r--r--chrome/browser/signin/easy_unlock_screenlock_state_handler_unittest.cc102
-rw-r--r--chrome/browser/signin/easy_unlock_service.cc7
-rw-r--r--chrome/browser/signin/easy_unlock_service_regular.cc20
-rw-r--r--chrome/browser/signin/easy_unlock_service_regular.h16
-rw-r--r--chrome/browser/signin/easy_unlock_service_signin_chromeos.cc16
-rw-r--r--chrome/browser/signin/easy_unlock_service_signin_chromeos.h18
-rw-r--r--chrome/browser/signin/proximity_auth_facade.cc76
-rw-r--r--chrome/browser/signin/proximity_auth_facade.h15
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc7
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h2
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc6
-rw-r--r--chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc6
-rw-r--r--chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc2
-rw-r--r--chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h7
-rw-r--r--chrome/browser/ui/webui/signin/user_manager_screen_handler.cc29
-rw-r--r--chrome/browser/ui/webui/signin/user_manager_screen_handler.h26
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--components/proximity_auth.gypi3
-rw-r--r--components/proximity_auth/BUILD.gn3
-rw-r--r--components/proximity_auth/DEPS6
-rw-r--r--components/proximity_auth/proximity_auth_client.h39
-rw-r--r--components/proximity_auth/screenlock_bridge.cc (renamed from chrome/browser/signin/screenlock_bridge.cc)52
-rw-r--r--components/proximity_auth/screenlock_bridge.h (renamed from chrome/browser/signin/screenlock_bridge.h)44
38 files changed, 498 insertions, 319 deletions
diff --git a/chrome/browser/chromeos/login/app_launch_signin_screen.cc b/chrome/browser/chromeos/login/app_launch_signin_screen.cc
index d98d51b..e13afed 100644
--- a/chrome/browser/chromeos/login/app_launch_signin_screen.cc
+++ b/chrome/browser/chromeos/login/app_launch_signin_screen.cc
@@ -8,10 +8,10 @@
#include "chrome/browser/chromeos/login/help_app_launcher.h"
#include "chrome/browser/chromeos/login/screens/user_selection_screen.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/login/auth/user_context.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
@@ -199,10 +199,10 @@ void AppLaunchSigninScreen::HandleGetUsers() {
for (user_manager::UserList::const_iterator it = users.begin();
it != users.end();
++it) {
- ScreenlockBridge::LockHandler::AuthType initial_auth_type =
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType initial_auth_type =
UserSelectionScreen::ShouldForceOnlineSignIn(*it)
- ? ScreenlockBridge::LockHandler::ONLINE_SIGN_IN
- : ScreenlockBridge::LockHandler::OFFLINE_PASSWORD;
+ ? proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN
+ : proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD;
base::DictionaryValue* user_dict = new base::DictionaryValue();
UserSelectionScreen::FillUserDictionary(
*it,
diff --git a/chrome/browser/chromeos/login/app_launch_signin_screen.h b/chrome/browser/chromeos/login/app_launch_signin_screen.h
index bc560bb..7a9bb77 100644
--- a/chrome/browser/chromeos/login/app_launch_signin_screen.h
+++ b/chrome/browser/chromeos/login/app_launch_signin_screen.h
@@ -8,10 +8,10 @@
#include <string>
#include "base/memory/ref_counted.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chromeos/login/auth/auth_status_consumer.h"
#include "chromeos/login/auth/authenticator.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
diff --git a/chrome/browser/chromeos/login/easy_unlock/bootstrap_user_flow.cc b/chrome/browser/chromeos/login/easy_unlock/bootstrap_user_flow.cc
index 1c55068..64a6b33 100644
--- a/chrome/browser/chromeos/login/easy_unlock/bootstrap_user_flow.cc
+++ b/chrome/browser/chromeos/login/easy_unlock/bootstrap_user_flow.cc
@@ -13,7 +13,7 @@
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/signin/easy_unlock_service.h"
#include "chrome/browser/signin/easy_unlock_service_regular.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "components/proximity_auth/screenlock_bridge.h"
namespace chromeos {
diff --git a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_reauth.cc b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_reauth.cc
index 1882dcb..f56fbbb 100644
--- a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_reauth.cc
+++ b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_reauth.cc
@@ -7,12 +7,13 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_reauth.h"
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "chromeos/login/auth/auth_status_consumer.h"
#include "chromeos/login/auth/user_context.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -74,8 +75,9 @@ class ReauthHandler : public content::NotificationObserver,
screen_locker->SetLoginStatusConsumer(this);
// Show tooltip explaining reauth.
- ScreenlockBridge::UserPodCustomIconOptions icon_options;
- icon_options.SetIcon(ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE);
+ proximity_auth::ScreenlockBridge::UserPodCustomIconOptions icon_options;
+ icon_options.SetIcon(
+ proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE);
icon_options.SetTooltip(
l10n_util::GetStringUTF16(
IDS_SMART_LOCK_SCREENLOCK_TOOLTIP_HARDLOCK_REAUTH_USER),
@@ -83,7 +85,7 @@ class ReauthHandler : public content::NotificationObserver,
const user_manager::UserList& lock_users = screen_locker->users();
DCHECK(lock_users.size() == 1);
- ScreenlockBridge::Get()->lock_handler()->ShowUserPodCustomIcon(
+ GetScreenlockBridgeInstance()->lock_handler()->ShowUserPodCustomIcon(
lock_users[0]->email(), icon_options);
}
diff --git a/chrome/browser/chromeos/login/screens/user_selection_screen.cc b/chrome/browser/chromeos/login/screens/user_selection_screen.cc
index 2156e875..9bcb404 100644
--- a/chrome/browser/chromeos/login/screens/user_selection_screen.cc
+++ b/chrome/browser/chromeos/login/screens/user_selection_screen.cc
@@ -18,9 +18,10 @@
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/signin/easy_unlock_service.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
#include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "components/user_manager/user_id.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_type.h"
@@ -118,14 +119,14 @@ UserSelectionScreen::UserSelectionScreen(const std::string& display_type)
}
UserSelectionScreen::~UserSelectionScreen() {
- ScreenlockBridge::Get()->SetLockHandler(nullptr);
+ GetScreenlockBridgeInstance()->SetLockHandler(nullptr);
ui::UserActivityDetector* activity_detector = ui::UserActivityDetector::Get();
if (activity_detector->HasObserver(this))
activity_detector->RemoveObserver(this);
}
void UserSelectionScreen::InitEasyUnlock() {
- ScreenlockBridge::Get()->SetLockHandler(this);
+ GetScreenlockBridgeInstance()->SetLockHandler(this);
}
void UserSelectionScreen::SetLoginDisplayDelegate(
@@ -445,15 +446,15 @@ void UserSelectionScreen::SetAuthType(const std::string& user_id,
view_->SetAuthType(user_id, auth_type, initial_value);
}
-ScreenlockBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType(
- const std::string& username) const {
+proximity_auth::ScreenlockBridge::LockHandler::AuthType
+UserSelectionScreen::GetAuthType(const std::string& username) const {
if (user_auth_type_map_.find(username) == user_auth_type_map_.end())
return OFFLINE_PASSWORD;
return user_auth_type_map_.find(username)->second;
}
-ScreenlockBridge::LockHandler::ScreenType UserSelectionScreen::GetScreenType()
- const {
+proximity_auth::ScreenlockBridge::LockHandler::ScreenType
+UserSelectionScreen::GetScreenType() const {
if (display_type_ == OobeUI::kLockDisplay)
return LOCK_SCREEN;
@@ -469,7 +470,8 @@ void UserSelectionScreen::ShowBannerMessage(const base::string16& message) {
void UserSelectionScreen::ShowUserPodCustomIcon(
const std::string& user_id,
- const ScreenlockBridge::UserPodCustomIconOptions& icon_options) {
+ const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions&
+ icon_options) {
scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue();
if (!icon || icon->empty())
return;
diff --git a/chrome/browser/chromeos/login/screens/user_selection_screen.h b/chrome/browser/chromeos/login/screens/user_selection_screen.h
index 74eab73..7b9c684 100644
--- a/chrome/browser/chromeos/login/screens/user_selection_screen.h
+++ b/chrome/browser/chromeos/login/screens/user_selection_screen.h
@@ -15,7 +15,7 @@
#include "chrome/browser/chromeos/login/signin/token_handle_util.h"
#include "chrome/browser/chromeos/login/ui/login_display.h"
#include "chrome/browser/chromeos/login/ui/models/user_board_model.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_id.h"
#include "ui/base/user_activity/user_activity_observer.h"
@@ -28,9 +28,10 @@ class LoginDisplayWebUIHandler;
class UserBoardView;
// This class represents User Selection screen: user pod-based login screen.
-class UserSelectionScreen : public ui::UserActivityObserver,
- public ScreenlockBridge::LockHandler,
- public UserBoardModel {
+class UserSelectionScreen
+ : public ui::UserActivityObserver,
+ public proximity_auth::ScreenlockBridge::LockHandler,
+ public UserBoardModel {
public:
explicit UserSelectionScreen(const std::string& display_type);
~UserSelectionScreen() override;
@@ -61,11 +62,12 @@ class UserSelectionScreen : public ui::UserActivityObserver,
void InitEasyUnlock();
- // ScreenlockBridge::LockHandler implementation:
+ // proximity_auth::ScreenlockBridge::LockHandler implementation:
void ShowBannerMessage(const base::string16& message) override;
void ShowUserPodCustomIcon(
const std::string& user_email,
- const ScreenlockBridge::UserPodCustomIconOptions& icon) override;
+ const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& icon)
+ override;
void HideUserPodCustomIcon(const std::string& user_email) override;
void EnableInput() override;
@@ -135,7 +137,7 @@ class UserSelectionScreen : public ui::UserActivityObserver,
// Map of usernames to their current authentication type. If a user is not
// contained in the map, it is using the default authentication type.
- std::map<std::string, ScreenlockBridge::LockHandler::AuthType>
+ std::map<std::string, proximity_auth::ScreenlockBridge::LockHandler::AuthType>
user_auth_type_map_;
// Timer for measuring idle state duration before password clear.
diff --git a/chrome/browser/chromeos/login/ui/views/user_board_view.h b/chrome/browser/chromeos/login/ui/views/user_board_view.h
index dae7a7d..30fe63f 100644
--- a/chrome/browser/chromeos/login/ui/views/user_board_view.h
+++ b/chrome/browser/chromeos/login/ui/views/user_board_view.h
@@ -10,7 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/values.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "components/proximity_auth/screenlock_bridge.h"
namespace chromeos {
@@ -35,9 +35,10 @@ class UserBoardView {
virtual void ShowUserPodCustomIcon(const std::string& user_id,
const base::DictionaryValue& icon) = 0;
virtual void HideUserPodCustomIcon(const std::string& user_id) = 0;
- virtual void SetAuthType(const std::string& user_id,
- ScreenlockBridge::LockHandler::AuthType auth_type,
- const base::string16& initial_value) = 0;
+ virtual void SetAuthType(
+ const std::string& user_id,
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
+ const base::string16& initial_value) = 0;
};
} // namespace chromeos
diff --git a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc
index 5785922..8844619 100644
--- a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc
+++ b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc
@@ -17,12 +17,12 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h"
#include "chrome/browser/signin/easy_unlock_service.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
#include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h"
#include "chrome/common/extensions/api/easy_unlock_private.h"
#include "chrome/grit/generated_resources.h"
#include "components/proximity_auth/bluetooth_util.h"
#include "components/proximity_auth/cryptauth/cryptauth_enrollment_utils.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "components/proximity_auth/switches.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
diff --git a/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc b/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc
index 78d1c49..283c569 100644
--- a/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc
+++ b/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc
@@ -8,6 +8,7 @@
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/easy_unlock_service.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
#include "chrome/common/extensions/api/screenlock_private.h"
#include "chrome/common/extensions/extension_constants.h"
#include "extensions/browser/app_window/app_window_registry.h"
@@ -20,23 +21,23 @@ namespace extensions {
namespace {
screenlock::AuthType FromLockHandlerAuthType(
- ScreenlockBridge::LockHandler::AuthType auth_type) {
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type) {
switch (auth_type) {
- case ScreenlockBridge::LockHandler::OFFLINE_PASSWORD:
+ case proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD:
return screenlock::AUTH_TYPE_OFFLINEPASSWORD;
- case ScreenlockBridge::LockHandler::NUMERIC_PIN:
+ case proximity_auth::ScreenlockBridge::LockHandler::NUMERIC_PIN:
return screenlock::AUTH_TYPE_NUMERICPIN;
- case ScreenlockBridge::LockHandler::USER_CLICK:
+ case proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK:
return screenlock::AUTH_TYPE_USERCLICK;
- case ScreenlockBridge::LockHandler::ONLINE_SIGN_IN:
+ case proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN:
// Apps should treat forced online sign in same as system password.
return screenlock::AUTH_TYPE_OFFLINEPASSWORD;
- case ScreenlockBridge::LockHandler::EXPAND_THEN_USER_CLICK:
+ case proximity_auth::ScreenlockBridge::LockHandler::EXPAND_THEN_USER_CLICK:
// This type is used for public sessions, which do not support screen
// locking.
NOTREACHED();
return screenlock::AUTH_TYPE_NONE;
- case ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD:
+ case proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD:
return screenlock::AUTH_TYPE_OFFLINEPASSWORD;
}
NOTREACHED();
@@ -50,7 +51,8 @@ ScreenlockPrivateGetLockedFunction::ScreenlockPrivateGetLockedFunction() {}
ScreenlockPrivateGetLockedFunction::~ScreenlockPrivateGetLockedFunction() {}
bool ScreenlockPrivateGetLockedFunction::RunAsync() {
- SetResult(new base::FundamentalValue(ScreenlockBridge::Get()->IsLocked()));
+ SetResult(
+ new base::FundamentalValue(GetScreenlockBridgeInstance()->IsLocked()));
SendResponse(error_.empty());
return true;
}
@@ -75,9 +77,9 @@ bool ScreenlockPrivateSetLockedFunction::RunAsync() {
if (service)
service->SetTrialRun();
}
- ScreenlockBridge::Get()->Lock(GetProfile());
+ GetScreenlockBridgeInstance()->Lock(GetProfile());
} else {
- ScreenlockBridge::Get()->Unlock(GetProfile());
+ GetScreenlockBridgeInstance()->Unlock(GetProfile());
}
SendResponse(error_.empty());
return true;
@@ -104,19 +106,19 @@ bool ScreenlockPrivateAcceptAuthAttemptFunction::RunSync() {
ScreenlockPrivateEventRouter::ScreenlockPrivateEventRouter(
content::BrowserContext* context)
: browser_context_(context) {
- ScreenlockBridge::Get()->AddObserver(this);
+ GetScreenlockBridgeInstance()->AddObserver(this);
}
ScreenlockPrivateEventRouter::~ScreenlockPrivateEventRouter() {}
void ScreenlockPrivateEventRouter::OnScreenDidLock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) {
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) {
DispatchEvent(screenlock::OnChanged::kEventName,
new base::FundamentalValue(true));
}
void ScreenlockPrivateEventRouter::OnScreenDidUnlock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) {
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) {
DispatchEvent(screenlock::OnChanged::kEventName,
new base::FundamentalValue(false));
}
@@ -146,11 +148,11 @@ ScreenlockPrivateEventRouter::GetFactoryInstance() {
}
void ScreenlockPrivateEventRouter::Shutdown() {
- ScreenlockBridge::Get()->RemoveObserver(this);
+ GetScreenlockBridgeInstance()->RemoveObserver(this);
}
bool ScreenlockPrivateEventRouter::OnAuthAttempted(
- ScreenlockBridge::LockHandler::AuthType auth_type,
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
const std::string& value) {
extensions::EventRouter* router =
extensions::EventRouter::Get(browser_context_);
diff --git a/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.h b/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.h
index fb87f12..d120c46 100644
--- a/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.h
+++ b/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.h
@@ -8,7 +8,7 @@
#include <string>
#include "chrome/browser/extensions/chrome_extension_function.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
namespace extensions {
@@ -50,14 +50,16 @@ class ScreenlockPrivateAcceptAuthAttemptFunction
DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateAcceptAuthAttemptFunction);
};
-class ScreenlockPrivateEventRouter : public extensions::BrowserContextKeyedAPI,
- public ScreenlockBridge::Observer {
+class ScreenlockPrivateEventRouter
+ : public extensions::BrowserContextKeyedAPI,
+ public proximity_auth::ScreenlockBridge::Observer {
public:
explicit ScreenlockPrivateEventRouter(content::BrowserContext* context);
~ScreenlockPrivateEventRouter() override;
- bool OnAuthAttempted(ScreenlockBridge::LockHandler::AuthType auth_type,
- const std::string& value);
+ bool OnAuthAttempted(
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
+ const std::string& value);
// BrowserContextKeyedAPI
static extensions::BrowserContextKeyedAPIFactory<
@@ -65,11 +67,12 @@ class ScreenlockPrivateEventRouter : public extensions::BrowserContextKeyedAPI,
GetFactoryInstance();
void Shutdown() override;
- // ScreenlockBridge::Observer
- void OnScreenDidLock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) override;
+ // proximity_auth::ScreenlockBridge::Observer
+ void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
+ screen_type) override;
void OnScreenDidUnlock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) override;
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type)
+ override;
void OnFocusedUserChanged(const std::string& user_id) override;
private:
diff --git a/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc b/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
index cf59938..3bc8d57 100644
--- a/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
+++ b/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/easy_unlock_service.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/common/profile_management_switches.h"
@@ -75,9 +76,8 @@ class ScreenlockPrivateApiTest : public ExtensionApiTest,
const content::NotificationDetails& details) override {
const std::string& content = *content::Details<std::string>(details).ptr();
if (content == kAttemptClickAuthMessage) {
- ScreenlockBridge::Get()->lock_handler()->SetAuthType(
- kTestUser,
- ScreenlockBridge::LockHandler::USER_CLICK,
+ GetScreenlockBridgeInstance()->lock_handler()->SetAuthType(
+ kTestUser, proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
base::string16());
EasyUnlockService::Get(profile())->AttemptAuth(kTestUser);
}
diff --git a/chrome/browser/signin/easy_unlock_auth_attempt.cc b/chrome/browser/signin/easy_unlock_auth_attempt.cc
index 44ca2d9..5560754 100644
--- a/chrome/browser/signin/easy_unlock_auth_attempt.cc
+++ b/chrome/browser/signin/easy_unlock_auth_attempt.cc
@@ -7,7 +7,8 @@
#include "base/bind.h"
#include "base/logging.h"
#include "chrome/browser/signin/easy_unlock_app_manager.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "crypto/encryptor.h"
#include "crypto/symmetric_key.h"
@@ -50,25 +51,25 @@ void DefaultAuthAttemptFinalizedHandler(
const std::string& user_id,
const std::string& key_secret,
const std::string& key_label) {
- if (!ScreenlockBridge::Get()->IsLocked())
+ if (!GetScreenlockBridgeInstance()->IsLocked())
return;
switch (auth_attempt_type) {
case EasyUnlockAuthAttempt::TYPE_UNLOCK:
if (success) {
- ScreenlockBridge::Get()->lock_handler()->Unlock(user_id);
+ GetScreenlockBridgeInstance()->lock_handler()->Unlock(user_id);
} else {
- ScreenlockBridge::Get()->lock_handler()->EnableInput();
+ GetScreenlockBridgeInstance()->lock_handler()->EnableInput();
}
return;
case EasyUnlockAuthAttempt::TYPE_SIGNIN:
if (success) {
- ScreenlockBridge::Get()->lock_handler()->AttemptEasySignin(
+ GetScreenlockBridgeInstance()->lock_handler()->AttemptEasySignin(
user_id, key_secret, key_label);
} else {
// Attempting signin with an empty secret is equivalent to canceling the
// attempt.
- ScreenlockBridge::Get()->lock_handler()->AttemptEasySignin(
+ GetScreenlockBridgeInstance()->lock_handler()->AttemptEasySignin(
user_id, std::string(), std::string());
}
return;
@@ -99,13 +100,13 @@ EasyUnlockAuthAttempt::~EasyUnlockAuthAttempt() {
bool EasyUnlockAuthAttempt::Start() {
DCHECK_EQ(STATE_IDLE, state_);
- if (!ScreenlockBridge::Get()->IsLocked())
+ if (!GetScreenlockBridgeInstance()->IsLocked())
return false;
- ScreenlockBridge::LockHandler::AuthType auth_type =
- ScreenlockBridge::Get()->lock_handler()->GetAuthType(user_id_);
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type =
+ GetScreenlockBridgeInstance()->lock_handler()->GetAuthType(user_id_);
- if (auth_type != ScreenlockBridge::LockHandler::USER_CLICK) {
+ if (auth_type != proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK) {
Cancel(user_id_);
return false;
}
@@ -125,7 +126,7 @@ void EasyUnlockAuthAttempt::FinalizeUnlock(const std::string& user_id,
if (state_ != STATE_RUNNING || user_id != user_id_)
return;
- if (!ScreenlockBridge::Get()->IsLocked())
+ if (!GetScreenlockBridgeInstance()->IsLocked())
return;
if (type_ != TYPE_UNLOCK) {
@@ -144,7 +145,7 @@ void EasyUnlockAuthAttempt::FinalizeSignin(const std::string& user_id,
if (state_ != STATE_RUNNING || user_id != user_id_)
return;
- if (!ScreenlockBridge::Get()->IsLocked())
+ if (!GetScreenlockBridgeInstance()->IsLocked())
return;
if (type_ != TYPE_SIGNIN) {
diff --git a/chrome/browser/signin/easy_unlock_auth_attempt_unittest.cc b/chrome/browser/signin/easy_unlock_auth_attempt_unittest.cc
index 0cf2f87..3b183cf 100644
--- a/chrome/browser/signin/easy_unlock_auth_attempt_unittest.cc
+++ b/chrome/browser/signin/easy_unlock_auth_attempt_unittest.cc
@@ -6,7 +6,8 @@
#include "base/macros.h"
#include "chrome/browser/signin/easy_unlock_app_manager.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_CHROMEOS)
@@ -100,7 +101,7 @@ class FakeAppManager : public EasyUnlockAppManager {
};
// Fake lock handler to be used in these tests.
-class TestLockHandler : public ScreenlockBridge::LockHandler {
+class TestLockHandler : public proximity_auth::ScreenlockBridge::LockHandler {
public:
// The state of unlock/signin procedure.
enum AuthState {
@@ -133,14 +134,15 @@ class TestLockHandler : public ScreenlockBridge::LockHandler {
// Not using |SetAuthType| to make sure it's not called during tests.
void set_auth_type(AuthType value) { auth_type_ = value; }
- // ScreenlockBridge::LockHandler implementation:
+ // proximity_auth::ScreenlockBridge::LockHandler implementation:
void ShowBannerMessage(const base::string16& message) override {
ADD_FAILURE() << "Should not be reached.";
}
void ShowUserPodCustomIcon(
const std::string& user_email,
- const ScreenlockBridge::UserPodCustomIconOptions& icon) override {
+ const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& icon)
+ override {
ADD_FAILURE() << "Should not be reached.";
}
@@ -215,7 +217,7 @@ class EasyUnlockAuthAttemptUnlockTest : public testing::Test {
}
void TearDown() override {
- ScreenlockBridge::Get()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
auth_attempt_.reset();
}
@@ -223,7 +225,7 @@ class EasyUnlockAuthAttemptUnlockTest : public testing::Test {
void InitScreenLock() {
lock_handler_.reset(new TestLockHandler(kTestUser1));
lock_handler_->set_state(TestLockHandler::STATE_ATTEMPTING_UNLOCK);
- ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
+ GetScreenlockBridgeInstance()->SetLockHandler(lock_handler_.get());
}
scoped_ptr<EasyUnlockAuthAttempt> auth_attempt_;
@@ -235,7 +237,7 @@ class EasyUnlockAuthAttemptUnlockTest : public testing::Test {
};
TEST_F(EasyUnlockAuthAttemptUnlockTest, StartWhenNotLocked) {
- ASSERT_FALSE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_FALSE(GetScreenlockBridgeInstance()->IsLocked());
EXPECT_FALSE(auth_attempt_->Start());
EXPECT_EQ(0u, app_manager_->auth_attempt_count());
@@ -243,10 +245,11 @@ TEST_F(EasyUnlockAuthAttemptUnlockTest, StartWhenNotLocked) {
TEST_F(EasyUnlockAuthAttemptUnlockTest, StartWhenAuthTypeIsPassword) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_UNLOCK, lock_handler_->state());
- lock_handler_->set_auth_type(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD);
+ lock_handler_->set_auth_type(
+ proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD);
EXPECT_FALSE(auth_attempt_->Start());
@@ -257,7 +260,7 @@ TEST_F(EasyUnlockAuthAttemptUnlockTest, StartWhenAuthTypeIsPassword) {
TEST_F(EasyUnlockAuthAttemptUnlockTest,
StartWhenDispatchingAuthAttemptEventFails) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_UNLOCK, lock_handler_->state());
app_manager_->set_auth_attempt_should_fail(true);
@@ -270,7 +273,7 @@ TEST_F(EasyUnlockAuthAttemptUnlockTest,
TEST_F(EasyUnlockAuthAttemptUnlockTest, ResetBeforeFinalizeUnlock) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_UNLOCK, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -285,7 +288,7 @@ TEST_F(EasyUnlockAuthAttemptUnlockTest, ResetBeforeFinalizeUnlock) {
TEST_F(EasyUnlockAuthAttemptUnlockTest, FinalizeUnlockFailure) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_UNLOCK, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -300,7 +303,7 @@ TEST_F(EasyUnlockAuthAttemptUnlockTest, FinalizeUnlockFailure) {
TEST_F(EasyUnlockAuthAttemptUnlockTest, FinalizeSigninCalled) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_UNLOCK, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -317,7 +320,7 @@ TEST_F(EasyUnlockAuthAttemptUnlockTest, FinalizeSigninCalled) {
TEST_F(EasyUnlockAuthAttemptUnlockTest, UnlockSucceeds) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_UNLOCK, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -332,7 +335,7 @@ TEST_F(EasyUnlockAuthAttemptUnlockTest, UnlockSucceeds) {
TEST_F(EasyUnlockAuthAttemptUnlockTest, FinalizeUnlockCalledForWrongUser) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_UNLOCK, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -367,7 +370,7 @@ class EasyUnlockAuthAttemptSigninTest : public testing::Test {
}
void TearDown() override {
- ScreenlockBridge::Get()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
auth_attempt_.reset();
}
@@ -375,7 +378,7 @@ class EasyUnlockAuthAttemptSigninTest : public testing::Test {
void InitScreenLock() {
lock_handler_.reset(new TestLockHandler(kTestUser1));
lock_handler_->set_state(TestLockHandler::STATE_ATTEMPTING_SIGNIN);
- ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
+ GetScreenlockBridgeInstance()->SetLockHandler(lock_handler_.get());
}
scoped_ptr<EasyUnlockAuthAttempt> auth_attempt_;
@@ -387,7 +390,7 @@ class EasyUnlockAuthAttemptSigninTest : public testing::Test {
};
TEST_F(EasyUnlockAuthAttemptSigninTest, StartWhenNotLocked) {
- ASSERT_FALSE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_FALSE(GetScreenlockBridgeInstance()->IsLocked());
EXPECT_FALSE(auth_attempt_->Start());
EXPECT_EQ(0u, app_manager_->auth_attempt_count());
@@ -395,10 +398,11 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, StartWhenNotLocked) {
TEST_F(EasyUnlockAuthAttemptSigninTest, StartWhenAuthTypeIsPassword) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_SIGNIN, lock_handler_->state());
- lock_handler_->set_auth_type(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD);
+ lock_handler_->set_auth_type(
+ proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD);
EXPECT_FALSE(auth_attempt_->Start());
@@ -409,7 +413,7 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, StartWhenAuthTypeIsPassword) {
TEST_F(EasyUnlockAuthAttemptSigninTest,
StartWhenDispatchingAuthAttemptEventFails) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_SIGNIN, lock_handler_->state());
app_manager_->set_auth_attempt_should_fail(true);
@@ -422,7 +426,7 @@ TEST_F(EasyUnlockAuthAttemptSigninTest,
TEST_F(EasyUnlockAuthAttemptSigninTest, ResetBeforeFinalizeSignin) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_SIGNIN, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -437,7 +441,7 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, ResetBeforeFinalizeSignin) {
TEST_F(EasyUnlockAuthAttemptSigninTest, FinalizeSigninWithEmtpySecret) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_SIGNIN, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -452,7 +456,7 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, FinalizeSigninWithEmtpySecret) {
TEST_F(EasyUnlockAuthAttemptSigninTest, FinalizeSigninWithEmtpyKey) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_SIGNIN, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -467,7 +471,7 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, FinalizeSigninWithEmtpyKey) {
TEST_F(EasyUnlockAuthAttemptSigninTest, SigninSuccess) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_SIGNIN, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -484,7 +488,7 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, SigninSuccess) {
TEST_F(EasyUnlockAuthAttemptSigninTest, WrongWrappedSecret) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_SIGNIN, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -499,7 +503,7 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, WrongWrappedSecret) {
TEST_F(EasyUnlockAuthAttemptSigninTest, InvalidSessionKey) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_SIGNIN, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -514,7 +518,7 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, InvalidSessionKey) {
TEST_F(EasyUnlockAuthAttemptSigninTest, FinalizeUnlockCalled) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_SIGNIN, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
@@ -529,7 +533,7 @@ TEST_F(EasyUnlockAuthAttemptSigninTest, FinalizeUnlockCalled) {
TEST_F(EasyUnlockAuthAttemptSigninTest, FinalizeSigninCalledForWrongUser) {
InitScreenLock();
- ASSERT_TRUE(ScreenlockBridge::Get()->IsLocked());
+ ASSERT_TRUE(GetScreenlockBridgeInstance()->IsLocked());
ASSERT_EQ(TestLockHandler::STATE_ATTEMPTING_SIGNIN, lock_handler_->state());
ASSERT_TRUE(auth_attempt_->Start());
diff --git a/chrome/browser/signin/easy_unlock_screenlock_state_handler.cc b/chrome/browser/signin/easy_unlock_screenlock_state_handler.cc
index 3a4ee63..4b7171a 100644
--- a/chrome/browser/signin/easy_unlock_screenlock_state_handler.cc
+++ b/chrome/browser/signin/easy_unlock_screenlock_state_handler.cc
@@ -14,7 +14,7 @@
namespace {
-ScreenlockBridge::UserPodCustomIcon GetIconForState(
+proximity_auth::ScreenlockBridge::UserPodCustomIcon GetIconForState(
EasyUnlockScreenlockStateHandler::State state) {
switch (state) {
case EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH:
@@ -24,20 +24,21 @@ ScreenlockBridge::UserPodCustomIcon GetIconForState(
case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE:
case EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED:
case EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW:
- return ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED;
+ return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED;
case EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH:
case EasyUnlockScreenlockStateHandler::
STATE_PHONE_LOCKED_AND_TX_POWER_TOO_HIGH:
// TODO(isherman): This icon is currently identical to the regular locked
// icon. Once the reduced proximity range flag is removed, consider
// deleting the redundant icon.
- return ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED_WITH_PROXIMITY_HINT;
+ return proximity_auth::ScreenlockBridge::
+ USER_POD_CUSTOM_ICON_LOCKED_WITH_PROXIMITY_HINT;
case EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING:
- return ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER;
+ return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER;
case EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED:
- return ScreenlockBridge::USER_POD_CUSTOM_ICON_UNLOCKED;
+ return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_UNLOCKED;
default:
- return ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE;
+ return proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE;
}
}
@@ -93,11 +94,10 @@ bool IsLockedState(EasyUnlockScreenlockStateHandler::State state) {
} // namespace
-
EasyUnlockScreenlockStateHandler::EasyUnlockScreenlockStateHandler(
const std::string& user_email,
HardlockState initial_hardlock_state,
- ScreenlockBridge* screenlock_bridge)
+ proximity_auth::ScreenlockBridge* screenlock_bridge)
: state_(STATE_INACTIVE),
user_email_(user_email),
screenlock_bridge_(screenlock_bridge),
@@ -140,7 +140,7 @@ void EasyUnlockScreenlockStateHandler::ChangeState(State new_state) {
// Do nothing when auth type is online.
if (screenlock_bridge_->lock_handler()->GetAuthType(user_email_) ==
- ScreenlockBridge::LockHandler::ONLINE_SIGN_IN) {
+ proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN) {
return;
}
@@ -155,14 +155,15 @@ void EasyUnlockScreenlockStateHandler::ChangeState(State new_state) {
UpdateScreenlockAuthType();
- ScreenlockBridge::UserPodCustomIcon icon = GetIconForState(state_);
+ proximity_auth::ScreenlockBridge::UserPodCustomIcon icon =
+ GetIconForState(state_);
- if (icon == ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE) {
+ if (icon == proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_NONE) {
screenlock_bridge_->lock_handler()->HideUserPodCustomIcon(user_email_);
return;
}
- ScreenlockBridge::UserPodCustomIconOptions icon_options;
+ proximity_auth::ScreenlockBridge::UserPodCustomIconOptions icon_options;
icon_options.SetIcon(icon);
// Don't hardlock on trial run.
@@ -222,13 +223,13 @@ void EasyUnlockScreenlockStateHandler::RecordClickOnLockIcon() {
}
void EasyUnlockScreenlockStateHandler::OnScreenDidLock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) {
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) {
did_see_locked_phone_ = IsLockedState(state_);
RefreshScreenlockState();
}
void EasyUnlockScreenlockStateHandler::OnScreenDidUnlock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) {
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) {
if (hardlock_state_ == LOGIN_FAILED)
hardlock_state_ = NO_HARDLOCK;
hardlock_ui_shown_ = false;
@@ -259,15 +260,18 @@ void EasyUnlockScreenlockStateHandler::ShowHardlockUI() {
return;
// Do not override online signin.
- const ScreenlockBridge::LockHandler::AuthType existing_auth_type =
- screenlock_bridge_->lock_handler()->GetAuthType(user_email_);
- if (existing_auth_type == ScreenlockBridge::LockHandler::ONLINE_SIGN_IN)
+ const proximity_auth::ScreenlockBridge::LockHandler::AuthType
+ existing_auth_type =
+ screenlock_bridge_->lock_handler()->GetAuthType(user_email_);
+ if (existing_auth_type ==
+ proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN)
return;
- if (existing_auth_type != ScreenlockBridge::LockHandler::OFFLINE_PASSWORD) {
+ if (existing_auth_type !=
+ proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD) {
screenlock_bridge_->lock_handler()->SetAuthType(
user_email_,
- ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
base::string16());
}
@@ -280,15 +284,17 @@ void EasyUnlockScreenlockStateHandler::ShowHardlockUI() {
if (hardlock_ui_shown_)
return;
- ScreenlockBridge::UserPodCustomIconOptions icon_options;
+ proximity_auth::ScreenlockBridge::UserPodCustomIconOptions icon_options;
if (hardlock_state_ == LOGIN_FAILED) {
- icon_options.SetIcon(ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED);
+ icon_options.SetIcon(
+ proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED);
} else if (hardlock_state_ == PAIRING_CHANGED ||
hardlock_state_ == PAIRING_ADDED) {
- icon_options.SetIcon(
- ScreenlockBridge::USER_POD_CUSTOM_ICON_LOCKED_TO_BE_ACTIVATED);
+ icon_options.SetIcon(proximity_auth::ScreenlockBridge::
+ USER_POD_CUSTOM_ICON_LOCKED_TO_BE_ACTIVATED);
} else {
- icon_options.SetIcon(ScreenlockBridge::USER_POD_CUSTOM_ICON_HARDLOCKED);
+ icon_options.SetIcon(
+ proximity_auth::ScreenlockBridge::USER_POD_CUSTOM_ICON_HARDLOCKED);
}
base::string16 device_name = GetDeviceName();
@@ -317,7 +323,7 @@ void EasyUnlockScreenlockStateHandler::ShowHardlockUI() {
}
void EasyUnlockScreenlockStateHandler::UpdateTooltipOptions(
- ScreenlockBridge::UserPodCustomIconOptions* icon_options) {
+ proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options) {
size_t resource_id = 0;
base::string16 device_name;
if (is_trial_run_ && state_ == STATE_AUTHENTICATED) {
@@ -360,23 +366,26 @@ void EasyUnlockScreenlockStateHandler::UpdateScreenlockAuthType() {
return;
// Do not override online signin.
- const ScreenlockBridge::LockHandler::AuthType existing_auth_type =
- screenlock_bridge_->lock_handler()->GetAuthType(user_email_);
- DCHECK_NE(ScreenlockBridge::LockHandler::ONLINE_SIGN_IN, existing_auth_type);
+ const proximity_auth::ScreenlockBridge::LockHandler::AuthType
+ existing_auth_type =
+ screenlock_bridge_->lock_handler()->GetAuthType(user_email_);
+ DCHECK_NE(proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN,
+ existing_auth_type);
if (state_ == STATE_AUTHENTICATED) {
- if (existing_auth_type != ScreenlockBridge::LockHandler::USER_CLICK) {
+ if (existing_auth_type !=
+ proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK) {
screenlock_bridge_->lock_handler()->SetAuthType(
user_email_,
- ScreenlockBridge::LockHandler::USER_CLICK,
+ proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
l10n_util::GetStringUTF16(
IDS_EASY_UNLOCK_SCREENLOCK_USER_POD_AUTH_VALUE));
}
} else if (existing_auth_type !=
- ScreenlockBridge::LockHandler::OFFLINE_PASSWORD) {
+ proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD) {
screenlock_bridge_->lock_handler()->SetAuthType(
user_email_,
- ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
base::string16());
}
}
diff --git a/chrome/browser/signin/easy_unlock_screenlock_state_handler.h b/chrome/browser/signin/easy_unlock_screenlock_state_handler.h
index d6f722b..096839a 100644
--- a/chrome/browser/signin/easy_unlock_screenlock_state_handler.h
+++ b/chrome/browser/signin/easy_unlock_screenlock_state_handler.h
@@ -8,13 +8,14 @@
#include <string>
#include "base/strings/string16.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "components/proximity_auth/screenlock_bridge.h"
class PrefService;
// Profile specific class responsible for updating screenlock UI for the user
// associated with the profile when their Easy Unlock state changes.
-class EasyUnlockScreenlockStateHandler : public ScreenlockBridge::Observer {
+class EasyUnlockScreenlockStateHandler
+ : public proximity_auth::ScreenlockBridge::Observer {
public:
// Available Easy Unlock states.
enum State {
@@ -71,9 +72,10 @@ class EasyUnlockScreenlockStateHandler : public ScreenlockBridge::Observer {
// |initial_hardlock_state|: The initial hardlock state.
// |screenlock_bridge|: The screenlock bridge used to update the screen lock
// state.
- EasyUnlockScreenlockStateHandler(const std::string& user_email,
- HardlockState initial_hardlock_state,
- ScreenlockBridge* screenlock_bridge);
+ EasyUnlockScreenlockStateHandler(
+ const std::string& user_email,
+ HardlockState initial_hardlock_state,
+ proximity_auth::ScreenlockBridge* screenlock_bridge);
~EasyUnlockScreenlockStateHandler() override;
// Returns true if handler is not in INACTIVE state.
@@ -104,11 +106,12 @@ class EasyUnlockScreenlockStateHandler : public ScreenlockBridge::Observer {
State state() const { return state_; }
private:
- // ScreenlockBridge::Observer:
- void OnScreenDidLock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) override;
+ // proximity_auth::ScreenlockBridge::Observer:
+ void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
+ screen_type) override;
void OnScreenDidUnlock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) override;
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type)
+ override;
void OnFocusedUserChanged(const std::string& user_id) override;
// Forces refresh of the Easy Unlock screenlock UI.
@@ -118,7 +121,7 @@ class EasyUnlockScreenlockStateHandler : public ScreenlockBridge::Observer {
// Updates icon's tooltip options.
void UpdateTooltipOptions(
- ScreenlockBridge::UserPodCustomIconOptions* icon_options);
+ proximity_auth::ScreenlockBridge::UserPodCustomIconOptions* icon_options);
// Gets the name to be used for the device. The name depends on the device
// type (example values: Chromebook and Chromebox).
@@ -129,7 +132,7 @@ class EasyUnlockScreenlockStateHandler : public ScreenlockBridge::Observer {
State state_;
std::string user_email_;
- ScreenlockBridge* screenlock_bridge_;
+ proximity_auth::ScreenlockBridge* screenlock_bridge_;
// State of hardlock.
HardlockState hardlock_state_;
diff --git a/chrome/browser/signin/easy_unlock_screenlock_state_handler_unittest.cc b/chrome/browser/signin/easy_unlock_screenlock_state_handler_unittest.cc
index 75aa1b2..84b3901 100644
--- a/chrome/browser/signin/easy_unlock_screenlock_state_handler_unittest.cc
+++ b/chrome/browser/signin/easy_unlock_screenlock_state_handler_unittest.cc
@@ -13,15 +13,16 @@
#include "base/test/histogram_tester.h"
#include "chrome/browser/signin/easy_unlock_metrics.h"
#include "chrome/browser/signin/easy_unlock_service.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
#include "chrome/grit/generated_resources.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
namespace {
// Icons used by EasyUnlockScreenlockStateHandler. The icon id values are the
-// same as the ones set by ScreenlockBridge.
+// same as the ones set by proximity_auth::ScreenlockBridge.
const char kLockedIconId[] = "locked";
const char kLockedToBeActivatedIconId[] = "locked-to-be-activated";
const char kUnlockedIconId[] = "unlocked";
@@ -39,7 +40,7 @@ bool StringHasPlaceholders(const base::string16& input) {
}
// Fake lock handler to be used in these tests.
-class TestLockHandler : public ScreenlockBridge::LockHandler {
+class TestLockHandler : public proximity_auth::ScreenlockBridge::LockHandler {
public:
explicit TestLockHandler(const std::string& user_email)
: user_email_(user_email),
@@ -48,14 +49,15 @@ class TestLockHandler : public ScreenlockBridge::LockHandler {
}
~TestLockHandler() override {}
- // ScreenlockBridge::LockHandler implementation:
+ // proximity_auth::ScreenlockBridge::LockHandler implementation:
void ShowBannerMessage(const base::string16& message) override {
ASSERT_FALSE(true) << "Should not be reached.";
}
void ShowUserPodCustomIcon(
const std::string& user_email,
- const ScreenlockBridge::UserPodCustomIconOptions& icon) override {
+ const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& icon)
+ override {
ASSERT_EQ(user_email_, user_email);
++show_icon_count_;
last_custom_icon_ = icon.ToDictionaryValue().Pass();
@@ -207,7 +209,8 @@ class EasyUnlockScreenlockStateHandlerTest : public testing::Test {
void SetUp() override {
// Create and inject fake lock handler to the screenlock bridge.
lock_handler_.reset(new TestLockHandler(user_email_));
- ScreenlockBridge* screenlock_bridge = ScreenlockBridge::Get();
+ proximity_auth::ScreenlockBridge* screenlock_bridge =
+ GetScreenlockBridgeInstance();
screenlock_bridge->SetLockHandler(lock_handler_.get());
// Create the screenlock state handler object that will be tested.
@@ -218,7 +221,7 @@ class EasyUnlockScreenlockStateHandlerTest : public testing::Test {
}
void TearDown() override {
- ScreenlockBridge::Get()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
lock_handler_.reset();
state_handler_.reset();
}
@@ -230,8 +233,8 @@ class EasyUnlockScreenlockStateHandlerTest : public testing::Test {
// The user associated with |state_handler_|.
const std::string user_email_;
- // Faked lock handler given to ScreenlockBridge during the test. Abstracts
- // the screen lock UI.
+ // Faked lock handler given to proximity_auth::ScreenlockBridge during the
+ // test. Abstracts the screen lock UI.
scoped_ptr<TestLockHandler> lock_handler_;
};
@@ -241,7 +244,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, AuthenticatedTrialRun) {
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
@@ -261,7 +264,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, AuthenticatedNotInitialRun) {
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
@@ -287,7 +290,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, BluetoothConnecting) {
EXPECT_TRUE(state_handler_->IsActive());
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
@@ -306,14 +309,14 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, HardlockedState) {
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
state_handler_->SetHardlockState(
EasyUnlockScreenlockStateHandler::USER_HARDLOCK);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
@@ -334,14 +337,14 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, HardlockedStateNoPairing) {
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
state_handler_->SetHardlockState(
EasyUnlockScreenlockStateHandler::NO_PAIRING);
EXPECT_FALSE(lock_handler_->HasCustomIcon());
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_));
}
@@ -361,7 +364,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, StatesWithLockedIcon) {
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount())
<< "State: " << states[i];
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_))
<< "State: " << states[i];
@@ -387,7 +390,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, SettingTrialRunUpdatesUI) {
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
@@ -396,7 +399,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, SettingTrialRunUpdatesUI) {
state_handler_->SetTrialRun();
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
@@ -409,7 +412,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest,
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
@@ -417,7 +420,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest,
state_handler_.reset();
EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_));
ASSERT_FALSE(lock_handler_->HasCustomIcon());
@@ -428,17 +431,17 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, StatePreservedWhenScreenUnlocks) {
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
- ScreenlockBridge::Get()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
lock_handler_.reset(new TestLockHandler(user_email_));
EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
- ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
+ GetScreenlockBridgeInstance()->SetLockHandler(lock_handler_.get());
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
}
@@ -448,21 +451,21 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, StateChangeWhileScreenUnlocked) {
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
- ScreenlockBridge::Get()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
lock_handler_.reset(new TestLockHandler(user_email_));
EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
state_handler_->ChangeState(
EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING);
- ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
+ GetScreenlockBridgeInstance()->SetLockHandler(lock_handler_.get());
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
EXPECT_EQ(kSpinnerIconId, lock_handler_->GetCustomIconId());
@@ -492,9 +495,9 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest,
<< "State: " << states[i];
}
- ScreenlockBridge::Get()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
lock_handler_.reset(new TestLockHandler(user_email_));
- ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
+ GetScreenlockBridgeInstance()->SetLockHandler(lock_handler_.get());
for (size_t i = 0; i < states.size(); ++i) {
state_handler_->ChangeState(states[i]);
@@ -618,14 +621,14 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, StateChangesIgnoredIfHardlocked) {
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
state_handler_->SetHardlockState(
EasyUnlockScreenlockStateHandler::USER_HARDLOCK);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
EXPECT_EQ(kHardlockedIconId, lock_handler_->GetCustomIconId());
@@ -639,7 +642,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, StateChangesIgnoredIfHardlocked) {
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
ASSERT_TRUE(lock_handler_->HasCustomIcon());
EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_));
}
@@ -655,10 +658,10 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest,
state_handler_->SetHardlockState(
EasyUnlockScreenlockStateHandler::NO_HARDLOCK);
- ScreenlockBridge::Get()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
lock_handler_.reset(new TestLockHandler(user_email_));
EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
- ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
+ GetScreenlockBridgeInstance()->SetLockHandler(lock_handler_.get());
state_handler_->ChangeState(
EasyUnlockScreenlockStateHandler::STATE_NO_PHONE);
@@ -666,14 +669,14 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest,
EXPECT_EQ(2u, lock_handler_->GetAndResetShowIconCount());
EXPECT_TRUE(lock_handler_->HasCustomIcon());
- ScreenlockBridge::Get()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
lock_handler_.reset(new TestLockHandler(user_email_));
EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
- ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
+ GetScreenlockBridgeInstance()->SetLockHandler(lock_handler_.get());
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
EXPECT_TRUE(lock_handler_->HasCustomIcon());
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_));
EXPECT_EQ(kLockedIconId, lock_handler_->GetCustomIconId());
@@ -681,7 +684,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest,
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
EXPECT_TRUE(lock_handler_->HasCustomIcon());
- EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK,
lock_handler_->GetAuthType(user_email_));
EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick());
}
@@ -693,13 +696,13 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, HardlockStatePersistsOverUnlocks) {
EasyUnlockScreenlockStateHandler::USER_HARDLOCK);
EXPECT_EQ(2u, lock_handler_->GetAndResetShowIconCount());
- ScreenlockBridge::Get()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
lock_handler_.reset(new TestLockHandler(user_email_));
EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
- ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
+ GetScreenlockBridgeInstance()->SetLockHandler(lock_handler_.get());
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_));
ASSERT_TRUE(lock_handler_->HasCustomIcon());
EXPECT_EQ(kHardlockedIconId, lock_handler_->GetCustomIconId());
@@ -708,14 +711,15 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, HardlockStatePersistsOverUnlocks) {
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
EXPECT_TRUE(lock_handler_->HasCustomIcon());
- EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
lock_handler_->GetAuthType(user_email_));
}
TEST_F(EasyUnlockScreenlockStateHandlerTest, NoOverrideOnlineSignin) {
- lock_handler_->SetAuthType(user_email_,
- ScreenlockBridge::LockHandler::ONLINE_SIGN_IN,
- base::string16());
+ lock_handler_->SetAuthType(
+ user_email_,
+ proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN,
+ base::string16());
std::vector<EasyUnlockScreenlockStateHandler::State> states;
states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH);
@@ -733,7 +737,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, NoOverrideOnlineSignin) {
for (size_t i = 0; i < states.size(); ++i) {
state_handler_->ChangeState(states[i]);
- EXPECT_EQ(ScreenlockBridge::LockHandler::ONLINE_SIGN_IN,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN,
lock_handler_->GetAuthType(user_email_));
EXPECT_FALSE(lock_handler_->HasCustomIcon());
}
@@ -748,7 +752,7 @@ TEST_F(EasyUnlockScreenlockStateHandlerTest, NoOverrideOnlineSignin) {
for (size_t i = 0; i < hardlock_states.size(); ++i) {
state_handler_->SetHardlockState(hardlock_states[i]);
- EXPECT_EQ(ScreenlockBridge::LockHandler::ONLINE_SIGN_IN,
+ EXPECT_EQ(proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN,
lock_handler_->GetAuthType(user_email_));
EXPECT_FALSE(lock_handler_->HasCustomIcon());
}
diff --git a/chrome/browser/signin/easy_unlock_service.cc b/chrome/browser/signin/easy_unlock_service.cc
index 3d5a3d5..391c8a8 100644
--- a/chrome/browser/signin/easy_unlock_service.cc
+++ b/chrome/browser/signin/easy_unlock_service.cc
@@ -22,12 +22,13 @@
#include "chrome/browser/signin/easy_unlock_app_manager.h"
#include "chrome/browser/signin/easy_unlock_service_factory.h"
#include "chrome/browser/signin/easy_unlock_service_observer.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/proximity_auth/ble/proximity_auth_ble_system.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "components/proximity_auth/switches.h"
#include "components/user_manager/user.h"
#include "device/bluetooth/bluetooth_adapter.h"
@@ -446,9 +447,7 @@ EasyUnlockScreenlockStateHandler*
return NULL;
if (!screenlock_state_handler_) {
screenlock_state_handler_.reset(new EasyUnlockScreenlockStateHandler(
- GetUserEmail(),
- GetHardlockState(),
- ScreenlockBridge::Get()));
+ GetUserEmail(), GetHardlockState(), GetScreenlockBridgeInstance()));
}
return screenlock_state_handler_.get();
}
diff --git a/chrome/browser/signin/easy_unlock_service_regular.cc b/chrome/browser/signin/easy_unlock_service_regular.cc
index a7f8ea9..38cb609 100644
--- a/chrome/browser/signin/easy_unlock_service_regular.cc
+++ b/chrome/browser/signin/easy_unlock_service_regular.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/api/easy_unlock_private.h"
@@ -24,6 +24,7 @@
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h"
#include "components/proximity_auth/cryptauth/cryptauth_client_impl.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "components/proximity_auth/switches.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
@@ -92,7 +93,12 @@ EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const {
}
std::string EasyUnlockServiceRegular::GetUserEmail() const {
- return ScreenlockBridge::GetAuthenticatedUserEmail(profile());
+ const SigninManagerBase* signin_manager =
+ SigninManagerFactory::GetForProfileIfExists(profile());
+ // |profile| has to be a signed-in profile with SigninManager already
+ // created. Otherwise, just crash to collect stack.
+ DCHECK(signin_manager);
+ return signin_manager->GetAuthenticatedUsername();
}
void EasyUnlockServiceRegular::LaunchSetup() {
@@ -298,7 +304,7 @@ void EasyUnlockServiceRegular::SetAutoPairingResult(
}
void EasyUnlockServiceRegular::InitializeInternal() {
- ScreenlockBridge::Get()->AddObserver(this);
+ GetScreenlockBridgeInstance()->AddObserver(this);
registrar_.Init(profile()->GetPrefs());
registrar_.Add(
prefs::kEasyUnlockAllowed,
@@ -317,7 +323,7 @@ void EasyUnlockServiceRegular::ShutdownInternal() {
turn_off_flow_status_ = EasyUnlockService::IDLE;
registrar_.RemoveAll();
- ScreenlockBridge::Get()->RemoveObserver(this);
+ GetScreenlockBridgeInstance()->RemoveObserver(this);
}
bool EasyUnlockServiceRegular::IsAllowedInternal() const {
@@ -354,16 +360,16 @@ void EasyUnlockServiceRegular::OnSuspendDone() {
}
void EasyUnlockServiceRegular::OnScreenDidLock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) {
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) {
will_unlock_using_easy_unlock_ = false;
lock_screen_last_shown_timestamp_ = base::TimeTicks::Now();
}
void EasyUnlockServiceRegular::OnScreenDidUnlock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) {
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) {
// Notifications of signin screen unlock events can also reach this code path;
// disregard them.
- if (screen_type != ScreenlockBridge::LockHandler::LOCK_SCREEN)
+ if (screen_type != proximity_auth::ScreenlockBridge::LockHandler::LOCK_SCREEN)
return;
// Only record metrics for users who have enabled the feature.
diff --git a/chrome/browser/signin/easy_unlock_service_regular.h b/chrome/browser/signin/easy_unlock_service_regular.h
index 324d234..1f4ff9d 100644
--- a/chrome/browser/signin/easy_unlock_service_regular.h
+++ b/chrome/browser/signin/easy_unlock_service_regular.h
@@ -13,7 +13,7 @@
#include "base/prefs/pref_change_registrar.h"
#include "base/time/time.h"
#include "chrome/browser/signin/easy_unlock_service.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/easy_unlock/short_lived_user_context.h"
@@ -38,8 +38,9 @@ class Profile;
// EasyUnlockService instance that should be used for regular, non-signin
// profiles.
-class EasyUnlockServiceRegular : public EasyUnlockService,
- public ScreenlockBridge::Observer {
+class EasyUnlockServiceRegular
+ : public EasyUnlockService,
+ public proximity_auth::ScreenlockBridge::Observer {
public:
explicit EasyUnlockServiceRegular(Profile* profile);
~EasyUnlockServiceRegular() override;
@@ -70,11 +71,12 @@ class EasyUnlockServiceRegular : public EasyUnlockService,
void OnWillFinalizeUnlock(bool success) override;
void OnSuspendDone() override;
- // ScreenlockBridge::Observer implementation:
- void OnScreenDidLock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) override;
+ // proximity_auth::ScreenlockBridge::Observer implementation:
+ void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
+ screen_type) override;
void OnScreenDidUnlock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) override;
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type)
+ override;
void OnFocusedUserChanged(const std::string& user_id) override;
diff --git a/chrome/browser/signin/easy_unlock_service_signin_chromeos.cc b/chrome/browser/signin/easy_unlock_service_signin_chromeos.cc
index 5c068cd..ad3536f 100644
--- a/chrome/browser/signin/easy_unlock_service_signin_chromeos.cc
+++ b/chrome/browser/signin/easy_unlock_service_signin_chromeos.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/signin/easy_unlock_app_manager.h"
#include "chrome/browser/signin/easy_unlock_metrics.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
#include "chromeos/login/auth/user_context.h"
#include "chromeos/tpm/tpm_token_loader.h"
@@ -222,7 +223,8 @@ void EasyUnlockServiceSignin::InitializeInternal() {
service_active_ = true;
chromeos::LoginState::Get()->AddObserver(this);
- ScreenlockBridge* screenlock_bridge = ScreenlockBridge::Get();
+ proximity_auth::ScreenlockBridge* screenlock_bridge =
+ GetScreenlockBridgeInstance();
screenlock_bridge->AddObserver(this);
if (!screenlock_bridge->focused_user_id().empty())
OnFocusedUserChanged(screenlock_bridge->focused_user_id());
@@ -234,7 +236,7 @@ void EasyUnlockServiceSignin::ShutdownInternal() {
service_active_ = false;
weak_ptr_factory_.InvalidateWeakPtrs();
- ScreenlockBridge::Get()->RemoveObserver(this);
+ GetScreenlockBridgeInstance()->RemoveObserver(this);
chromeos::LoginState::Get()->RemoveObserver(this);
STLDeleteContainerPairSecondPointers(user_data_.begin(), user_data_.end());
user_data_.clear();
@@ -257,10 +259,11 @@ void EasyUnlockServiceSignin::OnSuspendDone() {
}
void EasyUnlockServiceSignin::OnScreenDidLock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) {
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) {
// In production code, the screen type should always be the signin screen; but
// in tests, the screen type might be different.
- if (screen_type != ScreenlockBridge::LockHandler::SIGNIN_SCREEN)
+ if (screen_type !=
+ proximity_auth::ScreenlockBridge::LockHandler::SIGNIN_SCREEN)
return;
// Update initial UI is when the account picker on login screen is ready.
@@ -269,10 +272,11 @@ void EasyUnlockServiceSignin::OnScreenDidLock(
}
void EasyUnlockServiceSignin::OnScreenDidUnlock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) {
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) {
// In production code, the screen type should always be the signin screen; but
// in tests, the screen type might be different.
- if (screen_type != ScreenlockBridge::LockHandler::SIGNIN_SCREEN)
+ if (screen_type !=
+ proximity_auth::ScreenlockBridge::LockHandler::SIGNIN_SCREEN)
return;
DisableAppWithoutResettingScreenlockState();
diff --git a/chrome/browser/signin/easy_unlock_service_signin_chromeos.h b/chrome/browser/signin/easy_unlock_service_signin_chromeos.h
index 94b3cef..634de98 100644
--- a/chrome/browser/signin/easy_unlock_service_signin_chromeos.h
+++ b/chrome/browser/signin/easy_unlock_service_signin_chromeos.h
@@ -15,13 +15,14 @@
#include "base/values.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h"
#include "chrome/browser/signin/easy_unlock_service.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
#include "chromeos/login/login_state.h"
+#include "components/proximity_auth/screenlock_bridge.h"
// EasyUnlockService instance that should be used for signin profile.
-class EasyUnlockServiceSignin : public EasyUnlockService,
- public ScreenlockBridge::Observer,
- public chromeos::LoginState::Observer {
+class EasyUnlockServiceSignin
+ : public EasyUnlockService,
+ public proximity_auth::ScreenlockBridge::Observer,
+ public chromeos::LoginState::Observer {
public:
explicit EasyUnlockServiceSignin(Profile* profile);
~EasyUnlockServiceSignin() override;
@@ -85,11 +86,12 @@ class EasyUnlockServiceSignin : public EasyUnlockService,
void OnWillFinalizeUnlock(bool success) override;
void OnSuspendDone() override;
- // ScreenlockBridge::Observer implementation:
- void OnScreenDidLock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) override;
+ // proximity_auth::ScreenlockBridge::Observer implementation:
+ void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
+ screen_type) override;
void OnScreenDidUnlock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) override;
+ proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type)
+ override;
void OnFocusedUserChanged(const std::string& user_id) override;
// chromeos::LoginState::Observer implementation:
diff --git a/chrome/browser/signin/proximity_auth_facade.cc b/chrome/browser/signin/proximity_auth_facade.cc
new file mode 100644
index 0000000..bef1143
--- /dev/null
+++ b/chrome/browser/signin/proximity_auth_facade.cc
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/signin/proximity_auth_facade.h"
+
+#include "base/lazy_instance.h"
+#include "base/logging.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_window.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "components/proximity_auth/proximity_auth_client.h"
+#include "components/proximity_auth/screenlock_bridge.h"
+#include "components/signin/core/browser/signin_manager_base.h"
+
+namespace {
+
+// A Chrome-specific implementation of the ProximityAuthClient.
+class ChromeProximityAuthClient : public proximity_auth::ProximityAuthClient {
+ public:
+ ChromeProximityAuthClient() {}
+ ~ChromeProximityAuthClient() override {}
+
+ // proximity_auth::ProximityAuthClient implementation:
+ std::string GetAuthenticatedUsername(
+ content::BrowserContext* browser_context) const override;
+ void Lock(content::BrowserContext* browser_context) override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ChromeProximityAuthClient);
+};
+
+std::string ChromeProximityAuthClient::GetAuthenticatedUsername(
+ content::BrowserContext* browser_context) const {
+ Profile* profile = Profile::FromBrowserContext(browser_context);
+ const SigninManagerBase* signin_manager =
+ SigninManagerFactory::GetForProfileIfExists(profile);
+ // |profile| has to be a signed-in profile with SigninManager already
+ // created. Otherwise, just crash to collect stack.
+ DCHECK(signin_manager);
+ return signin_manager->GetAuthenticatedUsername();
+}
+
+void ChromeProximityAuthClient::Lock(content::BrowserContext* browser_context) {
+ profiles::LockProfile(Profile::FromBrowserContext(browser_context));
+}
+
+// A facade class that is the glue required to initialize and manage the
+// lifecycle of various objects of the Proximity Auth component.
+class ProximityAuthFacade {
+ public:
+ proximity_auth::ScreenlockBridge* GetScreenlockBridge() {
+ return &screenlock_bridge_;
+ }
+
+ private:
+ friend struct base::DefaultLazyInstanceTraits<ProximityAuthFacade>;
+ friend struct base::DefaultDeleter<ProximityAuthFacade>;
+
+ ProximityAuthFacade() : screenlock_bridge_(&proximity_auth_client_) {}
+ ~ProximityAuthFacade() {}
+
+ ChromeProximityAuthClient proximity_auth_client_;
+ proximity_auth::ScreenlockBridge screenlock_bridge_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProximityAuthFacade);
+};
+
+base::LazyInstance<ProximityAuthFacade> g_proximity_auth_facade_instance =
+ LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+proximity_auth::ScreenlockBridge* GetScreenlockBridgeInstance() {
+ return g_proximity_auth_facade_instance.Pointer()->GetScreenlockBridge();
+}
diff --git a/chrome/browser/signin/proximity_auth_facade.h b/chrome/browser/signin/proximity_auth_facade.h
new file mode 100644
index 0000000..9a99ed1
--- /dev/null
+++ b/chrome/browser/signin/proximity_auth_facade.h
@@ -0,0 +1,15 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SIGNIN_PROXIMITY_AUTH_FACADE_H_
+#define CHROME_BROWSER_SIGNIN_PROXIMITY_AUTH_FACADE_H_
+
+namespace proximity_auth {
+class ScreenlockBridge;
+}
+
+// Returns the global proximity_auth::ScreenlockBridge instance.
+proximity_auth::ScreenlockBridge* GetScreenlockBridgeInstance();
+
+#endif // CHROME_BROWSER_SIGNIN_PROXIMITY_AUTH_FACADE_H_
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
index a1133cd..c631d08 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -51,6 +51,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/signin/easy_unlock_service.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
@@ -294,8 +295,8 @@ SigninScreenHandler::~SigninScreenHandler() {
max_mode_delegate_->RemoveObserver(this);
max_mode_delegate_.reset(NULL);
}
- ScreenlockBridge::Get()->SetLockHandler(NULL);
- ScreenlockBridge::Get()->SetFocusedUser("");
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetFocusedUser("");
}
// static
@@ -1256,7 +1257,7 @@ void SigninScreenHandler::HandleUpdateOfflineLogin(bool offline_login_active) {
void SigninScreenHandler::HandleFocusPod(const std::string& user_id) {
SetUserInputMethod(user_id, ime_state_.get());
WallpaperManager::Get()->SetUserWallpaperDelayed(user_id);
- ScreenlockBridge::Get()->SetFocusedUser(user_id);
+ GetScreenlockBridgeInstance()->SetFocusedUser(user_id);
if (delegate_)
delegate_->CheckUserStatus(user_id);
if (!test_focus_pod_callback_.is_null())
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
index 95044d2..951600b 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
@@ -20,12 +20,12 @@
#include "chrome/browser/chromeos/login/signin_specifics.h"
#include "chrome/browser/chromeos/login/ui/login_display.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/browser/ui/webui/chromeos/touch_view_controller_delegate.h"
#include "chromeos/network/portal_detector/network_portal_detector.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc b/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
index 2846abd..ed1d6f3 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
@@ -8,9 +8,9 @@
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller_delegate.h"
#include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "components/user_manager/user.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -68,8 +68,8 @@ class SigninPrepareUserListTest
FakeChromeUserManager* fake_user_manager_;
ScopedUserManagerEnabler user_manager_enabler_;
scoped_ptr<TestingProfileManager> profile_manager_;
- std::map<std::string,
- ScreenlockBridge::LockHandler::AuthType> user_auth_type_map;
+ std::map<std::string, proximity_auth::ScreenlockBridge::LockHandler::AuthType>
+ user_auth_type_map;
scoped_ptr<MultiProfileUserController> controller_;
DISALLOW_COPY_AND_ASSIGN(SigninPrepareUserListTest);
diff --git a/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc
index 4a015d7..d533099 100644
--- a/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc
@@ -225,10 +225,8 @@ void SupervisedUserCreationScreenHandler::Show() {
bool is_owner = ((*it)->email() == owner);
base::DictionaryValue* user_dict = new base::DictionaryValue();
UserSelectionScreen::FillUserDictionary(
- *it,
- is_owner,
- false, /* is_signin_to_add */
- ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
+ *it, is_owner, false, /* is_signin_to_add */
+ proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
NULL, /* public_session_recommended_locales */
user_dict);
users_list->Append(user_dict);
diff --git a/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc
index 80f8bb7..18c0ac3 100644
--- a/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc
@@ -87,7 +87,7 @@ void UserBoardScreenHandler::HideUserPodCustomIcon(const std::string& user_id) {
void UserBoardScreenHandler::SetAuthType(
const std::string& user_id,
- ScreenlockBridge::LockHandler::AuthType auth_type,
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
const base::string16& initial_value) {
CallJS("login.AccountPickerScreen.setAuthType", user_id,
static_cast<int>(auth_type), base::StringValue(initial_value));
diff --git a/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h
index 36b1118..1c85437 100644
--- a/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h
+++ b/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h
@@ -47,9 +47,10 @@ class UserBoardScreenHandler : public BaseScreenHandler, public UserBoardView {
void ShowUserPodCustomIcon(const std::string& user_id,
const base::DictionaryValue& icon) override;
void HideUserPodCustomIcon(const std::string& user_id) override;
- void SetAuthType(const std::string& user_id,
- ScreenlockBridge::LockHandler::AuthType auth_type,
- const base::string16& initial_value) override;
+ void SetAuthType(
+ const std::string& user_id,
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
+ const base::string16& initial_value) override;
void Bind(UserBoardModel& model) override;
void Unbind() override;
diff --git a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
index d3f54d5..a8f83a5 100644
--- a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
+++ b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/local_auth.h"
+#include "chrome/browser/signin/proximity_auth_facade.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_dialogs.h"
@@ -297,7 +298,7 @@ UserManagerScreenHandler::UserManagerScreenHandler()
}
UserManagerScreenHandler::~UserManagerScreenHandler() {
- ScreenlockBridge::Get()->SetLockHandler(NULL);
+ GetScreenlockBridgeInstance()->SetLockHandler(NULL);
}
void UserManagerScreenHandler::ShowBannerMessage(
@@ -309,7 +310,8 @@ void UserManagerScreenHandler::ShowBannerMessage(
void UserManagerScreenHandler::ShowUserPodCustomIcon(
const std::string& user_email,
- const ScreenlockBridge::UserPodCustomIconOptions& icon_options) {
+ const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions&
+ icon_options) {
scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue();
if (!icon || icon->empty())
return;
@@ -332,10 +334,10 @@ void UserManagerScreenHandler::EnableInput() {
void UserManagerScreenHandler::SetAuthType(
const std::string& user_email,
- ScreenlockBridge::LockHandler::AuthType auth_type,
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
const base::string16& auth_value) {
if (GetAuthType(user_email) ==
- ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD)
+ proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD)
return;
user_auth_type_map_[user_email] = auth_type;
@@ -346,17 +348,17 @@ void UserManagerScreenHandler::SetAuthType(
base::StringValue(auth_value));
}
-ScreenlockBridge::LockHandler::AuthType UserManagerScreenHandler::GetAuthType(
- const std::string& user_email) const {
+proximity_auth::ScreenlockBridge::LockHandler::AuthType
+UserManagerScreenHandler::GetAuthType(const std::string& user_email) const {
UserAuthTypeMap::const_iterator it = user_auth_type_map_.find(user_email);
if (it == user_auth_type_map_.end())
- return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD;
+ return proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD;
return it->second;
}
-ScreenlockBridge::LockHandler::ScreenType
+proximity_auth::ScreenlockBridge::LockHandler::ScreenType
UserManagerScreenHandler::GetScreenType() const {
- return ScreenlockBridge::LockHandler::LOCK_SCREEN;
+ return proximity_auth::ScreenlockBridge::LockHandler::LOCK_SCREEN;
}
void UserManagerScreenHandler::Unlock(const std::string& user_email) {
@@ -388,7 +390,7 @@ void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) {
desktop_type_ = chrome::GetHostDesktopTypeForNativeView(
web_ui()->GetWebContents()->GetNativeView());
- ScreenlockBridge::Get()->SetLockHandler(this);
+ GetScreenlockBridgeInstance()->SetLockHandler(this);
}
void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) {
@@ -546,9 +548,10 @@ void UserManagerScreenHandler::HandleHardlockUserPod(
const base::ListValue* args) {
std::string email;
CHECK(args->GetString(0, &email));
- SetAuthType(email,
- ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD,
- base::string16());
+ SetAuthType(
+ email,
+ proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD,
+ base::string16());
HideUserPodCustomIcon(email);
}
diff --git a/chrome/browser/ui/webui/signin/user_manager_screen_handler.h b/chrome/browser/ui/webui/signin/user_manager_screen_handler.h
index 2a68f7e..98bf442 100644
--- a/chrome/browser/ui/webui/signin/user_manager_screen_handler.h
+++ b/chrome/browser/ui/webui/signin/user_manager_screen_handler.h
@@ -14,8 +14,8 @@
#include "base/memory/weak_ptr.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_metrics.h"
-#include "chrome/browser/signin/screenlock_bridge.h"
#include "chrome/browser/ui/host_desktop.h"
+#include "components/proximity_auth/screenlock_bridge.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -29,10 +29,11 @@ class FilePath;
class ListValue;
}
-class UserManagerScreenHandler : public content::WebUIMessageHandler,
- public ScreenlockBridge::LockHandler,
- public GaiaAuthConsumer,
- public content::NotificationObserver {
+class UserManagerScreenHandler
+ : public content::WebUIMessageHandler,
+ public proximity_auth::ScreenlockBridge::LockHandler,
+ public GaiaAuthConsumer,
+ public content::NotificationObserver {
public:
UserManagerScreenHandler();
~UserManagerScreenHandler() override;
@@ -47,16 +48,18 @@ class UserManagerScreenHandler : public content::WebUIMessageHandler,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
- // ScreenlockBridge::LockHandler implementation.
+ // proximity_auth::ScreenlockBridge::LockHandler implementation.
void ShowBannerMessage(const base::string16& message) override;
void ShowUserPodCustomIcon(
const std::string& user_email,
- const ScreenlockBridge::UserPodCustomIconOptions& icon_options) override;
+ const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions&
+ icon_options) override;
void HideUserPodCustomIcon(const std::string& user_email) override;
void EnableInput() override;
- void SetAuthType(const std::string& user_email,
- ScreenlockBridge::LockHandler::AuthType auth_type,
- const base::string16& auth_value) override;
+ void SetAuthType(
+ const std::string& user_email,
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
+ const base::string16& auth_value) override;
AuthType GetAuthType(const std::string& user_email) const override;
ScreenType GetScreenType() const override;
void Unlock(const std::string& user_email) override;
@@ -115,7 +118,8 @@ class UserManagerScreenHandler : public content::WebUIMessageHandler,
// URL hash, used to key post-profile actions if present.
std::string url_hash_;
- typedef std::map<std::string, ScreenlockBridge::LockHandler::AuthType>
+ typedef std::map<std::string,
+ proximity_auth::ScreenlockBridge::LockHandler::AuthType>
UserAuthTypeMap;
UserAuthTypeMap user_auth_type_map_;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 6d89d15..4a4355c 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1422,6 +1422,8 @@
'browser/signin/easy_unlock_service_regular.h',
'browser/signin/easy_unlock_service_signin_chromeos.cc',
'browser/signin/easy_unlock_service_signin_chromeos.h',
+ 'browser/signin/proximity_auth_facade.cc',
+ 'browser/signin/proximity_auth_facade.h',
'browser/speech/extension_api/tts_engine_extension_api.cc',
'browser/speech/extension_api/tts_engine_extension_api.h',
'browser/speech/extension_api/tts_engine_extension_observer.cc',
@@ -2596,8 +2598,6 @@
'browser/signin/profile_identity_provider.h',
'browser/signin/profile_oauth2_token_service_factory.cc',
'browser/signin/profile_oauth2_token_service_factory.h',
- 'browser/signin/screenlock_bridge.cc',
- 'browser/signin/screenlock_bridge.h',
'browser/signin/signin_cookie_changed_subscription.cc',
'browser/signin/signin_cookie_changed_subscription.h',
'browser/signin/signin_error_controller_factory.cc',
diff --git a/components/proximity_auth.gypi b/components/proximity_auth.gypi
index c5fcc84..e10cc9c 100644
--- a/components/proximity_auth.gypi
+++ b/components/proximity_auth.gypi
@@ -37,11 +37,14 @@
"proximity_auth/connection.h",
"proximity_auth/connection_finder.h",
"proximity_auth/connection_observer.h",
+ "proximity_auth/proximity_auth_client.h",
"proximity_auth/proximity_auth_system.cc",
"proximity_auth/proximity_auth_system.h",
"proximity_auth/remote_device.h",
"proximity_auth/remote_status_update.cc",
"proximity_auth/remote_status_update.h",
+ "proximity_auth/screenlock_bridge.cc",
+ "proximity_auth/screenlock_bridge.h",
"proximity_auth/secure_context.h",
"proximity_auth/switches.cc",
"proximity_auth/switches.h",
diff --git a/components/proximity_auth/BUILD.gn b/components/proximity_auth/BUILD.gn
index 7d31f67..e2faf96 100644
--- a/components/proximity_auth/BUILD.gn
+++ b/components/proximity_auth/BUILD.gn
@@ -23,11 +23,14 @@ source_set("proximity_auth") {
"connection.h",
"connection_finder.h",
"connection_observer.h",
+ "proximity_auth_client.h",
"proximity_auth_system.cc",
"proximity_auth_system.h",
"remote_device.h",
"remote_status_update.cc",
"remote_status_update.h",
+ "screenlock_bridge.cc",
+ "screenlock_bridge.h",
"secure_context.h",
"switches.cc",
"switches.h",
diff --git a/components/proximity_auth/DEPS b/components/proximity_auth/DEPS
index 6d746ad..161da31 100644
--- a/components/proximity_auth/DEPS
+++ b/components/proximity_auth/DEPS
@@ -2,3 +2,9 @@ include_rules = [
"+device/bluetooth",
"+net",
]
+
+specific_include_rules = {
+ "screenlock_bridge\.*": [
+ "+chromeos",
+ ],
+}
diff --git a/components/proximity_auth/proximity_auth_client.h b/components/proximity_auth/proximity_auth_client.h
new file mode 100644
index 0000000..b9ad752
--- /dev/null
+++ b/components/proximity_auth/proximity_auth_client.h
@@ -0,0 +1,39 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_PROXIMITY_AUTH_CLIENT_H_
+#define COMPONENTS_PROXIMITY_AUTH_CLIENT_H_
+
+#include <string>
+
+#include "base/macros.h"
+
+namespace content {
+class BrowserContext;
+} // namespace content
+
+namespace proximity_auth {
+
+// An interface that needs to be supplied to the Proximity Auth component by its
+// embedder.
+class ProximityAuthClient {
+ public:
+ // Returns the authenticated username for |browser_context|.
+ virtual std::string GetAuthenticatedUsername(
+ content::BrowserContext* browser_context) const = 0;
+
+ // Locks the screen for |browser_context|.
+ virtual void Lock(content::BrowserContext* browser_context) = 0;
+
+ protected:
+ ProximityAuthClient() {}
+ virtual ~ProximityAuthClient() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ProximityAuthClient);
+};
+
+} // namespace proximity_auth
+
+#endif // COMPONENTS_PROXIMITY_AUTH_CLIENT_H_
diff --git a/chrome/browser/signin/screenlock_bridge.cc b/components/proximity_auth/screenlock_bridge.cc
index c8db7a3..2af8378 100644
--- a/chrome/browser/signin/screenlock_bridge.cc
+++ b/components/proximity_auth/screenlock_bridge.cc
@@ -2,24 +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 proximity_auth {
namespace {
-base::LazyInstance<ScreenlockBridge> g_screenlock_bridge_bridge_instance =
- LAZY_INSTANCE_INITIALIZER;
-
// Ids for the icons that are supported by lock screen and signin screen
// account picker as user pod custom icons.
// The id's should be kept in sync with values used by user_pod_row.js.
@@ -53,9 +49,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 +63,8 @@ ScreenlockBridge::UserPodCustomIconOptions::UserPodCustomIconOptions()
is_trial_run_(false) {
}
-ScreenlockBridge::UserPodCustomIconOptions::~UserPodCustomIconOptions() {}
+ScreenlockBridge::UserPodCustomIconOptions::~UserPodCustomIconOptions() {
+}
scoped_ptr<base::DictionaryValue>
ScreenlockBridge::UserPodCustomIconOptions::ToDictionaryValue() const {
@@ -116,24 +116,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 +147,22 @@ 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) {
+void ScreenlockBridge::Unlock(content::BrowserContext* browser_context) {
if (lock_handler_)
- lock_handler_->Unlock(GetAuthenticatedUserEmail(profile));
+ lock_handler_->Unlock(client_->GetAuthenticatedUsername(browser_context));
}
void ScreenlockBridge::AddObserver(Observer* observer) {
@@ -188,3 +172,5 @@ void ScreenlockBridge::AddObserver(Observer* observer) {
void ScreenlockBridge::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
+
+} // namespace proximity_auth
diff --git a/chrome/browser/signin/screenlock_bridge.h b/components/proximity_auth/screenlock_bridge.h
index d376f68..8386370 100644
--- a/chrome/browser/signin/screenlock_bridge.h
+++ b/components/proximity_auth/screenlock_bridge.h
@@ -2,21 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_
-#define CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_
+#ifndef COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_
+#define COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_
#include <string>
#include "base/basictypes.h"
-#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
#include "base/values.h"
+namespace content {
+class BrowserContext;
+} // namespace content
-class Profile;
+namespace proximity_auth {
+
+class ProximityAuthClient;
// ScreenlockBridge brings together the screenLockPrivate API and underlying
// support. On ChromeOS, it delegates calls to the ScreenLocker. On other
@@ -25,6 +29,10 @@ class Profile;
// used solely for the lock screen anymore.
class ScreenlockBridge {
public:
+ // |client| is not owned and must outlive this object.
+ explicit ScreenlockBridge(ProximityAuthClient* client);
+ ~ScreenlockBridge();
+
// User pod icons supported by lock screen / signin screen UI.
enum UserPodCustomIcon {
USER_POD_CUSTOM_ICON_NONE,
@@ -99,11 +107,7 @@ class ScreenlockBridge {
FORCE_OFFLINE_PASSWORD = 5
};
- enum ScreenType {
- SIGNIN_SCREEN = 0,
- LOCK_SCREEN = 1,
- OTHER_SCREEN = 2
- };
+ enum ScreenType { SIGNIN_SCREEN = 0, LOCK_SCREEN = 1, OTHER_SCREEN = 2 };
// Displays |message| in a banner on the lock screen.
virtual void ShowBannerMessage(const base::string16& message) = 0;
@@ -130,7 +134,7 @@ class ScreenlockBridge {
// Returns the type of the screen -- a signin or a lock screen.
virtual ScreenType GetScreenType() const = 0;
- // Unlock from easy unlock app for a user.
+ // Unlocks from easy unlock app for a user.
virtual void Unlock(const std::string& user_email) = 0;
// Attempts to login the user using an easy unlock key.
@@ -157,15 +161,12 @@ class ScreenlockBridge {
virtual ~Observer() {}
};
- static ScreenlockBridge* Get();
- static std::string GetAuthenticatedUserEmail(const Profile* profile);
-
void SetLockHandler(LockHandler* lock_handler);
void SetFocusedUser(const std::string& user_id);
bool IsLocked() const;
- void Lock(Profile* profile);
- void Unlock(Profile* profile);
+ void Lock(content::BrowserContext* browser_context);
+ void Unlock(content::BrowserContext* browser_context);
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
@@ -175,13 +176,8 @@ class ScreenlockBridge {
std::string focused_user_id() const { return focused_user_id_; }
private:
- friend struct base::DefaultLazyInstanceTraits<ScreenlockBridge>;
- friend struct base::DefaultDeleter<ScreenlockBridge>;
-
- ScreenlockBridge();
- ~ScreenlockBridge();
-
- LockHandler* lock_handler_; // Not owned
+ ProximityAuthClient* client_; // Not owned. Must outlive this object.
+ LockHandler* lock_handler_; // Not owned
// The last focused user's id.
std::string focused_user_id_;
ObserverList<Observer, true> observers_;
@@ -189,4 +185,6 @@ class ScreenlockBridge {
DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge);
};
-#endif // CHROME_BROWSER_SIGNIN_SCREENLOCK_BRIDGE_H_
+} // namespace proximity_auth
+
+#endif // COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_