| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "components/cryptauth/cryptauth_enrollment_utils.h" | 34 #include "components/cryptauth/cryptauth_enrollment_utils.h" |
| 35 #include "components/cryptauth/cryptauth_gcm_manager_impl.h" | 35 #include "components/cryptauth/cryptauth_gcm_manager_impl.h" |
| 36 #include "components/cryptauth/remote_device_loader.h" | 36 #include "components/cryptauth/remote_device_loader.h" |
| 37 #include "components/cryptauth/secure_message_delegate.h" | 37 #include "components/cryptauth/secure_message_delegate.h" |
| 38 #include "components/gcm_driver/gcm_profile_service.h" | 38 #include "components/gcm_driver/gcm_profile_service.h" |
| 39 #include "components/pref_registry/pref_registry_syncable.h" | 39 #include "components/pref_registry/pref_registry_syncable.h" |
| 40 #include "components/prefs/pref_service.h" | 40 #include "components/prefs/pref_service.h" |
| 41 #include "components/prefs/scoped_user_pref_update.h" | 41 #include "components/prefs/scoped_user_pref_update.h" |
| 42 #include "components/proximity_auth/logging/logging.h" | 42 #include "components/proximity_auth/logging/logging.h" |
| 43 #include "components/proximity_auth/proximity_auth_pref_manager.h" | 43 #include "components/proximity_auth/proximity_auth_pref_manager.h" |
| 44 #include "components/proximity_auth/proximity_auth_pref_names.h" |
| 44 #include "components/proximity_auth/proximity_auth_system.h" | 45 #include "components/proximity_auth/proximity_auth_system.h" |
| 45 #include "components/proximity_auth/screenlock_bridge.h" | 46 #include "components/proximity_auth/screenlock_bridge.h" |
| 46 #include "components/proximity_auth/switches.h" | 47 #include "components/proximity_auth/switches.h" |
| 47 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 48 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 48 #include "components/signin/core/browser/signin_manager.h" | 49 #include "components/signin/core/browser/signin_manager.h" |
| 49 #include "components/translate/core/browser/translate_download_manager.h" | 50 #include "components/translate/core/browser/translate_download_manager.h" |
| 50 #include "components/version_info/version_info.h" | 51 #include "components/version_info/version_info.h" |
| 51 #include "content/public/browser/browser_thread.h" | 52 #include "content/public/browser/browser_thread.h" |
| 52 #include "extensions/browser/event_router.h" | 53 #include "extensions/browser/event_router.h" |
| 53 #include "extensions/common/constants.h" | 54 #include "extensions/common/constants.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 auto_pairing_callback_.Reset(); | 448 auto_pairing_callback_.Reset(); |
| 448 } | 449 } |
| 449 | 450 |
| 450 void EasyUnlockServiceRegular::InitializeInternal() { | 451 void EasyUnlockServiceRegular::InitializeInternal() { |
| 451 proximity_auth::ScreenlockBridge::Get()->AddObserver(this); | 452 proximity_auth::ScreenlockBridge::Get()->AddObserver(this); |
| 452 registrar_.Init(profile()->GetPrefs()); | 453 registrar_.Init(profile()->GetPrefs()); |
| 453 registrar_.Add( | 454 registrar_.Add( |
| 454 prefs::kEasyUnlockAllowed, | 455 prefs::kEasyUnlockAllowed, |
| 455 base::Bind(&EasyUnlockServiceRegular::OnPrefsChanged, | 456 base::Bind(&EasyUnlockServiceRegular::OnPrefsChanged, |
| 456 base::Unretained(this))); | 457 base::Unretained(this))); |
| 458 registrar_.Add(proximity_auth::prefs::kEasyUnlockProximityThreshold, |
| 459 base::Bind(&EasyUnlockServiceRegular::OnPrefsChanged, |
| 460 base::Unretained(this))); |
| 457 | 461 |
| 458 OnPrefsChanged(); | 462 OnPrefsChanged(); |
| 459 | 463 |
| 460 #if defined(OS_CHROMEOS) | 464 #if defined(OS_CHROMEOS) |
| 461 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 465 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 462 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { | 466 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { |
| 463 pref_manager_.reset( | 467 pref_manager_.reset( |
| 464 new proximity_auth::ProximityAuthPrefManager(profile()->GetPrefs())); | 468 new proximity_auth::ProximityAuthPrefManager(profile()->GetPrefs())); |
| 465 GetCryptAuthDeviceManager()->AddObserver(this); | 469 GetCryptAuthDeviceManager()->AddObserver(this); |
| 466 LoadRemoteDevices(); | 470 LoadRemoteDevices(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 PrefService* local_state = | 612 PrefService* local_state = |
| 609 g_browser_process ? g_browser_process->local_state() : NULL; | 613 g_browser_process ? g_browser_process->local_state() : NULL; |
| 610 PrefService* profile_prefs = profile()->GetPrefs(); | 614 PrefService* profile_prefs = profile()->GetPrefs(); |
| 611 if (!local_state || !profile_prefs) | 615 if (!local_state || !profile_prefs) |
| 612 return; | 616 return; |
| 613 | 617 |
| 614 // Create the dictionary of Easy Unlock preferences for the current user. The | 618 // Create the dictionary of Easy Unlock preferences for the current user. The |
| 615 // items in the dictionary are the same profile prefs used for Easy Unlock. | 619 // items in the dictionary are the same profile prefs used for Easy Unlock. |
| 616 std::unique_ptr<base::DictionaryValue> user_prefs_dict( | 620 std::unique_ptr<base::DictionaryValue> user_prefs_dict( |
| 617 new base::DictionaryValue()); | 621 new base::DictionaryValue()); |
| 622 user_prefs_dict->SetIntegerWithoutPathExpansion( |
| 623 proximity_auth::prefs::kEasyUnlockProximityThreshold, |
| 624 profile_prefs->GetInteger( |
| 625 proximity_auth::prefs::kEasyUnlockProximityThreshold)); |
| 618 | 626 |
| 619 DictionaryPrefUpdate update(local_state, | 627 DictionaryPrefUpdate update(local_state, |
| 620 prefs::kEasyUnlockLocalStateUserPrefs); | 628 prefs::kEasyUnlockLocalStateUserPrefs); |
| 621 update->SetWithoutPathExpansion(GetAccountId().GetUserEmail(), | 629 update->SetWithoutPathExpansion(GetAccountId().GetUserEmail(), |
| 622 std::move(user_prefs_dict)); | 630 std::move(user_prefs_dict)); |
| 623 } | 631 } |
| 624 | 632 |
| 625 cryptauth::CryptAuthEnrollmentManager* | 633 cryptauth::CryptAuthEnrollmentManager* |
| 626 EasyUnlockServiceRegular::GetCryptAuthEnrollmentManager() { | 634 EasyUnlockServiceRegular::GetCryptAuthEnrollmentManager() { |
| 627 cryptauth::CryptAuthEnrollmentManager* manager = | 635 cryptauth::CryptAuthEnrollmentManager* manager = |
| 628 ChromeCryptAuthServiceFactory::GetInstance() | 636 ChromeCryptAuthServiceFactory::GetInstance() |
| 629 ->GetForBrowserContext(profile()) | 637 ->GetForBrowserContext(profile()) |
| 630 ->GetCryptAuthEnrollmentManager(); | 638 ->GetCryptAuthEnrollmentManager(); |
| 631 DCHECK(manager); | 639 DCHECK(manager); |
| 632 return manager; | 640 return manager; |
| 633 } | 641 } |
| 634 | 642 |
| 635 cryptauth::CryptAuthDeviceManager* | 643 cryptauth::CryptAuthDeviceManager* |
| 636 EasyUnlockServiceRegular::GetCryptAuthDeviceManager() { | 644 EasyUnlockServiceRegular::GetCryptAuthDeviceManager() { |
| 637 cryptauth::CryptAuthDeviceManager* manager = | 645 cryptauth::CryptAuthDeviceManager* manager = |
| 638 ChromeCryptAuthServiceFactory::GetInstance() | 646 ChromeCryptAuthServiceFactory::GetInstance() |
| 639 ->GetForBrowserContext(profile()) | 647 ->GetForBrowserContext(profile()) |
| 640 ->GetCryptAuthDeviceManager(); | 648 ->GetCryptAuthDeviceManager(); |
| 641 DCHECK(manager); | 649 DCHECK(manager); |
| 642 return manager; | 650 return manager; |
| 643 } | 651 } |
| OLD | NEW |