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 <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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 } | 249 } |
250 return container_.get(); | 250 return container_.get(); |
251 } | 251 } |
252 | 252 |
253 void KeyboardController::NotifyKeyboardBoundsChanging( | 253 void KeyboardController::NotifyKeyboardBoundsChanging( |
254 const gfx::Rect& new_bounds) { | 254 const gfx::Rect& new_bounds) { |
255 current_keyboard_bounds_ = new_bounds; | 255 current_keyboard_bounds_ = new_bounds; |
256 if (proxy_->HasKeyboardWindow() && proxy_->GetKeyboardWindow()->IsVisible()) { | 256 if (proxy_->HasKeyboardWindow() && proxy_->GetKeyboardWindow()->IsVisible()) { |
257 FOR_EACH_OBSERVER(KeyboardControllerObserver, | 257 FOR_EACH_OBSERVER(KeyboardControllerObserver, |
258 observer_list_, | 258 observer_list_, |
259 OnKeyboardBoundsChanging(new_bounds)); | 259 OnKeyboardBoundsChanging(new_bounds)); |
flackr
2015/06/24 22:08:42
Do we ever need to get this Changing notification
bshe
2015/06/25 14:01:59
We probably do. Or we have to make sure the observ
| |
260 if (keyboard::IsKeyboardOverscrollEnabled()) { | 260 if (keyboard::IsKeyboardOverscrollEnabled()) { |
261 // Adjust the height of the viewport for visible windows on the primary | 261 // Adjust the height of the viewport for visible windows on the primary |
262 // display. | 262 // display. |
263 // TODO(kevers): Add EnvObserver to properly initialize insets if a | 263 // TODO(kevers): Add EnvObserver to properly initialize insets if a |
264 // window is created while the keyboard is visible. | 264 // window is created while the keyboard is visible. |
265 scoped_ptr<content::RenderWidgetHostIterator> widgets( | 265 scoped_ptr<content::RenderWidgetHostIterator> widgets( |
266 content::RenderWidgetHost::GetRenderWidgetHosts()); | 266 content::RenderWidgetHost::GetRenderWidgetHosts()); |
267 aura::Window* keyboard_window = proxy_->GetKeyboardWindow(); | 267 aura::Window* keyboard_window = proxy_->GetKeyboardWindow(); |
268 aura::Window* root_window = keyboard_window->GetRootWindow(); | 268 aura::Window* root_window = keyboard_window->GetRootWindow(); |
269 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { | 269 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { |
(...skipping 15 matching lines...) Expand all Loading... | |
285 view->SetInsets(gfx::Insets(0, 0, overlap, 0)); | 285 view->SetInsets(gfx::Insets(0, 0, overlap, 0)); |
286 else | 286 else |
287 view->SetInsets(gfx::Insets()); | 287 view->SetInsets(gfx::Insets()); |
288 AddBoundsChangedObserver(window); | 288 AddBoundsChangedObserver(window); |
289 } | 289 } |
290 } | 290 } |
291 } | 291 } |
292 } else { | 292 } else { |
293 ResetWindowInsets(); | 293 ResetWindowInsets(); |
294 } | 294 } |
295 FOR_EACH_OBSERVER(KeyboardControllerObserver, | |
296 observer_list_, | |
297 OnKeyboardBoundsChanged(new_bounds)); | |
295 } else { | 298 } else { |
296 current_keyboard_bounds_ = gfx::Rect(); | 299 current_keyboard_bounds_ = gfx::Rect(); |
297 } | 300 } |
298 } | 301 } |
299 | 302 |
300 void KeyboardController::HideKeyboard(HideReason reason) { | 303 void KeyboardController::HideKeyboard(HideReason reason) { |
301 keyboard_visible_ = false; | 304 keyboard_visible_ = false; |
302 ToggleTouchEventLogging(true); | 305 ToggleTouchEventLogging(true); |
303 | 306 |
304 keyboard::LogKeyboardControlEvent( | 307 keyboard::LogKeyboardControlEvent( |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 proxy_->HideKeyboardContainer(container_.get()); | 598 proxy_->HideKeyboardContainer(container_.get()); |
596 } | 599 } |
597 | 600 |
598 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { | 601 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { |
599 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; | 602 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; |
600 if (target_window) | 603 if (target_window) |
601 window_bounds_observer_->AddObservedWindow(target_window); | 604 window_bounds_observer_->AddObservedWindow(target_window); |
602 } | 605 } |
603 | 606 |
604 } // namespace keyboard | 607 } // namespace keyboard |
OLD | NEW |