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

Side by Side Diff: chrome/browser/ui/views/find_bar_view.h

Issue 13852009: Replace find bar RequestFocus override with OnFocus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a comment about select_all_on_focus_. Created 7 years, 8 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 | « no previous file | chrome/browser/ui/views/find_bar_view.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/ui/views/dropdown_bar_view.h" 10 #include "chrome/browser/ui/views/dropdown_bar_view.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 virtual void ContentsChanged(views::Textfield* sender, 80 virtual void ContentsChanged(views::Textfield* sender,
81 const string16& new_contents) OVERRIDE; 81 const string16& new_contents) OVERRIDE;
82 virtual bool HandleKeyEvent(views::Textfield* sender, 82 virtual bool HandleKeyEvent(views::Textfield* sender,
83 const ui::KeyEvent& key_event) OVERRIDE; 83 const ui::KeyEvent& key_event) OVERRIDE;
84 virtual void OnAfterCutOrCopy() OVERRIDE; 84 virtual void OnAfterCutOrCopy() OVERRIDE;
85 85
86 private: 86 private:
87 // Update the appearance for the match count label. 87 // Update the appearance for the match count label.
88 void UpdateMatchCountAppearance(bool no_match); 88 void UpdateMatchCountAppearance(bool no_match);
89 89
90 // Overridden from views::View. 90 // views::View:
91 virtual void OnThemeChanged() OVERRIDE; 91 virtual void OnThemeChanged() OVERRIDE;
92 92
93 // We use a hidden view to grab mouse clicks and bring focus to the find 93 // We use a hidden view to grab mouse clicks and bring focus to the find
94 // text box. This is because although the find text box may look like it 94 // text box. This is because although the find text box may look like it
95 // extends all the way to the find button, it only goes as far as to the 95 // extends all the way to the find button, it only goes as far as to the
96 // match_count label. The user, however, expects being able to click anywhere 96 // match_count label. The user, however, expects being able to click anywhere
97 // inside what looks like the find text box (including on or around the 97 // inside what looks like the find text box (including on or around the
98 // match_count label) and have focus brought to the find box. 98 // match_count label) and have focus brought to the find box.
99 class FocusForwarderView : public views::View { 99 class FocusForwarderView : public views::View {
100 public: 100 public:
101 explicit FocusForwarderView( 101 explicit FocusForwarderView(
102 views::Textfield* view_to_focus_on_mousedown) 102 views::Textfield* view_to_focus_on_mousedown)
103 : view_to_focus_on_mousedown_(view_to_focus_on_mousedown) {} 103 : view_to_focus_on_mousedown_(view_to_focus_on_mousedown) {}
104 104
105 private: 105 private:
106 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; 106 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
107 107
108 views::Textfield* view_to_focus_on_mousedown_; 108 views::Textfield* view_to_focus_on_mousedown_;
109 109
110 DISALLOW_COPY_AND_ASSIGN(FocusForwarderView); 110 DISALLOW_COPY_AND_ASSIGN(FocusForwarderView);
111 }; 111 };
112 112
113 // A wrapper of views::TextField that allows us to select all text when we 113 // A wrapper of views::TextField that allows us to select all text when we
114 // get focus. Represents the text field where the user enters a search term. 114 // get focus. Represents the text field where the user enters a search term.
115 class SearchTextfieldView : public views::Textfield { 115 class SearchTextfieldView : public views::Textfield {
116 public: 116 public:
117 SearchTextfieldView(); 117 SearchTextfieldView();
118 virtual ~SearchTextfieldView(); 118 virtual ~SearchTextfieldView();
119 119
120 virtual void RequestFocus() OVERRIDE; 120 // views::View:
121 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
122 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
123
124 // views::Textfield:
125 virtual void OnFocus() OVERRIDE;
121 126
122 private: 127 private:
128 bool select_all_on_focus_;
129
123 DISALLOW_COPY_AND_ASSIGN(SearchTextfieldView); 130 DISALLOW_COPY_AND_ASSIGN(SearchTextfieldView);
124 }; 131 };
125 132
126 // Returns the OS-specific view for the find bar that acts as an intermediary 133 // Returns the OS-specific view for the find bar that acts as an intermediary
127 // between us and the WebContentsView. 134 // between us and the WebContentsView.
128 FindBarHost* find_bar_host() const; 135 FindBarHost* find_bar_host() const;
129 136
130 // The controls in the window. 137 // The controls in the window.
131 SearchTextfieldView* find_text_; 138 SearchTextfieldView* find_text_;
132 views::Label* match_count_text_; 139 views::Label* match_count_text_;
133 FocusForwarderView* focus_forwarder_view_; 140 FocusForwarderView* focus_forwarder_view_;
134 views::ImageButton* find_previous_button_; 141 views::ImageButton* find_previous_button_;
135 views::ImageButton* find_next_button_; 142 views::ImageButton* find_next_button_;
136 views::ImageButton* close_button_; 143 views::ImageButton* close_button_;
137 144
138 // The preferred height of the find bar. 145 // The preferred height of the find bar.
139 int preferred_height_; 146 int preferred_height_;
140 147
141 // The background image for the Find text box, which we draw behind the Find 148 // The background image for the Find text box, which we draw behind the Find
142 // box to provide the Chrome look to the edge of the text box. 149 // box to provide the Chrome look to the edge of the text box.
143 const gfx::ImageSkia* text_box_background_; 150 const gfx::ImageSkia* text_box_background_;
144 151
145 // The rounded edge on the left side of the Find text box. 152 // The rounded edge on the left side of the Find text box.
146 const gfx::ImageSkia* text_box_background_left_; 153 const gfx::ImageSkia* text_box_background_left_;
147 154
148 DISALLOW_COPY_AND_ASSIGN(FindBarView); 155 DISALLOW_COPY_AND_ASSIGN(FindBarView);
149 }; 156 };
150 157
151 #endif // CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_ 158 #endif // CHROME_BROWSER_UI_VIEWS_FIND_BAR_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/find_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698