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

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

Issue 2861913002: [EasyUnlock] Fix crash when the same user pod is refocused. (Closed)
Patch Set: fixes Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/proximity_auth/proximity_auth_system_unittest.cc » ('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 "components/proximity_auth/proximity_auth_system.h" 5 #include "components/proximity_auth/proximity_auth_system.h"
6 6
7 #include "base/threading/thread_task_runner_handle.h" 7 #include "base/threading/thread_task_runner_handle.h"
8 #include "components/proximity_auth/logging/logging.h" 8 #include "components/proximity_auth/logging/logging.h"
9 #include "components/proximity_auth/proximity_auth_client.h" 9 #include "components/proximity_auth/proximity_auth_client.h"
10 #include "components/proximity_auth/remote_device_life_cycle_impl.h" 10 #include "components/proximity_auth/remote_device_life_cycle_impl.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 OnFocusedUserChanged(ScreenlockBridge::Get()->focused_account_id()); 120 OnFocusedUserChanged(ScreenlockBridge::Get()->focused_account_id());
121 } 121 }
122 122
123 void ProximityAuthSystem::OnScreenDidUnlock( 123 void ProximityAuthSystem::OnScreenDidUnlock(
124 ScreenlockBridge::LockHandler::ScreenType screen_type) { 124 ScreenlockBridge::LockHandler::ScreenType screen_type) {
125 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr); 125 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
126 remote_device_life_cycle_.reset(); 126 remote_device_life_cycle_.reset();
127 } 127 }
128 128
129 void ProximityAuthSystem::OnFocusedUserChanged(const AccountId& account_id) { 129 void ProximityAuthSystem::OnFocusedUserChanged(const AccountId& account_id) {
130 if (!account_id.is_valid())
131 return;
132
133 // Update the current RemoteDeviceLifeCycle to the focused user. 130 // Update the current RemoteDeviceLifeCycle to the focused user.
134 if (remote_device_life_cycle_ && 131 if (remote_device_life_cycle_) {
135 remote_device_life_cycle_->GetRemoteDevice().user_id != 132 if (remote_device_life_cycle_->GetRemoteDevice().user_id !=
136 account_id.GetUserEmail()) { 133 account_id.GetUserEmail()) {
137 PA_LOG(INFO) << "Focused user changed, destroying life cycle for " 134 PA_LOG(INFO) << "Focused user changed, destroying life cycle for "
138 << account_id.Serialize() << "."; 135 << account_id.Serialize() << ".";
139 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr); 136 unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
140 remote_device_life_cycle_.reset(); 137 remote_device_life_cycle_.reset();
138 } else {
139 PA_LOG(INFO) << "Refocused on a user who is already focused.";
140 return;
141 }
141 } 142 }
142 143
143 if (remote_devices_map_.find(account_id) == remote_devices_map_.end() || 144 if (remote_devices_map_.find(account_id) == remote_devices_map_.end() ||
144 remote_devices_map_[account_id].size() == 0) { 145 remote_devices_map_[account_id].size() == 0) {
145 PA_LOG(INFO) << "User " << account_id.Serialize() 146 PA_LOG(INFO) << "User " << account_id.Serialize()
146 << " does not have a RemoteDevice."; 147 << " does not have a RemoteDevice.";
147 return; 148 return;
148 } 149 }
149 150
150 // TODO(tengs): We currently assume each user has only one RemoteDevice, so we 151 // TODO(tengs): We currently assume each user has only one RemoteDevice, so we
151 // can simply take the first item in the list. 152 // can simply take the first item in the list.
152 cryptauth::RemoteDevice remote_device = remote_devices_map_[account_id][0]; 153 cryptauth::RemoteDevice remote_device = remote_devices_map_[account_id][0];
153 if (!suspended_) { 154 if (!suspended_) {
154 PA_LOG(INFO) << "Creating RemoteDeviceLifeCycle for focused user: " 155 PA_LOG(INFO) << "Creating RemoteDeviceLifeCycle for focused user: "
155 << account_id.Serialize(); 156 << account_id.Serialize();
156 remote_device_life_cycle_ = CreateRemoteDeviceLifeCycle(remote_device); 157 remote_device_life_cycle_ = CreateRemoteDeviceLifeCycle(remote_device);
157 unlock_manager_->SetRemoteDeviceLifeCycle(remote_device_life_cycle_.get()); 158 unlock_manager_->SetRemoteDeviceLifeCycle(remote_device_life_cycle_.get());
158 remote_device_life_cycle_->AddObserver(this); 159 remote_device_life_cycle_->AddObserver(this);
159 remote_device_life_cycle_->Start(); 160 remote_device_life_cycle_->Start();
160 } 161 }
161 } 162 }
162 163
163 } // proximity_auth 164 } // proximity_auth
OLDNEW
« no previous file with comments | « no previous file | components/proximity_auth/proximity_auth_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698