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

Side by Side Diff: components/proximity_auth/proximity_auth_system.cc

Issue 1494153002: This CL replaces e-mail with AccountId in easy signin code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 5 years 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
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 "components/proximity_auth/proximity_auth_system.h" 5 #include "components/proximity_auth/proximity_auth_system.h"
6 6
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "base/time/default_tick_clock.h" 8 #include "base/time/default_tick_clock.h"
9 #include "components/proximity_auth/logging/logging.h" 9 #include "components/proximity_auth/logging/logging.h"
10 #include "components/proximity_auth/proximity_auth_client.h" 10 #include "components/proximity_auth/proximity_auth_client.h"
(...skipping 26 matching lines...) Expand all
37 suspended_(false), 37 suspended_(false),
38 weak_ptr_factory_(this) {} 38 weak_ptr_factory_(this) {}
39 39
40 ProximityAuthSystem::~ProximityAuthSystem() { 40 ProximityAuthSystem::~ProximityAuthSystem() {
41 ScreenlockBridge::Get()->RemoveObserver(this); 41 ScreenlockBridge::Get()->RemoveObserver(this);
42 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr); 42 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
43 } 43 }
44 44
45 void ProximityAuthSystem::Start() { 45 void ProximityAuthSystem::Start() {
46 ScreenlockBridge::Get()->AddObserver(this); 46 ScreenlockBridge::Get()->AddObserver(this);
47 if (remote_device_.user_id == ScreenlockBridge::Get()->focused_user_id()) 47 if (remote_device_.user_id ==
48 OnFocusedUserChanged(ScreenlockBridge::Get()->focused_user_id()); 48 ScreenlockBridge::Get()->focused_account_id().GetUserEmail())
49 OnFocusedUserChanged(ScreenlockBridge::Get()->focused_account_id());
49 } 50 }
50 51
51 void ProximityAuthSystem::OnAuthAttempted(const std::string& user_id) { 52 void ProximityAuthSystem::OnAuthAttempted(const AccountId& /* account_id */) {
52 // TODO(tengs): There is no reason to pass the |user_id| argument anymore. 53 // TODO(tengs): There is no reason to pass the |account_id| argument anymore.
53 unlock_manager_->OnAuthAttempted(ScreenlockBridge::LockHandler::USER_CLICK); 54 unlock_manager_->OnAuthAttempted(ScreenlockBridge::LockHandler::USER_CLICK);
54 } 55 }
55 56
56 void ProximityAuthSystem::OnSuspend() { 57 void ProximityAuthSystem::OnSuspend() {
57 PA_LOG(INFO) << "Preparing for device suspension."; 58 PA_LOG(INFO) << "Preparing for device suspension.";
58 DCHECK(!suspended_); 59 DCHECK(!suspended_);
59 suspended_ = true; 60 suspended_ = true;
60 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr); 61 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
61 remote_device_life_cycle_.reset(); 62 remote_device_life_cycle_.reset();
62 } 63 }
(...skipping 12 matching lines...) Expand all
75 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 76 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
76 FROM_HERE, base::Bind(&ProximityAuthSystem::ResumeAfterWakeUpTimeout, 77 FROM_HERE, base::Bind(&ProximityAuthSystem::ResumeAfterWakeUpTimeout,
77 weak_ptr_factory_.GetWeakPtr()), 78 weak_ptr_factory_.GetWeakPtr()),
78 base::TimeDelta::FromSeconds(kWakeUpTimeoutSeconds)); 79 base::TimeDelta::FromSeconds(kWakeUpTimeoutSeconds));
79 } 80 }
80 81
81 void ProximityAuthSystem::ResumeAfterWakeUpTimeout() { 82 void ProximityAuthSystem::ResumeAfterWakeUpTimeout() {
82 PA_LOG(INFO) << "Resume after suspend"; 83 PA_LOG(INFO) << "Resume after suspend";
83 suspended_ = false; 84 suspended_ = false;
84 if (ScreenlockBridge::Get()->IsLocked()) 85 if (ScreenlockBridge::Get()->IsLocked())
85 OnFocusedUserChanged(ScreenlockBridge::Get()->focused_user_id()); 86 OnFocusedUserChanged(ScreenlockBridge::Get()->focused_account_id());
86 } 87 }
87 88
88 void ProximityAuthSystem::OnLifeCycleStateChanged( 89 void ProximityAuthSystem::OnLifeCycleStateChanged(
89 RemoteDeviceLifeCycle::State old_state, 90 RemoteDeviceLifeCycle::State old_state,
90 RemoteDeviceLifeCycle::State new_state) { 91 RemoteDeviceLifeCycle::State new_state) {
91 unlock_manager_->OnLifeCycleStateChanged(); 92 unlock_manager_->OnLifeCycleStateChanged();
92 } 93 }
93 94
94 void ProximityAuthSystem::OnScreenDidLock( 95 void ProximityAuthSystem::OnScreenDidLock(
95 ScreenlockBridge::LockHandler::ScreenType screen_type) { 96 ScreenlockBridge::LockHandler::ScreenType screen_type) {
96 OnFocusedUserChanged(ScreenlockBridge::Get()->focused_user_id()); 97 OnFocusedUserChanged(ScreenlockBridge::Get()->focused_account_id());
97 } 98 }
98 99
99 void ProximityAuthSystem::OnScreenDidUnlock( 100 void ProximityAuthSystem::OnScreenDidUnlock(
100 ScreenlockBridge::LockHandler::ScreenType screen_type) { 101 ScreenlockBridge::LockHandler::ScreenType screen_type) {
101 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr); 102 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
102 remote_device_life_cycle_.reset(); 103 remote_device_life_cycle_.reset();
103 } 104 }
104 105
105 void ProximityAuthSystem::OnFocusedUserChanged(const std::string& user_id) { 106 void ProximityAuthSystem::OnFocusedUserChanged(const AccountId& account_id) {
106 if (!user_id.empty() && remote_device_.user_id != user_id) { 107 if (account_id.is_valid() &&
108 remote_device_.user_id != account_id.GetUserEmail()) {
107 PA_LOG(INFO) << "Different user focused, destroying RemoteDeviceLifeCycle."; 109 PA_LOG(INFO) << "Different user focused, destroying RemoteDeviceLifeCycle.";
108 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr); 110 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
109 remote_device_life_cycle_.reset(); 111 remote_device_life_cycle_.reset();
110 } else if (!remote_device_life_cycle_ && !suspended_) { 112 } else if (!remote_device_life_cycle_ && !suspended_) {
111 PA_LOG(INFO) << "Creating RemoteDeviceLifeCycle for focused user."; 113 PA_LOG(INFO) << "Creating RemoteDeviceLifeCycle for focused user.";
112 remote_device_life_cycle_.reset( 114 remote_device_life_cycle_.reset(
113 new RemoteDeviceLifeCycleImpl(remote_device_, proximity_auth_client_)); 115 new RemoteDeviceLifeCycleImpl(remote_device_, proximity_auth_client_));
114 unlock_manager_->SetRemoteDeviceLifeCycle(remote_device_life_cycle_.get()); 116 unlock_manager_->SetRemoteDeviceLifeCycle(remote_device_life_cycle_.get());
115 remote_device_life_cycle_->AddObserver(this); 117 remote_device_life_cycle_->AddObserver(this);
116 remote_device_life_cycle_->Start(); 118 remote_device_life_cycle_->Start();
117 } 119 }
118 } 120 }
119 121
120 } // proximity_auth 122 } // proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698