Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: chrome/browser/signin/easy_unlock_util.cc

Issue 1096293003: Move screenlock_bridge to components/proximity_auth (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add proximity auth client and the chrome glue. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/signin/easy_unlock_util.h"
6
7 #include "base/lazy_instance.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h"
Ilya Sherman 2015/04/23 20:52:53 nit: Not needed?
msarda 2015/04/24 15:47:05 Done.
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_window.h"
13 #include "chrome/browser/signin/signin_manager_factory.h"
14 #include "components/proximity_auth/proximity_auth_client.h"
15 #include "components/proximity_auth/screenlock_bridge.h"
16 #include "components/signin/core/browser/signin_manager_base.h"
17
18 namespace {
19
20 // A Chrome specific implementation of the ProximityAuthClient.
Ilya Sherman 2015/04/23 20:52:53 nit: "Chrome specific" -> "Chrome-specific"
msarda 2015/04/24 15:47:05 Done.
21 class ChromeProximityAuthClient : public ProximityAuthClient {
22 public:
23 ChromeProximityAuthClient();
24 virtual ~ChromeProximityAuthClient();
Ilya Sherman 2015/04/23 20:52:53 nit: Please leave a blank line after this one.
sdefresne 2015/04/24 14:22:02 ~ChromeProximityAuthClient() override;
25 std::string GetAuthenticatedUsername(
Ilya Sherman 2015/04/23 20:52:53 nit: Above this line, please add "// ProximityAuth
msarda 2015/04/24 15:47:05 Done.
26 content::BrowserContext* browser_context) override;
27 void Lock(content::BrowserContext* browser_context) override;
28
29 private:
30 DISALLOW_COPY_AND_ASSIGN(ChromeProximityAuthClient);
31 };
32
33 ChromeProximityAuthClient::ChromeProximityAuthClient() {
34 }
35
36 ChromeProximityAuthClient::~ChromeProximityAuthClient() {
37 }
Ilya Sherman 2015/04/23 20:52:53 Optional: Eventually, we'll probably a more involv
msarda 2015/04/24 15:47:06 I prefer to do that later as I would argue we coul
38
39 std::string ChromeProximityAuthClient::GetAuthenticatedUsername(
40 content::BrowserContext* browser_context) {
41 Profile* profile = Profile::FromBrowserContext(browser_context);
42 const SigninManagerBase* signin_manager =
43 SigninManagerFactory::GetForProfileIfExists(profile);
44 // |profile| has to be a signed-in profile with SigninManager already
45 // created. Otherwise, just crash to collect stack.
46 CHECK(signin_manager);
Ilya Sherman 2015/04/23 20:52:53 nit: No need for the explicit CHECK -- a null poin
sdefresne 2015/04/24 14:22:02 It will only crash reliably if the called method i
msarda 2015/04/24 15:47:06 +1 for what Sylvain said (this was also the reason
47 return signin_manager->GetAuthenticatedUsername();
48 }
49
50 void ChromeProximityAuthClient::Lock(content::BrowserContext* browser_context) {
51 profiles::LockProfile(Profile::FromBrowserContext(browser_context));
52 }
53
54 // A utilitary class that serves as the glue code required to initialize and
Ilya Sherman 2015/04/23 20:52:53 nit: s/utilitary/utility
msarda 2015/04/24 15:47:05 Done.
msarda 2015/04/24 15:47:05 Done.
55 // manage the lifecycle of various objects of the Proximity Auth components.
56 class EasyUnlockUtil {
57 public:
58 ScreenlockBridge* GetScreenlockBridge();
59
60 private:
61 EasyUnlockUtil();
62 ~EasyUnlockUtil();
63
64 scoped_ptr<ChromeProximityAuthClient> proximity_auth_client_;
sdefresne 2015/04/24 14:22:03 Why not directly use instance value instead of sco
msarda 2015/04/24 15:47:05 Done.
65 scoped_ptr<ScreenlockBridge> screenlock_bridge_;
66 friend struct base::DefaultLazyInstanceTraits<EasyUnlockUtil>;
sdefresne 2015/04/24 14:22:02 style: friend comes before everything else https:
msarda 2015/04/24 15:47:05 Done.
67 friend struct base::DefaultDeleter<EasyUnlockUtil>;
68
69 DISALLOW_COPY_AND_ASSIGN(EasyUnlockUtil);
70 };
71
72 base::LazyInstance<EasyUnlockUtil> g_easy_unlock_util_instance =
73 LAZY_INSTANCE_INITIALIZER;
74
75 EasyUnlockUtil::EasyUnlockUtil() {
76 proximity_auth_client_.reset(new ChromeProximityAuthClient());
77 screenlock_bridge_.reset(new ScreenlockBridge(proximity_auth_client_.get()));
78 }
79
80 EasyUnlockUtil::~EasyUnlockUtil() {
81 }
82
83 ScreenlockBridge* EasyUnlockUtil::GetScreenlockBridge() {
84 return screenlock_bridge_.get();
85 }
86
87 } // namespace
88
89 ScreenlockBridge* GetScreenlockBridgeInstance() {
90 return g_easy_unlock_util_instance.Pointer()->GetScreenlockBridge();
91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698