summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisherman <isherman@chromium.org>2015-06-30 23:04:37 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-01 06:05:13 +0000
commit3ead4bc4ebb743b3771afb47dbfbd4eb2131ef1b (patch)
tree9a89715e485cf016af038b1d4e45bdd9edc0e70d
parent082bb470775656368f5bec9dd7a1ba4583e2bcb9 (diff)
downloadchromium_src-3ead4bc4ebb743b3771afb47dbfbd4eb2131ef1b.zip
chromium_src-3ead4bc4ebb743b3771afb47dbfbd4eb2131ef1b.tar.gz
chromium_src-3ead4bc4ebb743b3771afb47dbfbd4eb2131ef1b.tar.bz2
[Proximity Auth] Create one ProximityAuthClient per profile, rather than one global one.
BUG=501626 TEST=none R=tengs@chromium.org,mlerman@chromium.org Review URL: https://codereview.chromium.org/1209193003 Cr-Commit-Position: refs/heads/master@{#336983}
-rw-r--r--chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc11
-rw-r--r--chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc5
-rw-r--r--chrome/browser/signin/OWNERS5
-rw-r--r--chrome/browser/signin/chrome_proximity_auth_client.cc26
-rw-r--r--chrome/browser/signin/chrome_proximity_auth_client.h29
-rw-r--r--chrome/browser/signin/easy_unlock_service.cc3
-rw-r--r--chrome/browser/signin/easy_unlock_service.h9
-rw-r--r--chrome/browser/signin/proximity_auth_facade.cc39
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--components/proximity_auth/ble/proximity_auth_ble_system.cc19
-rw-r--r--components/proximity_auth/ble/proximity_auth_ble_system.h17
-rw-r--r--components/proximity_auth/ble/proximity_auth_ble_system_unittest.cc4
-rw-r--r--components/proximity_auth/proximity_auth_client.h22
-rw-r--r--components/proximity_auth/screenlock_bridge.cc13
-rw-r--r--components/proximity_auth/screenlock_bridge.h16
15 files changed, 117 insertions, 103 deletions
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 b55a9cb7..cc20018 100644
--- a/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc
+++ b/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.cc
@@ -7,6 +7,7 @@
#include "base/lazy_instance.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/chrome_proximity_auth_client.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"
@@ -65,6 +66,7 @@ bool ScreenlockPrivateSetLockedFunction::RunAsync() {
scoped_ptr<screenlock::SetLocked::Params> params(
screenlock::SetLocked::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
+ EasyUnlockService* service = EasyUnlockService::Get(GetProfile());
if (params->locked) {
if (extension()->id() == extension_misc::kEasyUnlockAppId &&
AppWindowRegistry::Get(browser_context())
@@ -73,13 +75,12 @@ bool ScreenlockPrivateSetLockedFunction::RunAsync() {
// Mark the Easy Unlock behaviour on the lock screen as the one initiated
// by the Easy Unlock setup app as a trial one.
// TODO(tbarzic): Move this logic to a new easyUnlockPrivate function.
- EasyUnlockService* service = EasyUnlockService::Get(GetProfile());
- if (service)
- service->SetTrialRun();
+ service->SetTrialRun();
}
- GetScreenlockBridgeInstance()->Lock(GetProfile());
+ GetScreenlockBridgeInstance()->Lock();
} else {
- GetScreenlockBridgeInstance()->Unlock(GetProfile());
+ GetScreenlockBridgeInstance()->Unlock(
+ service->proximity_auth_client()->GetAuthenticatedUsername());
}
SendResponse(error_.empty());
return true;
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 d1fcba8..42ce4fd 100644
--- a/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
+++ b/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
@@ -95,6 +95,9 @@ class ScreenlockPrivateApiTest : public ExtensionApiTest,
DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateApiTest);
};
+// Locking is currently implemented only on ChromeOS.
+#if defined(OS_CHROMEOS)
+
// Time out under MSan. http://crbug.com/478091
// Flaky under LSan on ChromeOS. http://crbug.com/482002
#if defined(MEMORY_SANITIZER) || defined(LEAK_SANITIZER) && defined(OS_CHROMEOS)
@@ -113,4 +116,6 @@ IN_PROC_BROWSER_TEST_F(ScreenlockPrivateApiTest, MAYBE_AuthType) {
RunTest("screenlock_private/auth_type");
}
+#endif // defined(OS_CHROMEOS)
+
} // namespace extensions
diff --git a/chrome/browser/signin/OWNERS b/chrome/browser/signin/OWNERS
index f1ab9cd..e7ab150 100644
--- a/chrome/browser/signin/OWNERS
+++ b/chrome/browser/signin/OWNERS
@@ -2,6 +2,11 @@ atwilson@chromium.org
mlerman@chromium.org
rogerta@chromium.org
+per-file chrome_proximity_auth_*=isherman@chromium.org
+per-file chrome_proximity_auth_*=tbarzic@chromium.org
+per-file chrome_proximity_auth_*=tengs@chromium.org
+per-file chrome_proximity_auth_*=xiyuan@chromium.org
+
per-file easy_unlock_*=isherman@chromium.org
per-file easy_unlock_*=tbarzic@chromium.org
per-file easy_unlock_*=tengs@chromium.org
diff --git a/chrome/browser/signin/chrome_proximity_auth_client.cc b/chrome/browser/signin/chrome_proximity_auth_client.cc
new file mode 100644
index 0000000..4877b4c
--- /dev/null
+++ b/chrome/browser/signin/chrome_proximity_auth_client.cc
@@ -0,0 +1,26 @@
+// 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 "base/logging.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_window.h"
+#include "chrome/browser/signin/chrome_proximity_auth_client.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "components/signin/core/browser/signin_manager_base.h"
+
+ChromeProximityAuthClient::ChromeProximityAuthClient(Profile* profile)
+ : profile_(profile) {
+}
+
+ChromeProximityAuthClient::~ChromeProximityAuthClient() {
+}
+
+std::string ChromeProximityAuthClient::GetAuthenticatedUsername() const {
+ 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();
+}
diff --git a/chrome/browser/signin/chrome_proximity_auth_client.h b/chrome/browser/signin/chrome_proximity_auth_client.h
new file mode 100644
index 0000000..7274820
--- /dev/null
+++ b/chrome/browser/signin/chrome_proximity_auth_client.h
@@ -0,0 +1,29 @@
+// 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_CHROME_PROXIMITY_AUTH_CLIENT_H_
+#define CHROME_BROWSER_SIGNIN_CHROME_PROXIMITY_AUTH_CLIENT_H_
+
+#include "base/macros.h"
+#include "components/proximity_auth/proximity_auth_client.h"
+
+class Profile;
+
+// A Chrome-specific implementation of the ProximityAuthClient interface.
+// There is one |ChromeProximityAuthClient| per |Profile|.
+class ChromeProximityAuthClient : public proximity_auth::ProximityAuthClient {
+ public:
+ explicit ChromeProximityAuthClient(Profile* profile);
+ ~ChromeProximityAuthClient() override;
+
+ // proximity_auth::ProximityAuthClient:
+ std::string GetAuthenticatedUsername() const override;
+
+ private:
+ Profile* const profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeProximityAuthClient);
+};
+
+#endif // CHROME_BROWSER_SIGNIN_CHROME_PROXIMITY_AUTH_CLIENT_H_
diff --git a/chrome/browser/signin/easy_unlock_service.cc b/chrome/browser/signin/easy_unlock_service.cc
index 37a3ed0..43e652b 100644
--- a/chrome/browser/signin/easy_unlock_service.cc
+++ b/chrome/browser/signin/easy_unlock_service.cc
@@ -260,6 +260,7 @@ class EasyUnlockService::PowerMonitor
EasyUnlockService::EasyUnlockService(Profile* profile)
: profile_(profile),
+ proximity_auth_client_(profile),
bluetooth_detector_(new BluetoothDetector(this)),
shut_down_(false),
tpm_key_checked_(false),
@@ -694,7 +695,7 @@ void EasyUnlockService::UpdateAppState() {
!proximity_auth_ble_system_) {
proximity_auth_ble_system_.reset(
new proximity_auth::ProximityAuthBleSystem(
- GetScreenlockBridgeInstance(), profile_,
+ GetScreenlockBridgeInstance(), &proximity_auth_client_,
CreateCryptAuthClientFactory()));
}
diff --git a/chrome/browser/signin/easy_unlock_service.h b/chrome/browser/signin/easy_unlock_service.h
index 0b577c7..ddf64c8 100644
--- a/chrome/browser/signin/easy_unlock_service.h
+++ b/chrome/browser/signin/easy_unlock_service.h
@@ -13,6 +13,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
+#include "chrome/browser/signin/chrome_proximity_auth_client.h"
#include "chrome/browser/signin/easy_unlock_auth_attempt.h"
#include "chrome/browser/signin/easy_unlock_metrics.h"
#include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h"
@@ -225,6 +226,10 @@ class EasyUnlockService : public KeyedService,
CreateCryptAuthClientFactory() override;
cryptauth::DeviceClassifier GetDeviceClassifier() override;
+ ChromeProximityAuthClient* proximity_auth_client() {
+ return &proximity_auth_client_;
+ }
+
protected:
explicit EasyUnlockService(Profile* profile);
~EasyUnlockService() override;
@@ -328,7 +333,9 @@ class EasyUnlockService : public KeyedService,
void EnsureTpmKeyPresentIfNeeded();
- Profile* profile_;
+ Profile* const profile_;
+
+ ChromeProximityAuthClient proximity_auth_client_;
scoped_ptr<EasyUnlockAppManager> app_manager_;
diff --git a/chrome/browser/signin/proximity_auth_facade.cc b/chrome/browser/signin/proximity_auth_facade.cc
index bef1143..71de2e8 100644
--- a/chrome/browser/signin/proximity_auth_facade.cc
+++ b/chrome/browser/signin/proximity_auth_facade.cc
@@ -5,46 +5,10 @@
#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 {
@@ -57,10 +21,9 @@ class ProximityAuthFacade {
friend struct base::DefaultLazyInstanceTraits<ProximityAuthFacade>;
friend struct base::DefaultDeleter<ProximityAuthFacade>;
- ProximityAuthFacade() : screenlock_bridge_(&proximity_auth_client_) {}
+ ProximityAuthFacade() {}
~ProximityAuthFacade() {}
- ChromeProximityAuthClient proximity_auth_client_;
proximity_auth::ScreenlockBridge screenlock_bridge_;
DISALLOW_COPY_AND_ASSIGN(ProximityAuthFacade);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index a11938e..0d6640a 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1480,6 +1480,8 @@
'browser/search/hotword_service.h',
'browser/search/hotword_service_factory.cc',
'browser/search/hotword_service_factory.h',
+ 'browser/signin/chrome_proximity_auth_client.cc',
+ 'browser/signin/chrome_proximity_auth_client.h',
'browser/signin/easy_unlock_app_manager.cc',
'browser/signin/easy_unlock_app_manager.h',
'browser/signin/easy_unlock_auth_attempt.cc',
diff --git a/components/proximity_auth/ble/proximity_auth_ble_system.cc b/components/proximity_auth/ble/proximity_auth_ble_system.cc
index cfd2074..1a399b4 100644
--- a/components/proximity_auth/ble/proximity_auth_ble_system.cc
+++ b/components/proximity_auth/ble/proximity_auth_ble_system.cc
@@ -16,6 +16,7 @@
#include "components/proximity_auth/cryptauth/cryptauth_client.h"
#include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h"
#include "components/proximity_auth/logging/logging.h"
+#include "components/proximity_auth/proximity_auth_client.h"
#include "components/proximity_auth/remote_device.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_gatt_connection.h"
@@ -70,17 +71,17 @@ void ProximityAuthBleSystem::ScreenlockBridgeAdapter::RemoveObserver(
}
void ProximityAuthBleSystem::ScreenlockBridgeAdapter::Unlock(
- content::BrowserContext* browser_context) {
- screenlock_bridge_->Unlock(browser_context);
+ ProximityAuthClient* client) {
+ screenlock_bridge_->Unlock(client->GetAuthenticatedUsername());
}
ProximityAuthBleSystem::ProximityAuthBleSystem(
ScreenlockBridge* screenlock_bridge,
- content::BrowserContext* browser_context,
+ ProximityAuthClient* proximity_auth_client,
scoped_ptr<CryptAuthClientFactory> cryptauth_client_factory)
: screenlock_bridge_(new ProximityAuthBleSystem::ScreenlockBridgeAdapter(
screenlock_bridge)),
- browser_context_(browser_context),
+ proximity_auth_client_(proximity_auth_client),
cryptauth_client_factory_(cryptauth_client_factory.Pass()),
is_polling_screen_state_(false),
weak_ptr_factory_(this) {
@@ -89,10 +90,10 @@ ProximityAuthBleSystem::ProximityAuthBleSystem(
}
ProximityAuthBleSystem::ProximityAuthBleSystem(
- ScreenlockBridgeAdapter* screenlock_bridge,
- content::BrowserContext* browser_context)
- : screenlock_bridge_(screenlock_bridge),
- browser_context_(browser_context),
+ scoped_ptr<ScreenlockBridgeAdapter> screenlock_bridge,
+ ProximityAuthClient* proximity_auth_client)
+ : screenlock_bridge_(screenlock_bridge.Pass()),
+ proximity_auth_client_(proximity_auth_client),
is_polling_screen_state_(false),
weak_ptr_factory_(this) {
PA_LOG(INFO) << "Starting Proximity Auth over Bluetooth Low Energy.";
@@ -210,7 +211,7 @@ void ProximityAuthBleSystem::OnMessageReceived(const Connection& connection,
// the Proximity Auth Unlock Manager migration to C++ is done.
if (message.payload() == kScreenUnlocked) {
PA_LOG(INFO) << "Device unlocked. Unlock.";
- screenlock_bridge_->Unlock(browser_context_);
+ screenlock_bridge_->Unlock(proximity_auth_client_);
}
}
diff --git a/components/proximity_auth/ble/proximity_auth_ble_system.h b/components/proximity_auth/ble/proximity_auth_ble_system.h
index 1444592..50f8704 100644
--- a/components/proximity_auth/ble/proximity_auth_ble_system.h
+++ b/components/proximity_auth/ble/proximity_auth_ble_system.h
@@ -15,10 +15,6 @@
#include "components/proximity_auth/cryptauth/cryptauth_client.h"
#include "components/proximity_auth/screenlock_bridge.h"
-namespace content {
-class BrowserContext;
-}
-
namespace device {
class BluetoothGattConnection;
}
@@ -29,6 +25,7 @@ class BluetoothLowEnergyConnection;
class BluetoothLowEnergyConnectionFinder;
class Connection;
class ConnectionFinder;
+class ProximityAuthClient;
// This is the main entry point to start Proximity Auth over Bluetooth Low
// Energy. This is the underlying system for the Smart Lock features. It will
@@ -39,7 +36,7 @@ class ProximityAuthBleSystem : public ScreenlockBridge::Observer,
public:
ProximityAuthBleSystem(
ScreenlockBridge* screenlock_bridge,
- content::BrowserContext* browser_context,
+ ProximityAuthClient* proximity_auth_client,
scoped_ptr<CryptAuthClientFactory> cryptauth_client_factory);
~ProximityAuthBleSystem() override;
@@ -65,7 +62,7 @@ class ProximityAuthBleSystem : public ScreenlockBridge::Observer,
virtual void AddObserver(ScreenlockBridge::Observer* observer);
virtual void RemoveObserver(ScreenlockBridge::Observer* observer);
- virtual void Unlock(content::BrowserContext* browser_context);
+ virtual void Unlock(ProximityAuthClient* client);
protected:
ScreenlockBridgeAdapter();
@@ -76,8 +73,8 @@ class ProximityAuthBleSystem : public ScreenlockBridge::Observer,
};
// Used for testing.
- ProximityAuthBleSystem(ScreenlockBridgeAdapter* screenlock_bridge,
- content::BrowserContext* browser_context);
+ ProximityAuthBleSystem(scoped_ptr<ScreenlockBridgeAdapter> screenlock_bridge,
+ ProximityAuthClient* proximity_auth_client);
// Virtual for testing.
virtual ConnectionFinder* CreateConnectionFinder();
@@ -102,8 +99,8 @@ class ProximityAuthBleSystem : public ScreenlockBridge::Observer,
scoped_ptr<ScreenlockBridgeAdapter> screenlock_bridge_;
- content::BrowserContext*
- browser_context_; // Not owned. Must outlive this object.
+ // Not owned. Must outlive this object.
+ ProximityAuthClient* proximity_auth_client_;
// Creates CryptAuth client instances to make API calls.
scoped_ptr<CryptAuthClientFactory> cryptauth_client_factory_;
diff --git a/components/proximity_auth/ble/proximity_auth_ble_system_unittest.cc b/components/proximity_auth/ble/proximity_auth_ble_system_unittest.cc
index 61a5638..b223e4a 100644
--- a/components/proximity_auth/ble/proximity_auth_ble_system_unittest.cc
+++ b/components/proximity_auth/ble/proximity_auth_ble_system_unittest.cc
@@ -38,11 +38,11 @@ class ProximityAuthBleSystemTestable : public ProximityAuthBleSystem {
MOCK_METHOD1(AddObserver, void(ScreenlockBridge::Observer*));
MOCK_METHOD1(RemoveObserver, void(ScreenlockBridge::Observer*));
- MOCK_METHOD1(Unlock, void(content::BrowserContext*));
+ MOCK_METHOD1(Unlock, void(ProximityAuthClient*));
};
ProximityAuthBleSystemTestable(ScreenlockBridgeAdapter* screenlock_bridge)
- : ProximityAuthBleSystem(screenlock_bridge, nullptr) {}
+ : ProximityAuthBleSystem(make_scoped_ptr(screenlock_bridge), nullptr) {}
ConnectionFinder* CreateConnectionFinder() override {
return new NiceMock<MockConnectionFinder>();
diff --git a/components/proximity_auth/proximity_auth_client.h b/components/proximity_auth/proximity_auth_client.h
index b9ad752..7a26778 100644
--- a/components/proximity_auth/proximity_auth_client.h
+++ b/components/proximity_auth/proximity_auth_client.h
@@ -7,31 +7,17 @@
#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.
+// embedder. There should be one |ProximityAuthClient| per
+// |content::BrowserContext|.
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);
+ // Returns the authenticated username.
+ virtual std::string GetAuthenticatedUsername() const = 0;
};
} // namespace proximity_auth
diff --git a/components/proximity_auth/screenlock_bridge.cc b/components/proximity_auth/screenlock_bridge.cc
index 2af8378..c3dd25f5 100644
--- a/components/proximity_auth/screenlock_bridge.cc
+++ b/components/proximity_auth/screenlock_bridge.cc
@@ -6,7 +6,6 @@
#include "base/logging.h"
#include "base/strings/string16.h"
-#include "components/proximity_auth/proximity_auth_client.h"
#if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -49,9 +48,7 @@ std::string GetIdForIcon(ScreenlockBridge::UserPodCustomIcon icon) {
} // namespace
-ScreenlockBridge::ScreenlockBridge(ProximityAuthClient* client)
- : client_(client), lock_handler_(nullptr) {
- DCHECK(client_);
+ScreenlockBridge::ScreenlockBridge() : lock_handler_(nullptr) {
}
ScreenlockBridge::~ScreenlockBridge() {
@@ -150,19 +147,19 @@ bool ScreenlockBridge::IsLocked() const {
return lock_handler_ != nullptr;
}
-void ScreenlockBridge::Lock(content::BrowserContext* browser_context) {
+void ScreenlockBridge::Lock() {
#if defined(OS_CHROMEOS)
chromeos::SessionManagerClient* session_manager =
chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
session_manager->RequestLockScreen();
#else
- client_->Lock(browser_context);
+ NOTIMPLEMENTED();
#endif
}
-void ScreenlockBridge::Unlock(content::BrowserContext* browser_context) {
+void ScreenlockBridge::Unlock(const std::string& user_email) {
if (lock_handler_)
- lock_handler_->Unlock(client_->GetAuthenticatedUsername(browser_context));
+ lock_handler_->Unlock(user_email);
}
void ScreenlockBridge::AddObserver(Observer* observer) {
diff --git a/components/proximity_auth/screenlock_bridge.h b/components/proximity_auth/screenlock_bridge.h
index f9a47a4..92cc94f 100644
--- a/components/proximity_auth/screenlock_bridge.h
+++ b/components/proximity_auth/screenlock_bridge.h
@@ -14,14 +14,8 @@
#include "base/strings/string16.h"
#include "base/values.h"
-namespace content {
-class BrowserContext;
-} // namespace content
-
namespace proximity_auth {
-class ProximityAuthClient;
-
// ScreenlockBridge brings together the screenLockPrivate API and underlying
// support. On ChromeOS, it delegates calls to the ScreenLocker. On other
// platforms, it delegates calls to UserManagerUI (and friends).
@@ -29,8 +23,7 @@ class ProximityAuthClient;
// used solely for the lock screen anymore.
class ScreenlockBridge {
public:
- // |client| is not owned and must outlive this object.
- explicit ScreenlockBridge(ProximityAuthClient* client);
+ ScreenlockBridge();
~ScreenlockBridge();
// User pod icons supported by lock screen / signin screen UI.
@@ -165,8 +158,10 @@ class ScreenlockBridge {
void SetFocusedUser(const std::string& user_id);
bool IsLocked() const;
- void Lock(content::BrowserContext* browser_context);
- void Unlock(content::BrowserContext* browser_context);
+ void Lock();
+
+ // Unlocks the screen for the authenticated user with the given |user_email|.
+ void Unlock(const std::string& user_email);
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
@@ -176,7 +171,6 @@ class ScreenlockBridge {
std::string focused_user_id() const { return focused_user_id_; }
private:
- ProximityAuthClient* client_; // Not owned. Must outlive this object.
LockHandler* lock_handler_; // Not owned
// The last focused user's id.
std::string focused_user_id_;