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(bool is_add, View* parent, | |
|
bryeung
2011/01/27 20:50:34
Why are we doing this in ViewHierarchyChanged? Is
oshima
2011/01/27 21:35:41
Yes, this is a standard item to initialize things
| |
| 66 View* child) { | |
|
oshima
2011/01/27 19:58:33
fix indentation. see my comment in header.
varunjain
2011/01/27 23:01:38
Done.
| |
| 67 OpaqueBrowserFrameView::ViewHierarchyChanged(is_add, parent, child); | |
| 68 if (!focus_change_listener_.get()) { | |
|
oshima
2011/01/27 19:58:33
You need to check GetWidget(). This assumes that t
varunjain
2011/01/27 23:01:38
GetWidget is checked inside GetFocusManager. I wil
| |
| 69 focus_change_listener_.reset(new TouchBrowserFocusChangeListener(this)); | |
| 70 GetFocusManager()->AddFocusChangeListener(focus_change_listener_.get()); | |
|
bryeung
2011/01/27 20:50:34
Related to oshima's point: GetFocusManager can ret
varunjain
2011/01/27 23:01:38
Done.
| |
| 71 } | |
| 72 } | |
| 73 | |
| 62 /////////////////////////////////////////////////////////////////////////////// | 74 /////////////////////////////////////////////////////////////////////////////// |
| 63 // TouchBrowserFrameView, private: | 75 // TouchBrowserFrameView, private: |
| 64 | 76 |
| 65 void TouchBrowserFrameView::InitVirtualKeyboard() { | 77 void TouchBrowserFrameView::InitVirtualKeyboard() { |
| 66 if (keyboard_) | 78 if (keyboard_) |
| 67 return; | 79 return; |
| 68 | 80 |
| 69 Profile* keyboard_profile = browser_view()->browser()->profile(); | 81 Profile* keyboard_profile = browser_view()->browser()->profile(); |
| 70 DCHECK(keyboard_profile) << "Profile required for virtual keyboard."; | 82 DCHECK(keyboard_profile) << "Profile required for virtual keyboard."; |
| 71 | 83 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 Source<RenderViewHost>(source).ptr()) | 123 Source<RenderViewHost>(source).ptr()) |
| 112 UpdateKeyboardAndLayout(*Details<const bool>(details).ptr()); | 124 UpdateKeyboardAndLayout(*Details<const bool>(details).ptr()); |
| 113 } else if (type == NotificationType::NAV_ENTRY_COMMITTED) { | 125 } else if (type == NotificationType::NAV_ENTRY_COMMITTED) { |
| 114 Browser* source_browser = Browser::GetBrowserForController( | 126 Browser* source_browser = Browser::GetBrowserForController( |
| 115 Source<NavigationController>(source).ptr(), NULL); | 127 Source<NavigationController>(source).ptr(), NULL); |
| 116 // If the Browser for the keyboard has navigated, hide the keyboard. | 128 // If the Browser for the keyboard has navigated, hide the keyboard. |
| 117 if (source_browser == browser) | 129 if (source_browser == browser) |
| 118 UpdateKeyboardAndLayout(false); | 130 UpdateKeyboardAndLayout(false); |
| 119 } | 131 } |
| 120 } | 132 } |
| 133 | |
| 134 /////////////////////////////////////////////////////////////////////////////// | |
| 135 // | |
| 136 // TouchBrowserFocusChangeListener | |
| 137 // | |
| 138 /////////////////////////////////////////////////////////////////////////////// | |
| 139 | |
| 140 TouchBrowserFrameView::TouchBrowserFocusChangeListener | |
| 141 ::TouchBrowserFocusChangeListener(TouchBrowserFrameView* browser_frame) | |
| 142 : touch_browser_frame_(browser_frame) { | |
| 143 } | |
| 144 | |
| 145 void TouchBrowserFrameView::TouchBrowserFocusChangeListener::FocusWillChange( | |
| 146 views::View* focused_before, views::View* focused_now) { | |
| 147 if (!focused_before || (focused_now && focused_now->GetVirtualKeyboardType() | |
|
oshima
2011/01/27 19:58:33
moving the "(forcusd_now && .." to next line would
varunjain
2011/01/27 23:01:38
Done.
| |
| 148 != focused_before->GetVirtualKeyboardType())) { | |
| 149 // TODO: support other types of keyboard. | |
| 150 touch_browser_frame_->UpdateKeyboardAndLayout( | |
| 151 focused_now->GetVirtualKeyboardType() == views::View::REGULAR_KEYBOARD); | |
| 152 } | |
| 153 } | |
| OLD | NEW |