| 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" |
| 11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "base/version.h" | 13 #include "base/version.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 17 #include "chrome/browser/signin/screenlock_bridge.h" | 17 #include "chrome/browser/signin/screenlock_bridge.h" |
| 18 #include "chrome/browser/signin/signin_manager_factory.h" | 18 #include "chrome/browser/signin/signin_manager_factory.h" |
| 19 #include "chrome/common/chrome_version_info.h" | 19 #include "chrome/common/chrome_version_info.h" |
| 20 #include "chrome/common/extensions/api/easy_unlock_private.h" | 20 #include "chrome/common/extensions/api/easy_unlock_private.h" |
| 21 #include "chrome/common/extensions/extension_constants.h" | 21 #include "chrome/common/extensions/extension_constants.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chromeos/login/user_names.h" | 23 #include "chromeos/login/user_names.h" |
| 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_account_token_fetcher.h" | 25 #include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h" |
| 26 #include "components/proximity_auth/cryptauth/cryptauth_client.h" | 26 #include "components/proximity_auth/cryptauth/cryptauth_client.h" |
| 27 #include "components/proximity_auth/cryptauth/cryptauth_client_factory.h" | 27 #include "components/proximity_auth/cryptauth/cryptauth_client_factory.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 | 34 |
| 35 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 #endif | 216 #endif |
| 217 } | 217 } |
| 218 | 218 |
| 219 void EasyUnlockServiceRegular::RunTurnOffFlow() { | 219 void EasyUnlockServiceRegular::RunTurnOffFlow() { |
| 220 if (turn_off_flow_status_ == PENDING) | 220 if (turn_off_flow_status_ == PENDING) |
| 221 return; | 221 return; |
| 222 DCHECK(!cryptauth_client_); | 222 DCHECK(!cryptauth_client_); |
| 223 | 223 |
| 224 SetTurnOffFlowStatus(PENDING); | 224 SetTurnOffFlowStatus(PENDING); |
| 225 | 225 |
| 226 proximity_auth::CryptAuthClientFactory factory( | 226 auto factory = proximity_auth::CryptAuthClientFactory::CreateDefault( |
| 227 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()), | 227 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()), |
| 228 SigninManagerFactory::GetForProfile(profile()) | 228 SigninManagerFactory::GetForProfile(profile()) |
| 229 ->GetAuthenticatedAccountId(), | 229 ->GetAuthenticatedAccountId(), |
| 230 profile()->GetRequestContext(), GetDeviceClassifier()); | 230 profile()->GetRequestContext(), GetDeviceClassifier()); |
| 231 cryptauth_client_ = factory.CreateInstance(); | 231 cryptauth_client_ = factory->CreateInstance(); |
| 232 | 232 |
| 233 cryptauth::ToggleEasyUnlockRequest request; | 233 cryptauth::ToggleEasyUnlockRequest request; |
| 234 request.set_enable(false); | 234 request.set_enable(false); |
| 235 request.set_apply_to_all(true); | 235 request.set_apply_to_all(true); |
| 236 cryptauth_client_->ToggleEasyUnlock( | 236 cryptauth_client_->ToggleEasyUnlock( |
| 237 request, | 237 request, |
| 238 base::Bind(&EasyUnlockServiceRegular::OnToggleEasyUnlockApiComplete, | 238 base::Bind(&EasyUnlockServiceRegular::OnToggleEasyUnlockApiComplete, |
| 239 weak_ptr_factory_.GetWeakPtr()), | 239 weak_ptr_factory_.GetWeakPtr()), |
| 240 base::Bind(&EasyUnlockServiceRegular::OnToggleEasyUnlockApiFailed, | 240 base::Bind(&EasyUnlockServiceRegular::OnToggleEasyUnlockApiFailed, |
| 241 weak_ptr_factory_.GetWeakPtr())); | 241 weak_ptr_factory_.GetWeakPtr())); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 new base::DictionaryValue()); | 427 new base::DictionaryValue()); |
| 428 user_prefs_dict->SetBooleanWithoutPathExpansion( | 428 user_prefs_dict->SetBooleanWithoutPathExpansion( |
| 429 prefs::kEasyUnlockProximityRequired, | 429 prefs::kEasyUnlockProximityRequired, |
| 430 profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired)); | 430 profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired)); |
| 431 | 431 |
| 432 DictionaryPrefUpdate update(local_state, | 432 DictionaryPrefUpdate update(local_state, |
| 433 prefs::kEasyUnlockLocalStateUserPrefs); | 433 prefs::kEasyUnlockLocalStateUserPrefs); |
| 434 std::string user_email = GetUserEmail(); | 434 std::string user_email = GetUserEmail(); |
| 435 update->SetWithoutPathExpansion(user_email, user_prefs_dict.Pass()); | 435 update->SetWithoutPathExpansion(user_email, user_prefs_dict.Pass()); |
| 436 } | 436 } |
| OLD | NEW |