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

Side by Side Diff: ui/keyboard/keyboard_controller.cc

Issue 2422073002: Reduce FOR_EACH_OBSERVER usage in ui/ (Closed)
Patch Set: remove space 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
« no previous file with comments | « ui/gl/gpu_switching_manager.cc ('k') | ui/native_theme/native_theme.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/keyboard/keyboard_controller.h" 5 #include "ui/keyboard/keyboard_controller.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 181 }
182 182
183 KeyboardController::~KeyboardController() { 183 KeyboardController::~KeyboardController() {
184 if (container_) { 184 if (container_) {
185 if (container_->GetRootWindow()) 185 if (container_->GetRootWindow())
186 container_->GetRootWindow()->RemoveObserver(this); 186 container_->GetRootWindow()->RemoveObserver(this);
187 container_->RemoveObserver(this); 187 container_->RemoveObserver(this);
188 } 188 }
189 if (input_method_) 189 if (input_method_)
190 input_method_->RemoveObserver(this); 190 input_method_->RemoveObserver(this);
191 FOR_EACH_OBSERVER(KeyboardControllerObserver, observer_list_, 191 for (KeyboardControllerObserver& observer : observer_list_)
192 OnKeyboardClosed()); 192 observer.OnKeyboardClosed();
193 ui_->SetController(nullptr); 193 ui_->SetController(nullptr);
194 } 194 }
195 195
196 // static 196 // static
197 void KeyboardController::ResetInstance(KeyboardController* controller) { 197 void KeyboardController::ResetInstance(KeyboardController* controller) {
198 if (instance_ && instance_ != controller) 198 if (instance_ && instance_ != controller)
199 delete instance_; 199 delete instance_;
200 instance_ = controller; 200 instance_ = controller;
201 } 201 }
202 202
(...skipping 11 matching lines...) Expand all
214 container_->AddObserver(this); 214 container_->AddObserver(this);
215 container_->SetLayoutManager(new KeyboardLayoutManager(this)); 215 container_->SetLayoutManager(new KeyboardLayoutManager(this));
216 } 216 }
217 return container_.get(); 217 return container_.get();
218 } 218 }
219 219
220 void KeyboardController::NotifyKeyboardBoundsChanging( 220 void KeyboardController::NotifyKeyboardBoundsChanging(
221 const gfx::Rect& new_bounds) { 221 const gfx::Rect& new_bounds) {
222 current_keyboard_bounds_ = new_bounds; 222 current_keyboard_bounds_ = new_bounds;
223 if (ui_->HasKeyboardWindow() && ui_->GetKeyboardWindow()->IsVisible()) { 223 if (ui_->HasKeyboardWindow() && ui_->GetKeyboardWindow()->IsVisible()) {
224 FOR_EACH_OBSERVER(KeyboardControllerObserver, 224 for (KeyboardControllerObserver& observer : observer_list_)
225 observer_list_, 225 observer.OnKeyboardBoundsChanging(new_bounds);
226 OnKeyboardBoundsChanging(new_bounds));
227 if (keyboard::IsKeyboardOverscrollEnabled()) 226 if (keyboard::IsKeyboardOverscrollEnabled())
228 ui_->InitInsets(new_bounds); 227 ui_->InitInsets(new_bounds);
229 else 228 else
230 ui_->ResetInsets(); 229 ui_->ResetInsets();
231 } else { 230 } else {
232 current_keyboard_bounds_ = gfx::Rect(); 231 current_keyboard_bounds_ = gfx::Rect();
233 } 232 }
234 } 233 }
235 234
236 void KeyboardController::HideKeyboard(HideReason reason) { 235 void KeyboardController::HideKeyboard(HideReason reason) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 480
482 void KeyboardController::ShowAnimationFinished() { 481 void KeyboardController::ShowAnimationFinished() {
483 // Notify observers after animation finished to prevent reveal desktop 482 // Notify observers after animation finished to prevent reveal desktop
484 // background during animation. 483 // background during animation.
485 NotifyKeyboardBoundsChanging(container_->bounds()); 484 NotifyKeyboardBoundsChanging(container_->bounds());
486 ui_->EnsureCaretInWorkArea(); 485 ui_->EnsureCaretInWorkArea();
487 } 486 }
488 487
489 void KeyboardController::HideAnimationFinished() { 488 void KeyboardController::HideAnimationFinished() {
490 ui_->HideKeyboardContainer(container_.get()); 489 ui_->HideKeyboardContainer(container_.get());
491 FOR_EACH_OBSERVER(KeyboardControllerObserver, observer_list_, 490 for (KeyboardControllerObserver& observer : observer_list_)
492 OnKeyboardHidden()); 491 observer.OnKeyboardHidden();
493 } 492 }
494 493
495 } // namespace keyboard 494 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/gl/gpu_switching_manager.cc ('k') | ui/native_theme/native_theme.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698