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

Side by Side Diff: chrome/browser/ui/touch/frame/touch_browser_frame_view.cc

Issue 6384004: Browser should get notified if a views textfield changes focus. In addition, (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Minor changes that were missed in last patch Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
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 17 matching lines...) Expand all
28 28
29 } // namespace 29 } // namespace
30 30
31 /////////////////////////////////////////////////////////////////////////////// 31 ///////////////////////////////////////////////////////////////////////////////
32 // TouchBrowserFrameView, public: 32 // TouchBrowserFrameView, public:
33 33
34 TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame, 34 TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame,
35 BrowserView* browser_view) 35 BrowserView* browser_view)
36 : OpaqueBrowserFrameView(frame, browser_view), 36 : OpaqueBrowserFrameView(frame, browser_view),
37 keyboard_showing_(false), 37 keyboard_showing_(false),
38 keyboard_(NULL) { 38 keyboard_(NULL),
39 focus_listener_added_(false) {
39 registrar_.Add(this, 40 registrar_.Add(this,
40 NotificationType::NAV_ENTRY_COMMITTED, 41 NotificationType::NAV_ENTRY_COMMITTED,
41 NotificationService::AllSources()); 42 NotificationService::AllSources());
42 registrar_.Add(this, 43 registrar_.Add(this,
43 NotificationType::FOCUS_CHANGED_IN_PAGE, 44 NotificationType::FOCUS_CHANGED_IN_PAGE,
44 NotificationService::AllSources()); 45 NotificationService::AllSources());
45 registrar_.Add(this, 46 registrar_.Add(this,
46 NotificationType::TAB_CONTENTS_DESTROYED, 47 NotificationType::TAB_CONTENTS_DESTROYED,
47 NotificationService::AllSources()); 48 NotificationService::AllSources());
48 49
49 browser_view->browser()->tabstrip_model()->AddObserver(this); 50 browser_view->browser()->tabstrip_model()->AddObserver(this);
50 } 51 }
51 52
52 TouchBrowserFrameView::~TouchBrowserFrameView() { 53 TouchBrowserFrameView::~TouchBrowserFrameView() {
54 if (focus_listener_added_ && GetFocusManager()) {
55 GetFocusManager()->RemoveFocusChangeListener(this);
56 }
oshima 2011/01/27 23:39:09 no {} for single line condition.
varunjain 2011/01/28 01:55:57 moved removing the focus listener to ViewHierarchy
53 browser_view()->browser()->tabstrip_model()->RemoveObserver(this); 57 browser_view()->browser()->tabstrip_model()->RemoveObserver(this);
54 } 58 }
55 59
56 void TouchBrowserFrameView::Layout() { 60 void TouchBrowserFrameView::Layout() {
57 OpaqueBrowserFrameView::Layout(); 61 OpaqueBrowserFrameView::Layout();
58 62
59 if (!keyboard_) 63 if (!keyboard_)
60 return; 64 return;
61 65
62 keyboard_->SetVisible(keyboard_showing_); 66 keyboard_->SetVisible(keyboard_showing_);
63 keyboard_->SetBounds(GetBoundsForReservedArea()); 67 keyboard_->SetBounds(GetBoundsForReservedArea());
64 } 68 }
65 69
70 void TouchBrowserFrameView::FocusWillChange(views::View* focused_before,
71 views::View* focused_now) {
72 if (!focused_before ||
73 (focused_now && focused_now->GetContentType()
74 != focused_before->GetContentType())) {
75 // TODO: support other types of keyboard.
76 UpdateKeyboardAndLayout(
77 focused_now->GetContentType() == views::View::GENERIC_INPUT);
78 }
79 }
80
66 /////////////////////////////////////////////////////////////////////////////// 81 ///////////////////////////////////////////////////////////////////////////////
67 // TouchBrowserFrameView, protected: 82 // TouchBrowserFrameView, protected:
68 int TouchBrowserFrameView::GetReservedHeight() const { 83 int TouchBrowserFrameView::GetReservedHeight() const {
69 if (keyboard_showing_) 84 if (keyboard_showing_)
70 return kKeyboardHeight; 85 return kKeyboardHeight;
71 86
72 return 0; 87 return 0;
73 } 88 }
74 89
90 void TouchBrowserFrameView::ViewHierarchyChanged(bool is_add,
91 View* parent,
92 View* child) {
93 OpaqueBrowserFrameView::ViewHierarchyChanged(is_add, parent, child);
94 if (!focus_listener_added_ && GetFocusManager()) {
95 GetFocusManager()->AddFocusChangeListener(this);
96 focus_listener_added_ = true;
97 }
98 }
99
75 /////////////////////////////////////////////////////////////////////////////// 100 ///////////////////////////////////////////////////////////////////////////////
76 // TouchBrowserFrameView, private: 101 // TouchBrowserFrameView, private:
77 102
78 void TouchBrowserFrameView::InitVirtualKeyboard() { 103 void TouchBrowserFrameView::InitVirtualKeyboard() {
79 if (keyboard_) 104 if (keyboard_)
80 return; 105 return;
81 106
82 Profile* keyboard_profile = browser_view()->browser()->profile(); 107 Profile* keyboard_profile = browser_view()->browser()->profile();
83 DCHECK(keyboard_profile) << "Profile required for virtual keyboard."; 108 DCHECK(keyboard_profile) << "Profile required for virtual keyboard.";
84 109
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 Browser* source_browser = Browser::GetBrowserForController( 170 Browser* source_browser = Browser::GetBrowserForController(
146 Source<NavigationController>(source).ptr(), NULL); 171 Source<NavigationController>(source).ptr(), NULL);
147 // If the Browser for the keyboard has navigated, hide the keyboard. 172 // If the Browser for the keyboard has navigated, hide the keyboard.
148 if (source_browser == browser) 173 if (source_browser == browser)
149 UpdateKeyboardAndLayout(false); 174 UpdateKeyboardAndLayout(false);
150 } else if (type == NotificationType::TAB_CONTENTS_DESTROYED) { 175 } else if (type == NotificationType::TAB_CONTENTS_DESTROYED) {
151 GetFocusedStateAccessor()->DeleteProperty( 176 GetFocusedStateAccessor()->DeleteProperty(
152 Source<TabContents>(source).ptr()->property_bag()); 177 Source<TabContents>(source).ptr()->property_bag());
153 } 178 }
154 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698