| 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" | |
| 10 | 9 |
| 11 #if defined(OS_CHROMEOS) | 10 #if defined(OS_CHROMEOS) |
| 12 #include "chromeos/dbus/dbus_thread_manager.h" | 11 #include "chromeos/dbus/dbus_thread_manager.h" |
| 13 #include "chromeos/dbus/session_manager_client.h" | 12 #include "chromeos/dbus/session_manager_client.h" |
| 14 #endif | 13 #endif |
| 15 | 14 |
| 16 namespace proximity_auth { | 15 namespace proximity_auth { |
| 17 namespace { | 16 namespace { |
| 18 | 17 |
| 19 // Ids for the icons that are supported by lock screen and signin screen | 18 // Ids for the icons that are supported by lock screen and signin screen |
| (...skipping 22 matching lines...) Expand all Loading... |
| 42 return kHardlockedUserPodCustomIconId; | 41 return kHardlockedUserPodCustomIconId; |
| 43 case ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER: | 42 case ScreenlockBridge::USER_POD_CUSTOM_ICON_SPINNER: |
| 44 return kSpinnerUserPodCustomIconId; | 43 return kSpinnerUserPodCustomIconId; |
| 45 default: | 44 default: |
| 46 return ""; | 45 return ""; |
| 47 } | 46 } |
| 48 } | 47 } |
| 49 | 48 |
| 50 } // namespace | 49 } // namespace |
| 51 | 50 |
| 52 ScreenlockBridge::ScreenlockBridge(ProximityAuthClient* client) | 51 ScreenlockBridge::ScreenlockBridge() : lock_handler_(nullptr) { |
| 53 : client_(client), lock_handler_(nullptr) { | |
| 54 DCHECK(client_); | |
| 55 } | 52 } |
| 56 | 53 |
| 57 ScreenlockBridge::~ScreenlockBridge() { | 54 ScreenlockBridge::~ScreenlockBridge() { |
| 58 } | 55 } |
| 59 | 56 |
| 60 ScreenlockBridge::UserPodCustomIconOptions::UserPodCustomIconOptions() | 57 ScreenlockBridge::UserPodCustomIconOptions::UserPodCustomIconOptions() |
| 61 : autoshow_tooltip_(false), | 58 : autoshow_tooltip_(false), |
| 62 hardlock_on_click_(false), | 59 hardlock_on_click_(false), |
| 63 is_trial_run_(false) { | 60 is_trial_run_(false) { |
| 64 } | 61 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (user_id == focused_user_id_) | 140 if (user_id == focused_user_id_) |
| 144 return; | 141 return; |
| 145 focused_user_id_ = user_id; | 142 focused_user_id_ = user_id; |
| 146 FOR_EACH_OBSERVER(Observer, observers_, OnFocusedUserChanged(user_id)); | 143 FOR_EACH_OBSERVER(Observer, observers_, OnFocusedUserChanged(user_id)); |
| 147 } | 144 } |
| 148 | 145 |
| 149 bool ScreenlockBridge::IsLocked() const { | 146 bool ScreenlockBridge::IsLocked() const { |
| 150 return lock_handler_ != nullptr; | 147 return lock_handler_ != nullptr; |
| 151 } | 148 } |
| 152 | 149 |
| 153 void ScreenlockBridge::Lock(content::BrowserContext* browser_context) { | 150 void ScreenlockBridge::Lock() { |
| 154 #if defined(OS_CHROMEOS) | 151 #if defined(OS_CHROMEOS) |
| 155 chromeos::SessionManagerClient* session_manager = | 152 chromeos::SessionManagerClient* session_manager = |
| 156 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); | 153 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| 157 session_manager->RequestLockScreen(); | 154 session_manager->RequestLockScreen(); |
| 158 #else | 155 #else |
| 159 client_->Lock(browser_context); | 156 NOTIMPLEMENTED(); |
| 160 #endif | 157 #endif |
| 161 } | 158 } |
| 162 | 159 |
| 163 void ScreenlockBridge::Unlock(content::BrowserContext* browser_context) { | 160 void ScreenlockBridge::Unlock(const std::string& user_email) { |
| 164 if (lock_handler_) | 161 if (lock_handler_) |
| 165 lock_handler_->Unlock(client_->GetAuthenticatedUsername(browser_context)); | 162 lock_handler_->Unlock(user_email); |
| 166 } | 163 } |
| 167 | 164 |
| 168 void ScreenlockBridge::AddObserver(Observer* observer) { | 165 void ScreenlockBridge::AddObserver(Observer* observer) { |
| 169 observers_.AddObserver(observer); | 166 observers_.AddObserver(observer); |
| 170 } | 167 } |
| 171 | 168 |
| 172 void ScreenlockBridge::RemoveObserver(Observer* observer) { | 169 void ScreenlockBridge::RemoveObserver(Observer* observer) { |
| 173 observers_.RemoveObserver(observer); | 170 observers_.RemoveObserver(observer); |
| 174 } | 171 } |
| 175 | 172 |
| 176 } // namespace proximity_auth | 173 } // namespace proximity_auth |
| OLD | NEW |