| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
| 12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
| 13 #include "base/time/default_clock.h" | 13 #include "base/time/default_clock.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 17 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 18 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 18 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 19 #include "chrome/browser/signin/chrome_proximity_auth_client.h" | 19 #include "chrome/browser/signin/chrome_proximity_auth_client.h" |
| 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 21 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
| 22 #include "chrome/common/extensions/api/easy_unlock_private.h" | 22 #include "chrome/common/extensions/api/easy_unlock_private.h" |
| 23 #include "chrome/common/extensions/extension_constants.h" | 23 #include "chrome/common/extensions/extension_constants.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "chromeos/login/user_names.h" | 25 #include "chromeos/login/user_names.h" |
| 26 #include "components/pref_registry/pref_registry_syncable.h" | 26 #include "components/pref_registry/pref_registry_syncable.h" |
| 27 #include "components/proximity_auth/cryptauth/base64url.h" |
| 27 #include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h" | 28 #include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h" |
| 28 #include "components/proximity_auth/cryptauth/cryptauth_client_impl.h" | 29 #include "components/proximity_auth/cryptauth/cryptauth_client_impl.h" |
| 29 #include "components/proximity_auth/cryptauth/cryptauth_device_manager.h" | |
| 30 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h" | 30 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h" |
| 31 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_utils.h" | 31 #include "components/proximity_auth/cryptauth/cryptauth_enrollment_utils.h" |
| 32 #include "components/proximity_auth/cryptauth/cryptauth_gcm_manager_impl.h" | 32 #include "components/proximity_auth/cryptauth/cryptauth_gcm_manager_impl.h" |
| 33 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" | 33 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" |
| 34 #include "components/proximity_auth/cryptauth_enroller_factory_impl.h" | 34 #include "components/proximity_auth/cryptauth_enroller_factory_impl.h" |
| 35 #include "components/proximity_auth/logging/logging.h" | 35 #include "components/proximity_auth/logging/logging.h" |
| 36 #include "components/proximity_auth/proximity_auth_pref_manager.h" | 36 #include "components/proximity_auth/proximity_auth_pref_manager.h" |
| 37 #include "components/proximity_auth/proximity_auth_system.h" |
| 38 #include "components/proximity_auth/remote_device_loader.h" |
| 37 #include "components/proximity_auth/screenlock_bridge.h" | 39 #include "components/proximity_auth/screenlock_bridge.h" |
| 38 #include "components/proximity_auth/switches.h" | 40 #include "components/proximity_auth/switches.h" |
| 39 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 41 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 40 #include "components/signin/core/browser/signin_manager.h" | 42 #include "components/signin/core/browser/signin_manager.h" |
| 41 #include "components/translate/core/browser/translate_download_manager.h" | 43 #include "components/translate/core/browser/translate_download_manager.h" |
| 42 #include "components/version_info/version_info.h" | 44 #include "components/version_info/version_info.h" |
| 43 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
| 44 #include "extensions/browser/event_router.h" | 46 #include "extensions/browser/event_router.h" |
| 45 #include "extensions/common/constants.h" | 47 #include "extensions/common/constants.h" |
| 46 #include "google_apis/gaia/gaia_auth_util.h" | 48 #include "google_apis/gaia/gaia_auth_util.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 67 // Key name of the remote device list in kEasyUnlockPairing. | 69 // Key name of the remote device list in kEasyUnlockPairing. |
| 68 const char kKeyDevices[] = "devices"; | 70 const char kKeyDevices[] = "devices"; |
| 69 | 71 |
| 70 } // namespace | 72 } // namespace |
| 71 | 73 |
| 72 EasyUnlockServiceRegular::EasyUnlockServiceRegular(Profile* profile) | 74 EasyUnlockServiceRegular::EasyUnlockServiceRegular(Profile* profile) |
| 73 : EasyUnlockService(profile), | 75 : EasyUnlockService(profile), |
| 74 turn_off_flow_status_(EasyUnlockService::IDLE), | 76 turn_off_flow_status_(EasyUnlockService::IDLE), |
| 75 will_unlock_using_easy_unlock_(false), | 77 will_unlock_using_easy_unlock_(false), |
| 76 lock_screen_last_shown_timestamp_(base::TimeTicks::Now()), | 78 lock_screen_last_shown_timestamp_(base::TimeTicks::Now()), |
| 77 weak_ptr_factory_(this) { | 79 deferring_device_load_(false), |
| 78 } | 80 weak_ptr_factory_(this) {} |
| 79 | 81 |
| 80 EasyUnlockServiceRegular::~EasyUnlockServiceRegular() { | 82 EasyUnlockServiceRegular::~EasyUnlockServiceRegular() { |
| 81 } | 83 } |
| 82 | 84 |
| 83 proximity_auth::CryptAuthEnrollmentManager* | 85 proximity_auth::CryptAuthEnrollmentManager* |
| 84 EasyUnlockServiceRegular::GetCryptAuthEnrollmentManager() { | 86 EasyUnlockServiceRegular::GetCryptAuthEnrollmentManager() { |
| 85 return enrollment_manager_.get(); | 87 return enrollment_manager_.get(); |
| 86 } | 88 } |
| 87 | 89 |
| 88 proximity_auth::CryptAuthDeviceManager* | 90 proximity_auth::CryptAuthDeviceManager* |
| 89 EasyUnlockServiceRegular::GetCryptAuthDeviceManager() { | 91 EasyUnlockServiceRegular::GetCryptAuthDeviceManager() { |
| 90 return device_manager_.get(); | 92 return device_manager_.get(); |
| 91 } | 93 } |
| 92 | 94 |
| 93 proximity_auth::ProximityAuthPrefManager* | 95 proximity_auth::ProximityAuthPrefManager* |
| 94 EasyUnlockServiceRegular::GetProximityAuthPrefManager() { | 96 EasyUnlockServiceRegular::GetProximityAuthPrefManager() { |
| 95 return pref_manager_.get(); | 97 return pref_manager_.get(); |
| 96 } | 98 } |
| 97 | 99 |
| 100 void EasyUnlockServiceRegular::LoadRemoteDevices() { |
| 101 if (device_manager_->unlock_keys().empty()) { |
| 102 OnRemoteDeviceChanged(nullptr); |
| 103 return; |
| 104 } |
| 105 |
| 106 remote_device_loader_.reset(new proximity_auth::RemoteDeviceLoader( |
| 107 device_manager_->unlock_keys(), proximity_auth_client()->GetAccountId(), |
| 108 enrollment_manager_->GetUserPrivateKey(), |
| 109 proximity_auth_client()->CreateSecureMessageDelegate(), |
| 110 pref_manager_.get())); |
| 111 remote_device_loader_->Load( |
| 112 base::Bind(&EasyUnlockServiceRegular::OnRemoteDevicesLoaded, |
| 113 weak_ptr_factory_.GetWeakPtr())); |
| 114 } |
| 115 |
| 116 void EasyUnlockServiceRegular::OnRemoteDevicesLoaded( |
| 117 const std::vector<proximity_auth::RemoteDevice>& remote_devices) { |
| 118 // TODO(tengs): We only support unlocking with one remote device at the |
| 119 // moment. We need to revisit once multiple devices are supported. |
| 120 OnRemoteDeviceChanged(&remote_devices[0]); |
| 121 |
| 122 #if defined(OS_CHROMEOS) |
| 123 // We need to store a copy of |remote devices_| in the TPM, so it can be |
| 124 // retrieved on the sign-in screen when a user session has not been started |
| 125 // yet. |
| 126 scoped_ptr<base::ListValue> device_list(new base::ListValue()); |
| 127 for (const auto& device : remote_devices) { |
| 128 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 129 std::string b64_public_key, b64_psk; |
| 130 proximity_auth::Base64UrlEncode(device.public_key, &b64_public_key); |
| 131 proximity_auth::Base64UrlEncode(device.persistent_symmetric_key, &b64_psk); |
| 132 |
| 133 dict->SetString("name", device.name); |
| 134 dict->SetString("psk", b64_psk); |
| 135 dict->SetString("bluetoothAddress", device.bluetooth_address); |
| 136 dict->SetString("permitId", "permit://google.com/easyunlock/v1/" + |
| 137 proximity_auth_client()->GetAccountId()); |
| 138 dict->SetString("permitRecord.id", b64_public_key); |
| 139 dict->SetString("permitRecord.type", "license"); |
| 140 dict->SetString("permitRecord.data", b64_public_key); |
| 141 device_list->Append(dict.Pass()); |
| 142 } |
| 143 |
| 144 // TODO(tengs): Rename this function after the easy_unlock app is replaced. |
| 145 SetRemoteDevices(*device_list); |
| 146 #endif |
| 147 } |
| 148 |
| 98 EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const { | 149 EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const { |
| 99 return EasyUnlockService::TYPE_REGULAR; | 150 return EasyUnlockService::TYPE_REGULAR; |
| 100 } | 151 } |
| 101 | 152 |
| 102 std::string EasyUnlockServiceRegular::GetUserEmail() const { | 153 std::string EasyUnlockServiceRegular::GetUserEmail() const { |
| 103 const SigninManagerBase* signin_manager = | 154 const SigninManagerBase* signin_manager = |
| 104 SigninManagerFactory::GetForProfileIfExists(profile()); | 155 SigninManagerFactory::GetForProfileIfExists(profile()); |
| 105 // |profile| has to be a signed-in profile with SigninManager already | 156 // |profile| has to be a signed-in profile with SigninManager already |
| 106 // created. Otherwise, just crash to collect stack. | 157 // created. Otherwise, just crash to collect stack. |
| 107 DCHECK(signin_manager); | 158 DCHECK(signin_manager); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 proximity_auth::ScreenlockBridge::Get()->AddObserver(this); | 381 proximity_auth::ScreenlockBridge::Get()->AddObserver(this); |
| 331 registrar_.Init(profile()->GetPrefs()); | 382 registrar_.Init(profile()->GetPrefs()); |
| 332 registrar_.Add( | 383 registrar_.Add( |
| 333 prefs::kEasyUnlockAllowed, | 384 prefs::kEasyUnlockAllowed, |
| 334 base::Bind(&EasyUnlockServiceRegular::OnPrefsChanged, | 385 base::Bind(&EasyUnlockServiceRegular::OnPrefsChanged, |
| 335 base::Unretained(this))); | 386 base::Unretained(this))); |
| 336 registrar_.Add(prefs::kEasyUnlockProximityRequired, | 387 registrar_.Add(prefs::kEasyUnlockProximityRequired, |
| 337 base::Bind(&EasyUnlockServiceRegular::OnPrefsChanged, | 388 base::Bind(&EasyUnlockServiceRegular::OnPrefsChanged, |
| 338 base::Unretained(this))); | 389 base::Unretained(this))); |
| 339 | 390 |
| 391 OnPrefsChanged(); |
| 392 |
| 340 #if defined(OS_CHROMEOS) | 393 #if defined(OS_CHROMEOS) |
| 341 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 394 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 342 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { | 395 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { |
| 343 InitializeCryptAuth(); | |
| 344 pref_manager_.reset( | 396 pref_manager_.reset( |
| 345 new proximity_auth::ProximityAuthPrefManager(profile()->GetPrefs())); | 397 new proximity_auth::ProximityAuthPrefManager(profile()->GetPrefs())); |
| 398 InitializeCryptAuth(); |
| 399 LoadRemoteDevices(); |
| 346 } | 400 } |
| 347 #endif | 401 #endif |
| 348 | |
| 349 OnPrefsChanged(); | |
| 350 } | 402 } |
| 351 | 403 |
| 352 void EasyUnlockServiceRegular::ShutdownInternal() { | 404 void EasyUnlockServiceRegular::ShutdownInternal() { |
| 353 #if defined(OS_CHROMEOS) | 405 #if defined(OS_CHROMEOS) |
| 354 short_lived_user_context_.reset(); | 406 short_lived_user_context_.reset(); |
| 355 #endif | 407 #endif |
| 356 | 408 |
| 357 turn_off_flow_status_ = EasyUnlockService::IDLE; | 409 turn_off_flow_status_ = EasyUnlockService::IDLE; |
| 358 registrar_.RemoveAll(); | 410 registrar_.RemoveAll(); |
| 359 proximity_auth::ScreenlockBridge::Get()->RemoveObserver(this); | 411 proximity_auth::ScreenlockBridge::Get()->RemoveObserver(this); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 381 #else | 433 #else |
| 382 // TODO(xiyuan): Revisit when non-chromeos platforms are supported. | 434 // TODO(xiyuan): Revisit when non-chromeos platforms are supported. |
| 383 return false; | 435 return false; |
| 384 #endif | 436 #endif |
| 385 } | 437 } |
| 386 | 438 |
| 387 void EasyUnlockServiceRegular::OnWillFinalizeUnlock(bool success) { | 439 void EasyUnlockServiceRegular::OnWillFinalizeUnlock(bool success) { |
| 388 will_unlock_using_easy_unlock_ = success; | 440 will_unlock_using_easy_unlock_ = success; |
| 389 } | 441 } |
| 390 | 442 |
| 391 void EasyUnlockServiceRegular::OnSuspendDone() { | 443 void EasyUnlockServiceRegular::OnSuspendDoneInternal() { |
| 392 lock_screen_last_shown_timestamp_ = base::TimeTicks::Now(); | 444 lock_screen_last_shown_timestamp_ = base::TimeTicks::Now(); |
| 393 } | 445 } |
| 394 | 446 |
| 395 void EasyUnlockServiceRegular::OnRefreshTokenAvailable( | 447 void EasyUnlockServiceRegular::OnRefreshTokenAvailable( |
| 396 const std::string& account_id) { | 448 const std::string& account_id) { |
| 397 if (account_id == proximity_auth_client()->GetAccountId()) { | 449 if (account_id == proximity_auth_client()->GetAccountId()) { |
| 398 OAuth2TokenService* token_service = | 450 OAuth2TokenService* token_service = |
| 399 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); | 451 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); |
| 400 token_service->RemoveObserver(this); | 452 token_service->RemoveObserver(this); |
| 401 #if defined(OS_CHROMEOS) | 453 #if defined(OS_CHROMEOS) |
| 402 InitializeCryptAuth(); | 454 enrollment_manager_->Start(); |
| 455 device_manager_->Start(); |
| 403 #endif | 456 #endif |
| 404 } | 457 } |
| 405 } | 458 } |
| 406 | 459 |
| 460 void EasyUnlockServiceRegular::OnSyncFinished( |
| 461 proximity_auth::CryptAuthDeviceManager::SyncResult sync_result, |
| 462 proximity_auth::CryptAuthDeviceManager::DeviceChangeResult |
| 463 device_change_result) { |
| 464 if (device_change_result != |
| 465 proximity_auth::CryptAuthDeviceManager::DeviceChangeResult::CHANGED) |
| 466 return; |
| 467 |
| 468 if (proximity_auth::ScreenlockBridge::Get()->IsLocked()) { |
| 469 PA_LOG(INFO) << "Deferring device load until screen is unlocked."; |
| 470 deferring_device_load_ = true; |
| 471 } else { |
| 472 LoadRemoteDevices(); |
| 473 } |
| 474 } |
| 475 |
| 407 void EasyUnlockServiceRegular::OnScreenDidLock( | 476 void EasyUnlockServiceRegular::OnScreenDidLock( |
| 408 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { | 477 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { |
| 409 will_unlock_using_easy_unlock_ = false; | 478 will_unlock_using_easy_unlock_ = false; |
| 410 lock_screen_last_shown_timestamp_ = base::TimeTicks::Now(); | 479 lock_screen_last_shown_timestamp_ = base::TimeTicks::Now(); |
| 411 } | 480 } |
| 412 | 481 |
| 413 void EasyUnlockServiceRegular::OnScreenDidUnlock( | 482 void EasyUnlockServiceRegular::OnScreenDidUnlock( |
| 414 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { | 483 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { |
| 415 // Notifications of signin screen unlock events can also reach this code path; | 484 // Notifications of signin screen unlock events can also reach this code path; |
| 416 // disregard them. | 485 // disregard them. |
| 417 if (screen_type != proximity_auth::ScreenlockBridge::LockHandler::LOCK_SCREEN) | 486 if (screen_type != proximity_auth::ScreenlockBridge::LockHandler::LOCK_SCREEN) |
| 418 return; | 487 return; |
| 419 | 488 |
| 420 // Only record metrics for users who have enabled the feature. | 489 // Only record metrics for users who have enabled the feature. |
| 421 if (IsEnabled()) { | 490 if (IsEnabled()) { |
| 422 EasyUnlockAuthEvent event = | 491 EasyUnlockAuthEvent event = |
| 423 will_unlock_using_easy_unlock_ | 492 will_unlock_using_easy_unlock_ |
| 424 ? EASY_UNLOCK_SUCCESS | 493 ? EASY_UNLOCK_SUCCESS |
| 425 : GetPasswordAuthEvent(); | 494 : GetPasswordAuthEvent(); |
| 426 RecordEasyUnlockScreenUnlockEvent(event); | 495 RecordEasyUnlockScreenUnlockEvent(event); |
| 427 | 496 |
| 428 if (will_unlock_using_easy_unlock_) { | 497 if (will_unlock_using_easy_unlock_) { |
| 429 RecordEasyUnlockScreenUnlockDuration( | 498 RecordEasyUnlockScreenUnlockDuration( |
| 430 base::TimeTicks::Now() - lock_screen_last_shown_timestamp_); | 499 base::TimeTicks::Now() - lock_screen_last_shown_timestamp_); |
| 431 } | 500 } |
| 432 } | 501 } |
| 433 | 502 |
| 434 will_unlock_using_easy_unlock_ = false; | 503 will_unlock_using_easy_unlock_ = false; |
| 504 |
| 505 // If we synced remote devices while the screen was locked, we can now load |
| 506 // the new remote devices. |
| 507 if (deferring_device_load_) { |
| 508 PA_LOG(INFO) << "Loading deferred devices after screen unlock."; |
| 509 deferring_device_load_ = false; |
| 510 LoadRemoteDevices(); |
| 511 } |
| 435 } | 512 } |
| 436 | 513 |
| 437 void EasyUnlockServiceRegular::OnFocusedUserChanged( | 514 void EasyUnlockServiceRegular::OnFocusedUserChanged( |
| 438 const std::string& user_id) { | 515 const std::string& user_id) { |
| 439 // Nothing to do. | 516 // Nothing to do. |
| 440 } | 517 } |
| 441 | 518 |
| 442 void EasyUnlockServiceRegular::OnPrefsChanged() { | 519 void EasyUnlockServiceRegular::OnPrefsChanged() { |
| 443 SyncProfilePrefsToLocalState(); | 520 SyncProfilePrefsToLocalState(); |
| 444 UpdateAppState(); | 521 UpdateAppState(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 // Note: The unit of this measument is in milli-inches. | 602 // Note: The unit of this measument is in milli-inches. |
| 526 device_info.set_device_display_diagonal_mils(diagonal_in_inches * 1000.0); | 603 device_info.set_device_display_diagonal_mils(diagonal_in_inches * 1000.0); |
| 527 #else | 604 #else |
| 528 // TODO(tengs): Fill in device information for other platforms. | 605 // TODO(tengs): Fill in device information for other platforms. |
| 529 #endif | 606 #endif |
| 530 return device_info; | 607 return device_info; |
| 531 } | 608 } |
| 532 | 609 |
| 533 #if defined(OS_CHROMEOS) | 610 #if defined(OS_CHROMEOS) |
| 534 void EasyUnlockServiceRegular::InitializeCryptAuth() { | 611 void EasyUnlockServiceRegular::InitializeCryptAuth() { |
| 535 OAuth2TokenService* token_service = | |
| 536 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); | |
| 537 if (!token_service->RefreshTokenIsAvailable( | |
| 538 proximity_auth_client()->GetAccountId())) { | |
| 539 PA_LOG(INFO) << "Refresh token not yet available."; | |
| 540 token_service->AddObserver(this); | |
| 541 return; | |
| 542 } | |
| 543 | |
| 544 PA_LOG(INFO) << "Initializing CryptAuth managers."; | 612 PA_LOG(INFO) << "Initializing CryptAuth managers."; |
| 545 // Initialize GCM manager. | 613 // Initialize GCM manager. |
| 546 gcm_manager_.reset(new proximity_auth::CryptAuthGCMManagerImpl( | 614 gcm_manager_.reset(new proximity_auth::CryptAuthGCMManagerImpl( |
| 547 gcm::GCMProfileServiceFactory::GetForProfile(profile())->driver(), | 615 gcm::GCMProfileServiceFactory::GetForProfile(profile())->driver(), |
| 548 proximity_auth_client()->GetPrefService())); | 616 proximity_auth_client()->GetPrefService())); |
| 549 gcm_manager_->StartListening(); | 617 gcm_manager_->StartListening(); |
| 550 | 618 |
| 551 // Initialize enrollment manager. | 619 // Initialize enrollment manager. |
| 552 cryptauth::GcmDeviceInfo device_info; | 620 cryptauth::GcmDeviceInfo device_info; |
| 553 enrollment_manager_.reset(new proximity_auth::CryptAuthEnrollmentManager( | 621 enrollment_manager_.reset(new proximity_auth::CryptAuthEnrollmentManager( |
| 554 make_scoped_ptr(new base::DefaultClock()), | 622 make_scoped_ptr(new base::DefaultClock()), |
| 555 make_scoped_ptr(new proximity_auth::CryptAuthEnrollerFactoryImpl( | 623 make_scoped_ptr(new proximity_auth::CryptAuthEnrollerFactoryImpl( |
| 556 proximity_auth_client())), | 624 proximity_auth_client())), |
| 557 proximity_auth_client()->CreateSecureMessageDelegate(), | 625 proximity_auth_client()->CreateSecureMessageDelegate(), |
| 558 GetGcmDeviceInfo(), gcm_manager_.get(), | 626 GetGcmDeviceInfo(), gcm_manager_.get(), |
| 559 proximity_auth_client()->GetPrefService())); | 627 proximity_auth_client()->GetPrefService())); |
| 560 enrollment_manager_->Start(); | |
| 561 | 628 |
| 562 // Initialize device manager. | 629 // Initialize device manager. |
| 563 device_manager_.reset(new proximity_auth::CryptAuthDeviceManager( | 630 device_manager_.reset(new proximity_auth::CryptAuthDeviceManager( |
| 564 make_scoped_ptr(new base::DefaultClock()), | 631 make_scoped_ptr(new base::DefaultClock()), |
| 565 proximity_auth_client()->CreateCryptAuthClientFactory(), | 632 proximity_auth_client()->CreateCryptAuthClientFactory(), |
| 566 gcm_manager_.get(), proximity_auth_client()->GetPrefService())); | 633 gcm_manager_.get(), proximity_auth_client()->GetPrefService())); |
| 634 |
| 635 OAuth2TokenService* token_service = |
| 636 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); |
| 637 if (!token_service->RefreshTokenIsAvailable( |
| 638 proximity_auth_client()->GetAccountId())) { |
| 639 PA_LOG(INFO) << "Refresh token not yet available, " |
| 640 << "waiting before starting CryptAuth managers"; |
| 641 token_service->AddObserver(this); |
| 642 } |
| 643 |
| 644 device_manager_->AddObserver(this); |
| 645 enrollment_manager_->Start(); |
| 567 device_manager_->Start(); | 646 device_manager_->Start(); |
| 568 } | 647 } |
| 569 #endif | 648 #endif |
| OLD | NEW |