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

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

Issue 2502343003: Moved //components/proximity_auth/cryptauth to //components/cryptauth. (Closed)
Patch Set: Fixed proto #includes. Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/signin/easy_unlock_service_regular.h ('k') | components/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/base64url.h" 11 #include "base/base64url.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/sys_info.h" 16 #include "base/sys_info.h"
17 #include "base/time/default_clock.h" 17 #include "base/time/default_clock.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 22 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
23 #include "chrome/browser/signin/chrome_proximity_auth_client.h" 23 #include "chrome/browser/signin/chrome_proximity_auth_client.h"
24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
25 #include "chrome/browser/signin/signin_manager_factory.h" 25 #include "chrome/browser/signin/signin_manager_factory.h"
26 #include "chrome/common/extensions/api/easy_unlock_private.h" 26 #include "chrome/common/extensions/api/easy_unlock_private.h"
27 #include "chrome/common/extensions/extension_constants.h" 27 #include "chrome/common/extensions/extension_constants.h"
28 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 #include "components/cryptauth/cryptauth_access_token_fetcher.h"
30 #include "components/cryptauth/cryptauth_client_impl.h"
31 #include "components/cryptauth/cryptauth_enrollment_manager.h"
32 #include "components/cryptauth/cryptauth_enrollment_utils.h"
33 #include "components/cryptauth/cryptauth_gcm_manager_impl.h"
34 #include "components/cryptauth/secure_message_delegate.h"
29 #include "components/gcm_driver/gcm_profile_service.h" 35 #include "components/gcm_driver/gcm_profile_service.h"
30 #include "components/pref_registry/pref_registry_syncable.h" 36 #include "components/pref_registry/pref_registry_syncable.h"
31 #include "components/prefs/pref_service.h" 37 #include "components/prefs/pref_service.h"
32 #include "components/prefs/scoped_user_pref_update.h" 38 #include "components/prefs/scoped_user_pref_update.h"
33 #include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h"
34 #include "components/proximity_auth/cryptauth/cryptauth_client_impl.h"
35 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h"
36 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_utils.h"
37 #include "components/proximity_auth/cryptauth/cryptauth_gcm_manager_impl.h"
38 #include "components/proximity_auth/cryptauth/secure_message_delegate.h"
39 #include "components/proximity_auth/cryptauth_enroller_factory_impl.h" 39 #include "components/proximity_auth/cryptauth_enroller_factory_impl.h"
40 #include "components/proximity_auth/logging/logging.h" 40 #include "components/proximity_auth/logging/logging.h"
41 #include "components/proximity_auth/proximity_auth_pref_manager.h" 41 #include "components/proximity_auth/proximity_auth_pref_manager.h"
42 #include "components/proximity_auth/proximity_auth_system.h" 42 #include "components/proximity_auth/proximity_auth_system.h"
43 #include "components/proximity_auth/remote_device_loader.h" 43 #include "components/proximity_auth/remote_device_loader.h"
44 #include "components/proximity_auth/screenlock_bridge.h" 44 #include "components/proximity_auth/screenlock_bridge.h"
45 #include "components/proximity_auth/switches.h" 45 #include "components/proximity_auth/switches.h"
46 #include "components/signin/core/browser/profile_oauth2_token_service.h" 46 #include "components/signin/core/browser/profile_oauth2_token_service.h"
47 #include "components/signin/core/browser/signin_manager.h" 47 #include "components/signin/core/browser/signin_manager.h"
48 #include "components/translate/core/browser/translate_download_manager.h" 48 #include "components/translate/core/browser/translate_download_manager.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 : EasyUnlockService(profile), 80 : EasyUnlockService(profile),
81 turn_off_flow_status_(EasyUnlockService::IDLE), 81 turn_off_flow_status_(EasyUnlockService::IDLE),
82 will_unlock_using_easy_unlock_(false), 82 will_unlock_using_easy_unlock_(false),
83 lock_screen_last_shown_timestamp_(base::TimeTicks::Now()), 83 lock_screen_last_shown_timestamp_(base::TimeTicks::Now()),
84 deferring_device_load_(false), 84 deferring_device_load_(false),
85 weak_ptr_factory_(this) {} 85 weak_ptr_factory_(this) {}
86 86
87 EasyUnlockServiceRegular::~EasyUnlockServiceRegular() { 87 EasyUnlockServiceRegular::~EasyUnlockServiceRegular() {
88 } 88 }
89 89
90 proximity_auth::CryptAuthEnrollmentManager* 90 cryptauth::CryptAuthEnrollmentManager*
91 EasyUnlockServiceRegular::GetCryptAuthEnrollmentManager() { 91 EasyUnlockServiceRegular::GetCryptAuthEnrollmentManager() {
92 return enrollment_manager_.get(); 92 return enrollment_manager_.get();
93 } 93 }
94 94
95 proximity_auth::CryptAuthDeviceManager* 95 cryptauth::CryptAuthDeviceManager*
96 EasyUnlockServiceRegular::GetCryptAuthDeviceManager() { 96 EasyUnlockServiceRegular::GetCryptAuthDeviceManager() {
97 return device_manager_.get(); 97 return device_manager_.get();
98 } 98 }
99 99
100 proximity_auth::ProximityAuthPrefManager* 100 proximity_auth::ProximityAuthPrefManager*
101 EasyUnlockServiceRegular::GetProximityAuthPrefManager() { 101 EasyUnlockServiceRegular::GetProximityAuthPrefManager() {
102 return pref_manager_.get(); 102 return pref_manager_.get();
103 } 103 }
104 104
105 void EasyUnlockServiceRegular::LoadRemoteDevices() { 105 void EasyUnlockServiceRegular::LoadRemoteDevices() {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 337 }
338 } 338 }
339 339
340 void EasyUnlockServiceRegular::RunTurnOffFlow() { 340 void EasyUnlockServiceRegular::RunTurnOffFlow() {
341 if (turn_off_flow_status_ == PENDING) 341 if (turn_off_flow_status_ == PENDING)
342 return; 342 return;
343 DCHECK(!cryptauth_client_); 343 DCHECK(!cryptauth_client_);
344 344
345 SetTurnOffFlowStatus(PENDING); 345 SetTurnOffFlowStatus(PENDING);
346 346
347 std::unique_ptr<proximity_auth::CryptAuthClientFactory> factory = 347 std::unique_ptr<cryptauth::CryptAuthClientFactory> factory =
348 proximity_auth_client()->CreateCryptAuthClientFactory(); 348 proximity_auth_client()->CreateCryptAuthClientFactory();
349 cryptauth_client_ = factory->CreateInstance(); 349 cryptauth_client_ = factory->CreateInstance();
350 350
351 cryptauth::ToggleEasyUnlockRequest request; 351 cryptauth::ToggleEasyUnlockRequest request;
352 request.set_enable(false); 352 request.set_enable(false);
353 request.set_apply_to_all(true); 353 request.set_apply_to_all(true);
354 cryptauth_client_->ToggleEasyUnlock( 354 cryptauth_client_->ToggleEasyUnlock(
355 request, 355 request,
356 base::Bind(&EasyUnlockServiceRegular::OnToggleEasyUnlockApiComplete, 356 base::Bind(&EasyUnlockServiceRegular::OnToggleEasyUnlockApiComplete,
357 weak_ptr_factory_.GetWeakPtr()), 357 weak_ptr_factory_.GetWeakPtr()),
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); 491 ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
492 token_service->RemoveObserver(this); 492 token_service->RemoveObserver(this);
493 #if defined(OS_CHROMEOS) 493 #if defined(OS_CHROMEOS)
494 enrollment_manager_->Start(); 494 enrollment_manager_->Start();
495 device_manager_->Start(); 495 device_manager_->Start();
496 #endif 496 #endif
497 } 497 }
498 } 498 }
499 499
500 void EasyUnlockServiceRegular::OnSyncFinished( 500 void EasyUnlockServiceRegular::OnSyncFinished(
501 proximity_auth::CryptAuthDeviceManager::SyncResult sync_result, 501 cryptauth::CryptAuthDeviceManager::SyncResult sync_result,
502 proximity_auth::CryptAuthDeviceManager::DeviceChangeResult 502 cryptauth::CryptAuthDeviceManager::DeviceChangeResult
503 device_change_result) { 503 device_change_result) {
504 if (device_change_result != 504 if (device_change_result !=
505 proximity_auth::CryptAuthDeviceManager::DeviceChangeResult::CHANGED) 505 cryptauth::CryptAuthDeviceManager::DeviceChangeResult::CHANGED)
506 return; 506 return;
507 507
508 if (proximity_auth::ScreenlockBridge::Get()->IsLocked()) { 508 if (proximity_auth::ScreenlockBridge::Get()->IsLocked()) {
509 PA_LOG(INFO) << "Deferring device load until screen is unlocked."; 509 PA_LOG(INFO) << "Deferring device load until screen is unlocked.";
510 deferring_device_load_ = true; 510 deferring_device_load_ = true;
511 } else { 511 } else {
512 LoadRemoteDevices(); 512 LoadRemoteDevices();
513 } 513 }
514 } 514 }
515 515
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 update->SetWithoutPathExpansion(GetAccountId().GetUserEmail(), 601 update->SetWithoutPathExpansion(GetAccountId().GetUserEmail(),
602 std::move(user_prefs_dict)); 602 std::move(user_prefs_dict));
603 } 603 }
604 604
605 cryptauth::GcmDeviceInfo EasyUnlockServiceRegular::GetGcmDeviceInfo() { 605 cryptauth::GcmDeviceInfo EasyUnlockServiceRegular::GetGcmDeviceInfo() {
606 cryptauth::GcmDeviceInfo device_info; 606 cryptauth::GcmDeviceInfo device_info;
607 device_info.set_long_device_id(EasyUnlockService::GetDeviceId()); 607 device_info.set_long_device_id(EasyUnlockService::GetDeviceId());
608 device_info.set_device_type(cryptauth::CHROME); 608 device_info.set_device_type(cryptauth::CHROME);
609 device_info.set_device_software_version(version_info::GetVersionNumber()); 609 device_info.set_device_software_version(version_info::GetVersionNumber());
610 google::protobuf::int64 software_version_code = 610 google::protobuf::int64 software_version_code =
611 proximity_auth::HashStringToInt64(version_info::GetLastChange()); 611 cryptauth::HashStringToInt64(version_info::GetLastChange());
612 device_info.set_device_software_version_code(software_version_code); 612 device_info.set_device_software_version_code(software_version_code);
613 device_info.set_locale( 613 device_info.set_locale(
614 translate::TranslateDownloadManager::GetInstance()->application_locale()); 614 translate::TranslateDownloadManager::GetInstance()->application_locale());
615 615
616 #if defined(OS_CHROMEOS) 616 #if defined(OS_CHROMEOS)
617 device_info.set_device_model(base::SysInfo::GetLsbReleaseBoard()); 617 device_info.set_device_model(base::SysInfo::GetLsbReleaseBoard());
618 device_info.set_device_os_version(base::GetLinuxDistro()); 618 device_info.set_device_os_version(base::GetLinuxDistro());
619 // The Chrome OS version tracks the Chrome version, so fill in the same value 619 // The Chrome OS version tracks the Chrome version, so fill in the same value
620 // as |device_software_version_code|. 620 // as |device_software_version_code|.
621 device_info.set_device_os_version_code(software_version_code); 621 device_info.set_device_os_version_code(software_version_code);
(...skipping 23 matching lines...) Expand all
645 #else 645 #else
646 // TODO(tengs): Fill in device information for other platforms. 646 // TODO(tengs): Fill in device information for other platforms.
647 #endif 647 #endif
648 return device_info; 648 return device_info;
649 } 649 }
650 650
651 #if defined(OS_CHROMEOS) 651 #if defined(OS_CHROMEOS)
652 void EasyUnlockServiceRegular::InitializeCryptAuth() { 652 void EasyUnlockServiceRegular::InitializeCryptAuth() {
653 PA_LOG(INFO) << "Initializing CryptAuth managers."; 653 PA_LOG(INFO) << "Initializing CryptAuth managers.";
654 // Initialize GCM manager. 654 // Initialize GCM manager.
655 gcm_manager_.reset(new proximity_auth::CryptAuthGCMManagerImpl( 655 gcm_manager_.reset(new cryptauth::CryptAuthGCMManagerImpl(
656 gcm::GCMProfileServiceFactory::GetForProfile(profile())->driver(), 656 gcm::GCMProfileServiceFactory::GetForProfile(profile())->driver(),
657 proximity_auth_client()->GetPrefService())); 657 proximity_auth_client()->GetPrefService()));
658 gcm_manager_->StartListening(); 658 gcm_manager_->StartListening();
659 659
660 // Initialize enrollment manager. 660 // Initialize enrollment manager.
661 cryptauth::GcmDeviceInfo device_info; 661 cryptauth::GcmDeviceInfo device_info;
662 enrollment_manager_.reset(new proximity_auth::CryptAuthEnrollmentManager( 662 enrollment_manager_.reset(new cryptauth::CryptAuthEnrollmentManager(
663 base::MakeUnique<base::DefaultClock>(), 663 base::MakeUnique<base::DefaultClock>(),
664 base::MakeUnique<proximity_auth::CryptAuthEnrollerFactoryImpl>( 664 base::MakeUnique<proximity_auth::CryptAuthEnrollerFactoryImpl>(
665 proximity_auth_client()), 665 proximity_auth_client()),
666 proximity_auth_client()->CreateSecureMessageDelegate(), 666 proximity_auth_client()->CreateSecureMessageDelegate(),
667 GetGcmDeviceInfo(), gcm_manager_.get(), 667 GetGcmDeviceInfo(), gcm_manager_.get(),
668 proximity_auth_client()->GetPrefService())); 668 proximity_auth_client()->GetPrefService()));
669 669
670 // Initialize device manager. 670 // Initialize device manager.
671 device_manager_.reset(new proximity_auth::CryptAuthDeviceManager( 671 device_manager_.reset(new cryptauth::CryptAuthDeviceManager(
672 base::MakeUnique<base::DefaultClock>(), 672 base::MakeUnique<base::DefaultClock>(),
673 proximity_auth_client()->CreateCryptAuthClientFactory(), 673 proximity_auth_client()->CreateCryptAuthClientFactory(),
674 gcm_manager_.get(), proximity_auth_client()->GetPrefService())); 674 gcm_manager_.get(), proximity_auth_client()->GetPrefService()));
675 675
676 OAuth2TokenService* token_service = 676 OAuth2TokenService* token_service =
677 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); 677 ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
678 if (!token_service->RefreshTokenIsAvailable( 678 if (!token_service->RefreshTokenIsAvailable(
679 proximity_auth_client()->GetAccountId())) { 679 proximity_auth_client()->GetAccountId())) {
680 PA_LOG(INFO) << "Refresh token not yet available, " 680 PA_LOG(INFO) << "Refresh token not yet available, "
681 << "waiting before starting CryptAuth managers"; 681 << "waiting before starting CryptAuth managers";
682 token_service->AddObserver(this); 682 token_service->AddObserver(this);
683 } 683 }
684 684
685 device_manager_->AddObserver(this); 685 device_manager_->AddObserver(this);
686 enrollment_manager_->Start(); 686 enrollment_manager_->Start();
687 device_manager_->Start(); 687 device_manager_->Start();
688 } 688 }
689 #endif 689 #endif
OLDNEW
« no previous file with comments | « chrome/browser/signin/easy_unlock_service_regular.h ('k') | components/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698