OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/signin/easy_unlock_service_regular.h" | 5 #include "chrome/browser/signin/easy_unlock_service_regular.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" |
25 #include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h" | 25 #include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h" |
26 #include "components/proximity_auth/cryptauth/cryptauth_client_impl.h" | 26 #include "components/proximity_auth/cryptauth/cryptauth_client_impl.h" |
27 #include "components/proximity_auth/screenlock_bridge.h" | 27 #include "components/proximity_auth/screenlock_bridge.h" |
28 #include "components/proximity_auth/switches.h" | 28 #include "components/proximity_auth/switches.h" |
29 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 29 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
30 #include "components/signin/core/browser/signin_manager.h" | 30 #include "components/signin/core/browser/signin_manager.h" |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 #include "extensions/browser/event_router.h" | 32 #include "extensions/browser/event_router.h" |
33 #include "extensions/common/constants.h" | 33 #include "extensions/common/constants.h" |
| 34 #include "google_apis/gaia/gaia_auth_util.h" |
34 | 35 |
35 #if defined(OS_CHROMEOS) | 36 #if defined(OS_CHROMEOS) |
36 #include "apps/app_lifetime_monitor_factory.h" | 37 #include "apps/app_lifetime_monitor_factory.h" |
37 #include "base/thread_task_runner_handle.h" | 38 #include "base/thread_task_runner_handle.h" |
38 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" | 39 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" |
39 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_reauth.h" | 40 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_reauth.h" |
40 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 41 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
41 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 42 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
42 #include "components/user_manager/user_manager.h" | 43 #include "components/user_manager/user_manager.h" |
43 #endif | 44 #endif |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const { | 92 EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const { |
92 return EasyUnlockService::TYPE_REGULAR; | 93 return EasyUnlockService::TYPE_REGULAR; |
93 } | 94 } |
94 | 95 |
95 std::string EasyUnlockServiceRegular::GetUserEmail() const { | 96 std::string EasyUnlockServiceRegular::GetUserEmail() const { |
96 const SigninManagerBase* signin_manager = | 97 const SigninManagerBase* signin_manager = |
97 SigninManagerFactory::GetForProfileIfExists(profile()); | 98 SigninManagerFactory::GetForProfileIfExists(profile()); |
98 // |profile| has to be a signed-in profile with SigninManager already | 99 // |profile| has to be a signed-in profile with SigninManager already |
99 // created. Otherwise, just crash to collect stack. | 100 // created. Otherwise, just crash to collect stack. |
100 DCHECK(signin_manager); | 101 DCHECK(signin_manager); |
101 return signin_manager->GetAuthenticatedUsername(); | 102 const std::string user_email = signin_manager->GetAuthenticatedUsername(); |
| 103 return user_email.empty() ? user_email : gaia::CanonicalizeEmail(user_email); |
102 } | 104 } |
103 | 105 |
104 void EasyUnlockServiceRegular::LaunchSetup() { | 106 void EasyUnlockServiceRegular::LaunchSetup() { |
105 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 107 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
106 #if defined(OS_CHROMEOS) | 108 #if defined(OS_CHROMEOS) |
107 // Force the user to reauthenticate by showing a modal overlay (similar to the | 109 // Force the user to reauthenticate by showing a modal overlay (similar to the |
108 // lock screen). The password obtained from the reauth is cached for a short | 110 // lock screen). The password obtained from the reauth is cached for a short |
109 // period of time and used to create the cryptohome keys for sign-in. | 111 // period of time and used to create the cryptohome keys for sign-in. |
110 if (short_lived_user_context_ && short_lived_user_context_->user_context()) { | 112 if (short_lived_user_context_ && short_lived_user_context_->user_context()) { |
111 OpenSetupApp(); | 113 OpenSetupApp(); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 new base::DictionaryValue()); | 434 new base::DictionaryValue()); |
433 user_prefs_dict->SetBooleanWithoutPathExpansion( | 435 user_prefs_dict->SetBooleanWithoutPathExpansion( |
434 prefs::kEasyUnlockProximityRequired, | 436 prefs::kEasyUnlockProximityRequired, |
435 profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired)); | 437 profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired)); |
436 | 438 |
437 DictionaryPrefUpdate update(local_state, | 439 DictionaryPrefUpdate update(local_state, |
438 prefs::kEasyUnlockLocalStateUserPrefs); | 440 prefs::kEasyUnlockLocalStateUserPrefs); |
439 std::string user_email = GetUserEmail(); | 441 std::string user_email = GetUserEmail(); |
440 update->SetWithoutPathExpansion(user_email, user_prefs_dict.Pass()); | 442 update->SetWithoutPathExpansion(user_email, user_prefs_dict.Pass()); |
441 } | 443 } |
OLD | NEW |