| 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/screenlock_bridge.h" | 5 #include "components/proximity_auth/screenlock_bridge.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "components/proximity_auth/proximity_auth_client.h" | 9 #include "components/proximity_auth/proximity_auth_client.h" |
| 10 #include "components/user_manager/user_id.h" |
| 10 | 11 |
| 11 #if defined(OS_CHROMEOS) | 12 #if defined(OS_CHROMEOS) |
| 12 #include "chromeos/dbus/dbus_thread_manager.h" | 13 #include "chromeos/dbus/dbus_thread_manager.h" |
| 13 #include "chromeos/dbus/session_manager_client.h" | 14 #include "chromeos/dbus/session_manager_client.h" |
| 14 #endif | 15 #endif |
| 15 | 16 |
| 16 namespace proximity_auth { | 17 namespace proximity_auth { |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 // Ids for the icons that are supported by lock screen and signin screen | 20 // Ids for the icons that are supported by lock screen and signin screen |
| (...skipping 23 matching lines...) Expand all Loading... |
| 43 case ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER: | 44 case ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER: |
| 44 return kSpinnerUserPodCustomIconId; | 45 return kSpinnerUserPodCustomIconId; |
| 45 default: | 46 default: |
| 46 return ""; | 47 return ""; |
| 47 } | 48 } |
| 48 } | 49 } |
| 49 | 50 |
| 50 } // namespace | 51 } // namespace |
| 51 | 52 |
| 52 ScreenlockBridge::ScreenlockBridge(ProximityAuthClient* client) | 53 ScreenlockBridge::ScreenlockBridge(ProximityAuthClient* client) |
| 53 : client_(client), lock_handler_(nullptr) { | 54 : client_(client), lock_handler_(nullptr), focused_user_id_(std::string(), s
td::string()) { |
| 54 DCHECK(client_); | 55 DCHECK(client_); |
| 55 } | 56 } |
| 56 | 57 |
| 57 ScreenlockBridge::~ScreenlockBridge() { | 58 ScreenlockBridge::~ScreenlockBridge() { |
| 58 } | 59 } |
| 59 | 60 |
| 60 ScreenlockBridge::UserPodCustomIconOptions::UserPodCustomIconOptions() | 61 ScreenlockBridge::UserPodCustomIconOptions::UserPodCustomIconOptions() |
| 61 : autoshow_tooltip_(false), | 62 : autoshow_tooltip_(false), |
| 62 hardlock_on_click_(false), | 63 hardlock_on_click_(false), |
| 63 is_trial_run_(false) { | 64 is_trial_run_(false) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 else | 133 else |
| 133 screen_type = lock_handler->GetScreenType(); | 134 screen_type = lock_handler->GetScreenType(); |
| 134 | 135 |
| 135 lock_handler_ = lock_handler; | 136 lock_handler_ = lock_handler; |
| 136 if (lock_handler_) | 137 if (lock_handler_) |
| 137 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidLock(screen_type)); | 138 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidLock(screen_type)); |
| 138 else | 139 else |
| 139 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidUnlock(screen_type)); | 140 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidUnlock(screen_type)); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void ScreenlockBridge::SetFocusedUser(const std::string& user_id) { | 143 void ScreenlockBridge::SetFocusedUser(const user_manager::UserID& user_id) { |
| 143 if (user_id == focused_user_id_) | 144 if (user_id == focused_user_id_) |
| 144 return; | 145 return; |
| 145 focused_user_id_ = user_id; | 146 focused_user_id_ = user_id; |
| 146 FOR_EACH_OBSERVER(Observer, observers_, OnFocusedUserChanged(user_id)); | 147 FOR_EACH_OBSERVER(Observer, observers_, OnFocusedUserChanged(user_id)); |
| 147 } | 148 } |
| 148 | 149 |
| 149 bool ScreenlockBridge::IsLocked() const { | 150 bool ScreenlockBridge::IsLocked() const { |
| 150 return lock_handler_ != nullptr; | 151 return lock_handler_ != nullptr; |
| 151 } | 152 } |
| 152 | 153 |
| 153 void ScreenlockBridge::Lock(content::BrowserContext* browser_context) { | 154 void ScreenlockBridge::Lock(content::BrowserContext* browser_context) { |
| 154 #if defined(OS_CHROMEOS) | 155 #if defined(OS_CHROMEOS) |
| 155 chromeos::SessionManagerClient* session_manager = | 156 chromeos::SessionManagerClient* session_manager = |
| 156 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); | 157 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| 157 session_manager->RequestLockScreen(); | 158 session_manager->RequestLockScreen(); |
| 158 #else | 159 #else |
| 159 client_->Lock(browser_context); | 160 client_->Lock(browser_context); |
| 160 #endif | 161 #endif |
| 161 } | 162 } |
| 162 | 163 |
| 163 void ScreenlockBridge::Unlock(content::BrowserContext* browser_context) { | 164 void ScreenlockBridge::Unlock(content::BrowserContext* browser_context) { |
| 164 if (lock_handler_) | 165 if (lock_handler_) { |
| 165 lock_handler_->Unlock(client_->GetAuthenticatedUsername(browser_context)); | 166 const user_manager::UserID user_id(user_manager::UserID::FromUserEmail(clien
t_->GetAuthenticatedUsername(browser_context))); |
| 167 lock_handler_->Unlock(user_id); |
| 168 } |
| 166 } | 169 } |
| 167 | 170 |
| 168 void ScreenlockBridge::AddObserver(Observer* observer) { | 171 void ScreenlockBridge::AddObserver(Observer* observer) { |
| 169 observers_.AddObserver(observer); | 172 observers_.AddObserver(observer); |
| 170 } | 173 } |
| 171 | 174 |
| 172 void ScreenlockBridge::RemoveObserver(Observer* observer) { | 175 void ScreenlockBridge::RemoveObserver(Observer* observer) { |
| 173 observers_.RemoveObserver(observer); | 176 observers_.RemoveObserver(observer); |
| 174 } | 177 } |
| 175 | 178 |
| 176 } // namespace proximity_auth | 179 } // namespace proximity_auth |
| OLD | NEW |