Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/ui/touch/frame/touch_browser_frame_view.h" | 5 #include "chrome/browser/ui/touch/frame/touch_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/renderer_host/render_view_host.h" | 8 #include "chrome/browser/renderer_host/render_view_host.h" |
| 9 #include "chrome/browser/tab_contents/navigation_controller.h" | 9 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 keyboard_(NULL) { | 31 keyboard_(NULL) { |
| 32 registrar_.Add(this, | 32 registrar_.Add(this, |
| 33 NotificationType::NAV_ENTRY_COMMITTED, | 33 NotificationType::NAV_ENTRY_COMMITTED, |
| 34 NotificationService::AllSources()); | 34 NotificationService::AllSources()); |
| 35 registrar_.Add(this, | 35 registrar_.Add(this, |
| 36 NotificationType::FOCUS_CHANGED_IN_PAGE, | 36 NotificationType::FOCUS_CHANGED_IN_PAGE, |
| 37 NotificationService::AllSources()); | 37 NotificationService::AllSources()); |
| 38 } | 38 } |
| 39 | 39 |
| 40 TouchBrowserFrameView::~TouchBrowserFrameView() { | 40 TouchBrowserFrameView::~TouchBrowserFrameView() { |
| 41 if (focus_change_listener_.get()) { | |
| 42 GetFocusManager()->RemoveFocusChangeListener(focus_change_listener_.get()); | |
| 43 } | |
| 41 } | 44 } |
| 42 | 45 |
| 43 void TouchBrowserFrameView::Layout() { | 46 void TouchBrowserFrameView::Layout() { |
| 44 OpaqueBrowserFrameView::Layout(); | 47 OpaqueBrowserFrameView::Layout(); |
| 45 | 48 |
| 46 if (!keyboard_) | 49 if (!keyboard_) |
| 47 return; | 50 return; |
| 48 | 51 |
| 49 keyboard_->SetVisible(keyboard_showing_); | 52 keyboard_->SetVisible(keyboard_showing_); |
| 50 keyboard_->SetBounds(GetBoundsForReservedArea()); | 53 keyboard_->SetBounds(GetBoundsForReservedArea()); |
| 51 } | 54 } |
| 52 | 55 |
| 53 /////////////////////////////////////////////////////////////////////////////// | 56 /////////////////////////////////////////////////////////////////////////////// |
| 54 // TouchBrowserFrameView, protected: | 57 // TouchBrowserFrameView, protected: |
| 55 int TouchBrowserFrameView::GetReservedHeight() const { | 58 int TouchBrowserFrameView::GetReservedHeight() const { |
| 56 if (keyboard_showing_) | 59 if (keyboard_showing_) |
| 57 return kKeyboardHeight; | 60 return kKeyboardHeight; |
| 58 | 61 |
| 59 return 0; | 62 return 0; |
| 60 } | 63 } |
| 61 | 64 |
| 65 void TouchBrowserFrameView::ViewHierarchyChanged( | |
| 66 bool is_add, View* parent, View* child) { | |
|
rjkroege
2011/01/27 00:04:22
could be indented the other way probably?
varunjain
2011/01/27 00:19:34
Done.
| |
| 67 OpaqueBrowserFrameView::ViewHierarchyChanged(is_add, parent, child); | |
| 68 if (!focus_change_listener_.get()) { | |
| 69 focus_change_listener_.reset(new TouchBrowserFocusChangeListener(this)); | |
| 70 GetFocusManager()->AddFocusChangeListener(focus_change_listener_.get()); | |
| 71 } | |
| 72 } | |
| 73 | |
|
rjkroege
2011/01/27 00:04:22
extra blank
varunjain
2011/01/27 00:19:34
Done.
| |
| 74 | |
| 62 /////////////////////////////////////////////////////////////////////////////// | 75 /////////////////////////////////////////////////////////////////////////////// |
| 63 // TouchBrowserFrameView, private: | 76 // TouchBrowserFrameView, private: |
| 64 | 77 |
| 65 void TouchBrowserFrameView::InitVirtualKeyboard() { | 78 void TouchBrowserFrameView::InitVirtualKeyboard() { |
| 66 if (keyboard_) | 79 if (keyboard_) |
| 67 return; | 80 return; |
| 68 | 81 |
| 69 Profile* keyboard_profile = browser_view()->browser()->profile(); | 82 Profile* keyboard_profile = browser_view()->browser()->profile(); |
| 70 DCHECK(keyboard_profile) << "Profile required for virtual keyboard."; | 83 DCHECK(keyboard_profile) << "Profile required for virtual keyboard."; |
| 71 | 84 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 Source<RenderViewHost>(source).ptr()) | 124 Source<RenderViewHost>(source).ptr()) |
| 112 UpdateKeyboardAndLayout(*Details<const bool>(details).ptr()); | 125 UpdateKeyboardAndLayout(*Details<const bool>(details).ptr()); |
| 113 } else if (type == NotificationType::NAV_ENTRY_COMMITTED) { | 126 } else if (type == NotificationType::NAV_ENTRY_COMMITTED) { |
| 114 Browser* source_browser = Browser::GetBrowserForController( | 127 Browser* source_browser = Browser::GetBrowserForController( |
| 115 Source<NavigationController>(source).ptr(), NULL); | 128 Source<NavigationController>(source).ptr(), NULL); |
| 116 // If the Browser for the keyboard has navigated, hide the keyboard. | 129 // If the Browser for the keyboard has navigated, hide the keyboard. |
| 117 if (source_browser == browser) | 130 if (source_browser == browser) |
| 118 UpdateKeyboardAndLayout(false); | 131 UpdateKeyboardAndLayout(false); |
| 119 } | 132 } |
| 120 } | 133 } |
| 134 | |
| 135 /////////////////////////////////////////////////////////////////////////////// | |
| 136 // | |
| 137 // TouchBrowserFocusChangeListener | |
| 138 // | |
| 139 /////////////////////////////////////////////////////////////////////////////// | |
| 140 | |
| 141 TouchBrowserFrameView::TouchBrowserFocusChangeListener | |
| 142 ::TouchBrowserFocusChangeListener(TouchBrowserFrameView* browser_frame) | |
| 143 : touch_browser_frame_(browser_frame) { | |
| 144 } | |
| 145 | |
| 146 void TouchBrowserFrameView::TouchBrowserFocusChangeListener::FocusWillChange( | |
| 147 views::View* focused_before, views::View* focused_now) { | |
| 148 if (!focused_before || (focused_now && focused_now->GetVirtualKeyboardType() | |
| 149 != focused_before->GetVirtualKeyboardType())) { | |
| 150 // TODO: support other types of keyboard. | |
| 151 touch_browser_frame_->UpdateKeyboardAndLayout( | |
| 152 focused_now->GetVirtualKeyboardType() == views::View::REGULAR_KEYBOARD); | |
| 153 } | |
| 154 } | |
| OLD | NEW |