OLD | NEW |
---|---|
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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "content/public/browser/render_widget_host.h" | 9 #include "content/public/browser/render_widget_host.h" |
10 #include "content/public/browser/render_widget_host_iterator.h" | 10 #include "content/public/browser/render_widget_host_iterator.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 | 211 |
212 void WindowBoundsChangeObserver::OnWindowBoundsChanged(aura::Window* window, | 212 void WindowBoundsChangeObserver::OnWindowBoundsChanged(aura::Window* window, |
213 const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) { | 213 const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) { |
214 KeyboardController* controller = KeyboardController::GetInstance(); | 214 KeyboardController* controller = KeyboardController::GetInstance(); |
215 if (controller) | 215 if (controller) |
216 controller->UpdateWindowInsets(window); | 216 controller->UpdateWindowInsets(window); |
217 } | 217 } |
218 | 218 |
219 void WindowBoundsChangeObserver::OnWindowDestroyed(aura::Window* window) { | 219 void WindowBoundsChangeObserver::OnWindowDestroyed(aura::Window* window) { |
220 if (window->HasObserver(this)) | 220 if (window->HasObserver(this)) |
221 window->RemoveObserver(this); | 221 window->RemoveObserver(this); |
kevers
2014/09/02 14:10:34
observed_windows_.erase(window);
Shu Chen
2014/09/02 14:30:43
Done.
| |
222 } | 222 } |
223 | 223 |
224 // static | 224 // static |
225 KeyboardController* KeyboardController::instance_ = NULL; | 225 KeyboardController* KeyboardController::instance_ = NULL; |
226 | 226 |
227 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) | 227 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) |
228 : proxy_(proxy), | 228 : proxy_(proxy), |
229 input_method_(NULL), | 229 input_method_(NULL), |
230 keyboard_visible_(false), | 230 keyboard_visible_(false), |
231 show_on_resize_(false), | 231 show_on_resize_(false), |
232 lock_keyboard_(false), | 232 lock_keyboard_(false), |
233 type_(ui::TEXT_INPUT_TYPE_NONE), | 233 type_(ui::TEXT_INPUT_TYPE_NONE), |
234 weak_factory_(this) { | 234 weak_factory_(this) { |
235 CHECK(proxy); | 235 CHECK(proxy); |
236 input_method_ = proxy_->GetInputMethod(); | 236 input_method_ = proxy_->GetInputMethod(); |
237 input_method_->AddObserver(this); | 237 input_method_->AddObserver(this); |
238 window_bounds_observer_.reset(new WindowBoundsChangeObserver()); | 238 window_bounds_observer_.reset(new WindowBoundsChangeObserver()); |
239 } | 239 } |
240 | 240 |
241 KeyboardController::~KeyboardController() { | 241 KeyboardController::~KeyboardController() { |
242 if (container_) | 242 if (container_) |
243 container_->RemoveObserver(this); | 243 container_->RemoveObserver(this); |
244 if (input_method_) | 244 if (input_method_) |
245 input_method_->RemoveObserver(this); | 245 input_method_->RemoveObserver(this); |
246 ResetWindowInsets(); | 246 ResetWindowInsets(); |
247 | |
248 for (std::set<aura::Window*>::iterator it = observed_windows_.begin(); | |
249 it != observed_windows_.end(); ++it) | |
250 (*it)->RemoveObserver(window_bounds_observer_.get()); | |
247 } | 251 } |
248 | 252 |
249 // static | 253 // static |
250 void KeyboardController::ResetInstance(KeyboardController* controller) { | 254 void KeyboardController::ResetInstance(KeyboardController* controller) { |
251 if (instance_ && instance_ != controller) | 255 if (instance_ && instance_ != controller) |
252 delete instance_; | 256 delete instance_; |
253 instance_ = controller; | 257 instance_ = controller; |
254 } | 258 } |
255 | 259 |
256 // static | 260 // static |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
554 | 558 |
555 void KeyboardController::HideAnimationFinished() { | 559 void KeyboardController::HideAnimationFinished() { |
556 proxy_->HideKeyboardContainer(container_.get()); | 560 proxy_->HideKeyboardContainer(container_.get()); |
557 } | 561 } |
558 | 562 |
559 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { | 563 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { |
560 aura::Window* target_window = GetFrameWindow(window); | 564 aura::Window* target_window = GetFrameWindow(window); |
561 if (target_window && | 565 if (target_window && |
562 !target_window->HasObserver(window_bounds_observer_.get())) { | 566 !target_window->HasObserver(window_bounds_observer_.get())) { |
563 target_window->AddObserver(window_bounds_observer_.get()); | 567 target_window->AddObserver(window_bounds_observer_.get()); |
568 observed_windows_.insert(target_window); | |
564 } | 569 } |
565 } | 570 } |
566 | 571 |
567 void KeyboardController::RemoveBoundsChangedObserver(aura::Window* window) { | 572 void KeyboardController::RemoveBoundsChangedObserver(aura::Window* window) { |
568 aura::Window* target_window = GetFrameWindow(window); | 573 aura::Window* target_window = GetFrameWindow(window); |
569 if (target_window && | 574 if (target_window && |
570 target_window->HasObserver(window_bounds_observer_.get())) { | 575 target_window->HasObserver(window_bounds_observer_.get())) { |
571 target_window->RemoveObserver(window_bounds_observer_.get()); | 576 target_window->RemoveObserver(window_bounds_observer_.get()); |
577 observed_windows_.erase(target_window); | |
572 } | 578 } |
573 } | 579 } |
574 | 580 |
575 } // namespace keyboard | 581 } // namespace keyboard |
OLD | NEW |