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 "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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 void ProximityAuthSystem::Stop() { | 49 void ProximityAuthSystem::Stop() { |
50 if (!started_) | 50 if (!started_) |
51 return; | 51 return; |
52 started_ = false; | 52 started_ = false; |
53 ScreenlockBridge::Get()->RemoveObserver(this); | 53 ScreenlockBridge::Get()->RemoveObserver(this); |
54 OnFocusedUserChanged(EmptyAccountId()); | 54 OnFocusedUserChanged(EmptyAccountId()); |
55 } | 55 } |
56 | 56 |
57 void ProximityAuthSystem::SetRemoteDevicesForUser( | 57 void ProximityAuthSystem::SetRemoteDevicesForUser( |
58 const AccountId& account_id, | 58 const AccountId& account_id, |
59 const RemoteDeviceList& remote_devices) { | 59 const cryptauth::RemoteDeviceList& remote_devices) { |
60 remote_devices_map_[account_id] = remote_devices; | 60 remote_devices_map_[account_id] = remote_devices; |
61 if (started_) { | 61 if (started_) { |
62 const AccountId& focused_account_id = | 62 const AccountId& focused_account_id = |
63 ScreenlockBridge::Get()->focused_account_id(); | 63 ScreenlockBridge::Get()->focused_account_id(); |
64 if (focused_account_id.is_valid()) | 64 if (focused_account_id.is_valid()) |
65 OnFocusedUserChanged(focused_account_id); | 65 OnFocusedUserChanged(focused_account_id); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 RemoteDeviceList ProximityAuthSystem::GetRemoteDevicesForUser( | 69 cryptauth::RemoteDeviceList ProximityAuthSystem::GetRemoteDevicesForUser( |
70 const AccountId& account_id) const { | 70 const AccountId& account_id) const { |
71 if (remote_devices_map_.find(account_id) == remote_devices_map_.end()) | 71 if (remote_devices_map_.find(account_id) == remote_devices_map_.end()) |
72 return RemoteDeviceList(); | 72 return cryptauth::RemoteDeviceList(); |
73 return remote_devices_map_.at(account_id); | 73 return remote_devices_map_.at(account_id); |
74 } | 74 } |
75 | 75 |
76 void ProximityAuthSystem::OnAuthAttempted(const AccountId& /* account_id */) { | 76 void ProximityAuthSystem::OnAuthAttempted(const AccountId& /* account_id */) { |
77 // TODO(tengs): There is no reason to pass the |account_id| argument anymore. | 77 // TODO(tengs): There is no reason to pass the |account_id| argument anymore. |
78 unlock_manager_->OnAuthAttempted(ScreenlockBridge::LockHandler::USER_CLICK); | 78 unlock_manager_->OnAuthAttempted(ScreenlockBridge::LockHandler::USER_CLICK); |
79 } | 79 } |
80 | 80 |
81 void ProximityAuthSystem::OnSuspend() { | 81 void ProximityAuthSystem::OnSuspend() { |
82 PA_LOG(INFO) << "Preparing for device suspension."; | 82 PA_LOG(INFO) << "Preparing for device suspension."; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 if (remote_devices_map_.find(account_id) == remote_devices_map_.end() || | 147 if (remote_devices_map_.find(account_id) == remote_devices_map_.end() || |
148 remote_devices_map_[account_id].size() == 0) { | 148 remote_devices_map_[account_id].size() == 0) { |
149 PA_LOG(INFO) << "User " << account_id.Serialize() | 149 PA_LOG(INFO) << "User " << account_id.Serialize() |
150 << " does not have a RemoteDevice."; | 150 << " does not have a RemoteDevice."; |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
154 // TODO(tengs): We currently assume each user has only one RemoteDevice, so we | 154 // TODO(tengs): We currently assume each user has only one RemoteDevice, so we |
155 // can simply take the first item in the list. | 155 // can simply take the first item in the list. |
156 RemoteDevice remote_device = remote_devices_map_[account_id][0]; | 156 cryptauth::RemoteDevice remote_device = remote_devices_map_[account_id][0]; |
157 if (!suspended_) { | 157 if (!suspended_) { |
158 PA_LOG(INFO) << "Creating RemoteDeviceLifeCycle for focused user: " | 158 PA_LOG(INFO) << "Creating RemoteDeviceLifeCycle for focused user: " |
159 << account_id.Serialize(); | 159 << account_id.Serialize(); |
160 remote_device_life_cycle_.reset( | 160 remote_device_life_cycle_.reset( |
161 new RemoteDeviceLifeCycleImpl(remote_device, proximity_auth_client_)); | 161 new RemoteDeviceLifeCycleImpl(remote_device, proximity_auth_client_)); |
162 unlock_manager_->SetRemoteDeviceLifeCycle(remote_device_life_cycle_.get()); | 162 unlock_manager_->SetRemoteDeviceLifeCycle(remote_device_life_cycle_.get()); |
163 remote_device_life_cycle_->AddObserver(this); | 163 remote_device_life_cycle_->AddObserver(this); |
164 remote_device_life_cycle_->Start(); | 164 remote_device_life_cycle_->Start(); |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 } // proximity_auth | 168 } // proximity_auth |
OLD | NEW |