Chromium Code Reviews| 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/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "components/proximity_auth/logging/logging.h" | 8 #include "components/proximity_auth/logging/logging.h" |
| 9 | 9 |
| 10 #if defined(OS_CHROMEOS) | 10 #if defined(OS_CHROMEOS) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 return; | 124 return; |
| 125 | 125 |
| 126 // TODO(isherman): If |lock_handler| is null, then |lock_handler_| might have | 126 // TODO(isherman): If |lock_handler| is null, then |lock_handler_| might have |
| 127 // been freed. Cache the screen type rather than querying it below. | 127 // been freed. Cache the screen type rather than querying it below. |
| 128 LockHandler::ScreenType screen_type; | 128 LockHandler::ScreenType screen_type; |
| 129 if (lock_handler_) | 129 if (lock_handler_) |
| 130 screen_type = lock_handler_->GetScreenType(); | 130 screen_type = lock_handler_->GetScreenType(); |
| 131 else | 131 else |
| 132 screen_type = lock_handler->GetScreenType(); | 132 screen_type = lock_handler->GetScreenType(); |
| 133 | 133 |
| 134 focused_user_id_ = std::string(); | 134 focused_account_id_ = EmptyAccountId(); |
| 135 lock_handler_ = lock_handler; | 135 lock_handler_ = lock_handler; |
| 136 if (lock_handler_) | 136 if (lock_handler_) |
| 137 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidLock(screen_type)); | 137 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidLock(screen_type)); |
| 138 else | 138 else |
| 139 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidUnlock(screen_type)); | 139 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidUnlock(screen_type)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void ScreenlockBridge::SetFocusedUser(const std::string& user_id) { | 142 void ScreenlockBridge::SetFocusedUser(const AccountId& account_id) { |
| 143 if (user_id == focused_user_id_) | 143 if (account_id == focused_account_id_) |
| 144 return; | 144 return; |
| 145 PA_LOG(INFO) << "Focused user changed to " << user_id; | 145 PA_LOG(INFO) << "Focused user changed to " << account_id.Serialize(); |
| 146 focused_user_id_ = user_id; | 146 focused_account_id_ = account_id; |
| 147 FOR_EACH_OBSERVER(Observer, observers_, OnFocusedUserChanged(user_id)); | 147 FOR_EACH_OBSERVER(Observer, observers_, OnFocusedUserChanged(account_id)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool ScreenlockBridge::IsLocked() const { | 150 bool ScreenlockBridge::IsLocked() const { |
| 151 return lock_handler_ != nullptr; | 151 return lock_handler_ != nullptr; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void ScreenlockBridge::Lock() { | 154 void ScreenlockBridge::Lock() { |
| 155 #if defined(OS_CHROMEOS) | 155 #if defined(OS_CHROMEOS) |
| 156 chromeos::SessionManagerClient* session_manager = | 156 chromeos::SessionManagerClient* session_manager = |
| 157 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); | 157 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| 158 session_manager->RequestLockScreen(); | 158 session_manager->RequestLockScreen(); |
| 159 #else | 159 #else |
| 160 NOTIMPLEMENTED(); | 160 NOTIMPLEMENTED(); |
| 161 #endif | 161 #endif |
| 162 } | 162 } |
| 163 | 163 |
| 164 void ScreenlockBridge::Unlock(const std::string& user_email) { | 164 void ScreenlockBridge::Unlock(const AccountId& account_id) { |
| 165 if (lock_handler_) | 165 if (lock_handler_) |
| 166 lock_handler_->Unlock(user_email); | 166 lock_handler_->Unlock(account_id); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void ScreenlockBridge::AddObserver(Observer* observer) { | 169 void ScreenlockBridge::AddObserver(Observer* observer) { |
| 170 observers_.AddObserver(observer); | 170 observers_.AddObserver(observer); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void ScreenlockBridge::RemoveObserver(Observer* observer) { | 173 void ScreenlockBridge::RemoveObserver(Observer* observer) { |
| 174 observers_.RemoveObserver(observer); | 174 observers_.RemoveObserver(observer); |
| 175 } | 175 } |
| 176 | 176 |
| 177 ScreenlockBridge::ScreenlockBridge() : lock_handler_(nullptr) { | 177 ScreenlockBridge::ScreenlockBridge() |
| 178 } | 178 : lock_handler_(nullptr), focused_account_id_(EmptyAccountId()) {} |
| 179 | 179 |
|
achuithb
2015/12/04 10:12:53
default ctor does the right thing, right?
Alexander Alekseev
2015/12/04 12:44:07
AccountId is not default-constructible.
| |
| 180 ScreenlockBridge::~ScreenlockBridge() { | 180 ScreenlockBridge::~ScreenlockBridge() { |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace proximity_auth | 183 } // namespace proximity_auth |
| OLD | NEW |