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

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

Issue 7783002: touchui: Some cleanup for managing keyboard visibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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
« no previous file with comments | « chrome/browser/ui/touch/frame/touch_browser_frame_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/touch/keyboard/keyboard_manager.h" 7 #include "chrome/browser/ui/touch/keyboard/keyboard_manager.h"
8 #include "ui/base/ime/text_input_type.h"
9 #include "views/controls/button/image_button.h" 8 #include "views/controls/button/image_button.h"
10 #include "views/controls/textfield/textfield.h"
11 #include "views/focus/focus_manager.h"
12 #include "views/ime/text_input_client.h"
13 9
14 // static 10 // static
15 const char TouchBrowserFrameView::kViewClassName[] = 11 const char TouchBrowserFrameView::kViewClassName[] =
16 "browser/ui/touch/frame/TouchBrowserFrameView"; 12 "browser/ui/touch/frame/TouchBrowserFrameView";
17 13
18 /////////////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////////////
19 // TouchBrowserFrameView, public: 15 // TouchBrowserFrameView, public:
20 16
21 TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame, 17 TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame,
22 BrowserView* browser_view) 18 BrowserView* browser_view)
23 : OpaqueBrowserFrameView(frame, browser_view), 19 : OpaqueBrowserFrameView(frame, browser_view) {
24 focus_listener_added_(false) {
25 // Make sure the singleton KeyboardManager object is initialized. 20 // Make sure the singleton KeyboardManager object is initialized.
26 KeyboardManager::GetInstance(); 21 KeyboardManager::GetInstance();
27 } 22 }
28 23
29 TouchBrowserFrameView::~TouchBrowserFrameView() { 24 TouchBrowserFrameView::~TouchBrowserFrameView() {
30 } 25 }
31 26
32 ///////////////////////////////////////////////////////////////////////////////
33 // TouchBrowserFrameView, private:
34
35 void TouchBrowserFrameView::FocusWillChange(views::View* focused_before,
36 views::View* focused_now) {
37 views::Widget* widget = focused_now ? focused_now->GetWidget() : NULL;
38 if (!widget || !widget->IsActive())
39 return;
40
41 views::TextInputClient* input =
42 focused_now ? focused_now->GetTextInputClient() : NULL;
43 // Show the keyboard if the focused view supports text-input.
44 KeyboardManager* keyboard = KeyboardManager::GetInstance();
45 if (input && input->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE)
46 keyboard->ShowKeyboardForWidget(focused_now->GetWidget());
47 else
48 keyboard->Hide();
49 }
50
51 std::string TouchBrowserFrameView::GetClassName() const { 27 std::string TouchBrowserFrameView::GetClassName() const {
52 return kViewClassName; 28 return kViewClassName;
53 } 29 }
54 30
55 void TouchBrowserFrameView::ViewHierarchyChanged(bool is_add,
56 View* parent,
57 View* child) {
58 OpaqueBrowserFrameView::ViewHierarchyChanged(is_add, parent, child);
59 if (!GetFocusManager())
60 return;
61
62 if (is_add && !focus_listener_added_) {
63 // Add focus listener when this view is added to the hierarchy.
64 GetFocusManager()->AddFocusChangeListener(this);
65 focus_listener_added_ = true;
66 } else if (!is_add && focus_listener_added_) {
67 // Remove focus listener when this view is removed from the hierarchy.
68 GetFocusManager()->RemoveFocusChangeListener(this);
69 focus_listener_added_ = false;
70 }
71 }
72
73 bool TouchBrowserFrameView::HitTest(const gfx::Point& point) const { 31 bool TouchBrowserFrameView::HitTest(const gfx::Point& point) const {
74 if (OpaqueBrowserFrameView::HitTest(point)) 32 if (OpaqueBrowserFrameView::HitTest(point))
75 return true; 33 return true;
76 34
77 if (close_button()->IsVisible() && 35 if (close_button()->IsVisible() &&
78 close_button()->GetMirroredBounds().Contains(point)) 36 close_button()->GetMirroredBounds().Contains(point))
79 return true; 37 return true;
80 if (restore_button()->IsVisible() && 38 if (restore_button()->IsVisible() &&
81 restore_button()->GetMirroredBounds().Contains(point)) 39 restore_button()->GetMirroredBounds().Contains(point))
82 return true; 40 return true;
83 if (maximize_button()->IsVisible() && 41 if (maximize_button()->IsVisible() &&
84 maximize_button()->GetMirroredBounds().Contains(point)) 42 maximize_button()->GetMirroredBounds().Contains(point))
85 return true; 43 return true;
86 if (minimize_button()->IsVisible() && 44 if (minimize_button()->IsVisible() &&
87 minimize_button()->GetMirroredBounds().Contains(point)) 45 minimize_button()->GetMirroredBounds().Contains(point))
88 return true; 46 return true;
89 47
90 return false; 48 return false;
91 } 49 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/touch/frame/touch_browser_frame_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698