| 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 "chrome/browser/signin/screenlock_bridge.h" | 5 #include "chrome/browser/signin/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 "chrome/browser/profiles/profile_window.h" | 9 #include "chrome/browser/profiles/profile_window.h" |
| 10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 void ScreenlockBridge::SetLockHandler(LockHandler* lock_handler) { | 131 void ScreenlockBridge::SetLockHandler(LockHandler* lock_handler) { |
| 132 DCHECK(lock_handler_ == NULL || lock_handler == NULL); | 132 DCHECK(lock_handler_ == NULL || lock_handler == NULL); |
| 133 lock_handler_ = lock_handler; | 133 lock_handler_ = lock_handler; |
| 134 if (lock_handler_) | 134 if (lock_handler_) |
| 135 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidLock()); | 135 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidLock()); |
| 136 else | 136 else |
| 137 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidUnlock()); | 137 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidUnlock()); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void ScreenlockBridge::SetFocusedUser(const std::string& user_id) { |
| 141 if (user_id == focused_user_id_) |
| 142 return; |
| 143 focused_user_id_ = user_id; |
| 144 FOR_EACH_OBSERVER(Observer, observers_, OnFocusedUserChanged(user_id)); |
| 145 } |
| 146 |
| 140 bool ScreenlockBridge::IsLocked() const { | 147 bool ScreenlockBridge::IsLocked() const { |
| 141 return lock_handler_ != NULL; | 148 return lock_handler_ != NULL; |
| 142 } | 149 } |
| 143 | 150 |
| 144 void ScreenlockBridge::Lock(Profile* profile) { | 151 void ScreenlockBridge::Lock(Profile* profile) { |
| 145 #if defined(OS_CHROMEOS) | 152 #if defined(OS_CHROMEOS) |
| 146 chromeos::SessionManagerClient* session_manager = | 153 chromeos::SessionManagerClient* session_manager = |
| 147 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); | 154 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| 148 session_manager->RequestLockScreen(); | 155 session_manager->RequestLockScreen(); |
| 149 #else | 156 #else |
| 150 profiles::LockProfile(profile); | 157 profiles::LockProfile(profile); |
| 151 #endif | 158 #endif |
| 152 } | 159 } |
| 153 | 160 |
| 154 void ScreenlockBridge::Unlock(Profile* profile) { | 161 void ScreenlockBridge::Unlock(Profile* profile) { |
| 155 if (lock_handler_) | 162 if (lock_handler_) |
| 156 lock_handler_->Unlock(GetAuthenticatedUserEmail(profile)); | 163 lock_handler_->Unlock(GetAuthenticatedUserEmail(profile)); |
| 157 } | 164 } |
| 158 | 165 |
| 159 void ScreenlockBridge::AddObserver(Observer* observer) { | 166 void ScreenlockBridge::AddObserver(Observer* observer) { |
| 160 observers_.AddObserver(observer); | 167 observers_.AddObserver(observer); |
| 161 } | 168 } |
| 162 | 169 |
| 163 void ScreenlockBridge::RemoveObserver(Observer* observer) { | 170 void ScreenlockBridge::RemoveObserver(Observer* observer) { |
| 164 observers_.RemoveObserver(observer); | 171 observers_.RemoveObserver(observer); |
| 165 } | 172 } |
| OLD | NEW |