Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: components/proximity_auth/screenlock_bridge.cc

Issue 2423353002: Reduce usage of FOR_EACH_OBSERVER macro in components/ (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "build/build_config.h" 8 #include "build/build_config.h"
9 #include "components/proximity_auth/logging/logging.h" 9 #include "components/proximity_auth/logging/logging.h"
10 10
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // TODO(isherman): If |lock_handler| is null, then |lock_handler_| might have 127 // TODO(isherman): If |lock_handler| is null, then |lock_handler_| might have
128 // been freed. Cache the screen type rather than querying it below. 128 // been freed. Cache the screen type rather than querying it below.
129 LockHandler::ScreenType screen_type; 129 LockHandler::ScreenType screen_type;
130 if (lock_handler_) 130 if (lock_handler_)
131 screen_type = lock_handler_->GetScreenType(); 131 screen_type = lock_handler_->GetScreenType();
132 else 132 else
133 screen_type = lock_handler->GetScreenType(); 133 screen_type = lock_handler->GetScreenType();
134 134
135 focused_account_id_ = EmptyAccountId(); 135 focused_account_id_ = EmptyAccountId();
136 lock_handler_ = lock_handler; 136 lock_handler_ = lock_handler;
137 if (lock_handler_) 137 if (lock_handler_) {
138 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidLock(screen_type)); 138 for (auto& observer : observers_)
139 else 139 observer.OnScreenDidLock(screen_type);
140 FOR_EACH_OBSERVER(Observer, observers_, OnScreenDidUnlock(screen_type)); 140 } else {
141 for (auto& observer : observers_)
142 observer.OnScreenDidUnlock(screen_type);
143 }
141 } 144 }
142 145
143 void ScreenlockBridge::SetFocusedUser(const AccountId& account_id) { 146 void ScreenlockBridge::SetFocusedUser(const AccountId& account_id) {
144 if (account_id == focused_account_id_) 147 if (account_id == focused_account_id_)
145 return; 148 return;
146 PA_LOG(INFO) << "Focused user changed to " << account_id.Serialize(); 149 PA_LOG(INFO) << "Focused user changed to " << account_id.Serialize();
147 focused_account_id_ = account_id; 150 focused_account_id_ = account_id;
148 FOR_EACH_OBSERVER(Observer, observers_, OnFocusedUserChanged(account_id)); 151 for (auto& observer : observers_)
152 observer.OnFocusedUserChanged(account_id);
149 } 153 }
150 154
151 bool ScreenlockBridge::IsLocked() const { 155 bool ScreenlockBridge::IsLocked() const {
152 return lock_handler_ != nullptr; 156 return lock_handler_ != nullptr;
153 } 157 }
154 158
155 void ScreenlockBridge::Lock() { 159 void ScreenlockBridge::Lock() {
156 #if defined(OS_CHROMEOS) 160 #if defined(OS_CHROMEOS)
157 chromeos::SessionManagerClient* session_manager = 161 chromeos::SessionManagerClient* session_manager =
158 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); 162 chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
(...skipping 16 matching lines...) Expand all
175 observers_.RemoveObserver(observer); 179 observers_.RemoveObserver(observer);
176 } 180 }
177 181
178 ScreenlockBridge::ScreenlockBridge() 182 ScreenlockBridge::ScreenlockBridge()
179 : lock_handler_(nullptr), focused_account_id_(EmptyAccountId()) {} 183 : lock_handler_(nullptr), focused_account_id_(EmptyAccountId()) {}
180 184
181 ScreenlockBridge::~ScreenlockBridge() { 185 ScreenlockBridge::~ScreenlockBridge() {
182 } 186 }
183 187
184 } // namespace proximity_auth 188 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/remote_device_life_cycle_impl.cc ('k') | components/user_manager/user_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698