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

Unified Diff: chrome/browser/signin/easy_unlock_service_regular.cc

Issue 1377313002: Revert of Hook up ProximityAuthSystem in EasyUnlockService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_connection
Patch Set: Created 5 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/signin/easy_unlock_service_regular.cc
diff --git a/chrome/browser/signin/easy_unlock_service_regular.cc b/chrome/browser/signin/easy_unlock_service_regular.cc
index a4ba88b6e9152689746dc9b6a5413ff49e01a4e9..7f1ebabb4f615324996fe5aefc10f309597ea5ef 100644
--- a/chrome/browser/signin/easy_unlock_service_regular.cc
+++ b/chrome/browser/signin/easy_unlock_service_regular.cc
@@ -24,9 +24,9 @@
#include "chrome/common/pref_names.h"
#include "chromeos/login/user_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
-#include "components/proximity_auth/cryptauth/base64url.h"
#include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h"
#include "components/proximity_auth/cryptauth/cryptauth_client_impl.h"
+#include "components/proximity_auth/cryptauth/cryptauth_device_manager.h"
#include "components/proximity_auth/cryptauth/cryptauth_enrollment_manager.h"
#include "components/proximity_auth/cryptauth/cryptauth_enrollment_utils.h"
#include "components/proximity_auth/cryptauth/cryptauth_gcm_manager_impl.h"
@@ -34,8 +34,6 @@
#include "components/proximity_auth/cryptauth_enroller_factory_impl.h"
#include "components/proximity_auth/logging/logging.h"
#include "components/proximity_auth/proximity_auth_pref_manager.h"
-#include "components/proximity_auth/proximity_auth_system.h"
-#include "components/proximity_auth/remote_device_loader.h"
#include "components/proximity_auth/screenlock_bridge.h"
#include "components/proximity_auth/switches.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
@@ -76,8 +74,8 @@
turn_off_flow_status_(EasyUnlockService::IDLE),
will_unlock_using_easy_unlock_(false),
lock_screen_last_shown_timestamp_(base::TimeTicks::Now()),
- deferring_device_load_(false),
- weak_ptr_factory_(this) {}
+ weak_ptr_factory_(this) {
+}
EasyUnlockServiceRegular::~EasyUnlockServiceRegular() {
}
@@ -95,55 +93,6 @@
proximity_auth::ProximityAuthPrefManager*
EasyUnlockServiceRegular::GetProximityAuthPrefManager() {
return pref_manager_.get();
-}
-
-void EasyUnlockServiceRegular::LoadRemoteDevices() {
- if (device_manager_->unlock_keys().empty()) {
- OnRemoteDeviceChanged(nullptr);
- return;
- }
-
- remote_device_loader_.reset(new proximity_auth::RemoteDeviceLoader(
- device_manager_->unlock_keys(), proximity_auth_client()->GetAccountId(),
- enrollment_manager_->GetUserPrivateKey(),
- proximity_auth_client()->CreateSecureMessageDelegate(),
- pref_manager_.get()));
- remote_device_loader_->Load(
- base::Bind(&EasyUnlockServiceRegular::OnRemoteDevicesLoaded,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void EasyUnlockServiceRegular::OnRemoteDevicesLoaded(
- const std::vector<proximity_auth::RemoteDevice>& remote_devices) {
- // TODO(tengs): We only support unlocking with one remote device at the
- // moment. We need to revisit once multiple devices are supported.
- OnRemoteDeviceChanged(&remote_devices[0]);
-
-#if defined(OS_CHROMEOS)
- // We need to store a copy of |remote devices_| in the TPM, so it can be
- // retrieved on the sign-in screen when a user session has not been started
- // yet.
- scoped_ptr<base::ListValue> device_list(new base::ListValue());
- for (const auto& device : remote_devices) {
- scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- std::string b64_public_key, b64_psk;
- proximity_auth::Base64UrlEncode(device.public_key, &b64_public_key);
- proximity_auth::Base64UrlEncode(device.persistent_symmetric_key, &b64_psk);
-
- dict->SetString("name", device.name);
- dict->SetString("psk", b64_psk);
- dict->SetString("bluetoothAddress", device.bluetooth_address);
- dict->SetString("permitId", "permit://google.com/easyunlock/v1/" +
- proximity_auth_client()->GetAccountId());
- dict->SetString("permitRecord.id", b64_public_key);
- dict->SetString("permitRecord.type", "license");
- dict->SetString("permitRecord.data", b64_public_key);
- device_list->Append(dict.Pass());
- }
-
- // TODO(tengs): Rename this function after the easy_unlock app is replaced.
- SetRemoteDevices(*device_list);
-#endif
}
EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const {
@@ -388,17 +337,16 @@
base::Bind(&EasyUnlockServiceRegular::OnPrefsChanged,
base::Unretained(this)));
- OnPrefsChanged();
-
#if defined(OS_CHROMEOS)
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) {
+ InitializeCryptAuth();
pref_manager_.reset(
new proximity_auth::ProximityAuthPrefManager(profile()->GetPrefs()));
- InitializeCryptAuth();
- LoadRemoteDevices();
- }
-#endif
+ }
+#endif
+
+ OnPrefsChanged();
}
void EasyUnlockServiceRegular::ShutdownInternal() {
@@ -440,7 +388,7 @@
will_unlock_using_easy_unlock_ = success;
}
-void EasyUnlockServiceRegular::OnSuspendDoneInternal() {
+void EasyUnlockServiceRegular::OnSuspendDone() {
lock_screen_last_shown_timestamp_ = base::TimeTicks::Now();
}
@@ -451,25 +399,8 @@
ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
token_service->RemoveObserver(this);
#if defined(OS_CHROMEOS)
- enrollment_manager_->Start();
- device_manager_->Start();
-#endif
- }
-}
-
-void EasyUnlockServiceRegular::OnSyncFinished(
- proximity_auth::CryptAuthDeviceManager::SyncResult sync_result,
- proximity_auth::CryptAuthDeviceManager::DeviceChangeResult
- device_change_result) {
- if (device_change_result !=
- proximity_auth::CryptAuthDeviceManager::DeviceChangeResult::CHANGED)
- return;
-
- if (proximity_auth::ScreenlockBridge::Get()->IsLocked()) {
- PA_LOG(INFO) << "Deferring device load until screen is unlocked.";
- deferring_device_load_ = true;
- } else {
- LoadRemoteDevices();
+ InitializeCryptAuth();
+#endif
}
}
@@ -501,14 +432,6 @@
}
will_unlock_using_easy_unlock_ = false;
-
- // If we synced remote devices while the screen was locked, we can now load
- // the new remote devices.
- if (deferring_device_load_) {
- PA_LOG(INFO) << "Loading deferred devices after screen unlock.";
- deferring_device_load_ = false;
- LoadRemoteDevices();
- }
}
void EasyUnlockServiceRegular::OnFocusedUserChanged(
@@ -609,6 +532,15 @@
#if defined(OS_CHROMEOS)
void EasyUnlockServiceRegular::InitializeCryptAuth() {
+ OAuth2TokenService* token_service =
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
+ if (!token_service->RefreshTokenIsAvailable(
+ proximity_auth_client()->GetAccountId())) {
+ PA_LOG(INFO) << "Refresh token not yet available.";
+ token_service->AddObserver(this);
+ return;
+ }
+
PA_LOG(INFO) << "Initializing CryptAuth managers.";
// Initialize GCM manager.
gcm_manager_.reset(new proximity_auth::CryptAuthGCMManagerImpl(
@@ -625,24 +557,13 @@
proximity_auth_client()->CreateSecureMessageDelegate(),
GetGcmDeviceInfo(), gcm_manager_.get(),
proximity_auth_client()->GetPrefService()));
+ enrollment_manager_->Start();
// Initialize device manager.
device_manager_.reset(new proximity_auth::CryptAuthDeviceManager(
make_scoped_ptr(new base::DefaultClock()),
proximity_auth_client()->CreateCryptAuthClientFactory(),
gcm_manager_.get(), proximity_auth_client()->GetPrefService()));
-
- OAuth2TokenService* token_service =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile());
- if (!token_service->RefreshTokenIsAvailable(
- proximity_auth_client()->GetAccountId())) {
- PA_LOG(INFO) << "Refresh token not yet available, "
- << "waiting before starting CryptAuth managers";
- token_service->AddObserver(this);
- }
-
- device_manager_->AddObserver(this);
- enrollment_manager_->Start();
device_manager_->Start();
}
#endif
« no previous file with comments | « chrome/browser/signin/easy_unlock_service_regular.h ('k') | chrome/browser/signin/easy_unlock_service_signin_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698