OLD | NEW |
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_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 12 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
13 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 13 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
14 #include "ui/base/range/range.h" | 14 #include "ui/base/range/range.h" |
15 #include "ui/views/controls/textfield/textfield_controller.h" | 15 #include "ui/views/controls/textfield/textfield_controller.h" |
16 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
17 #include "webkit/glue/window_open_disposition.h" | 17 #include "webkit/glue/window_open_disposition.h" |
18 | 18 |
19 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
20 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 20 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
21 #endif | 21 #endif |
22 | 22 |
23 class LocationBarView; | 23 class LocationBarView; |
24 class OmniboxEditController; | |
25 class OmniboxEditModel; | |
26 class OmniboxPopupView; | 24 class OmniboxPopupView; |
27 class Profile; | 25 class Profile; |
28 | 26 |
29 namespace ui { | 27 namespace ui { |
30 class OSExchangeData; | 28 class OSExchangeData; |
31 } // namespace ui | 29 } // namespace ui |
32 | 30 |
33 // Views-implementation of OmniboxView. This is based on gtk implementation. | 31 // Views-implementation of OmniboxView. This is based on gtk implementation. |
34 // The following features are not yet supported. | 32 // The following features are not yet supported. |
35 // | 33 // |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // the root view. | 85 // the root view. |
88 bool IsLocationEntryFocusableInRootView() const; | 86 bool IsLocationEntryFocusableInRootView() const; |
89 | 87 |
90 // Implements views::View | 88 // Implements views::View |
91 virtual void Layout() OVERRIDE; | 89 virtual void Layout() OVERRIDE; |
92 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 90 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
93 virtual std::string GetClassName() const OVERRIDE; | 91 virtual std::string GetClassName() const OVERRIDE; |
94 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 92 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
95 | 93 |
96 // OmniboxView: | 94 // OmniboxView: |
97 virtual OmniboxEditModel* model() OVERRIDE; | |
98 virtual const OmniboxEditModel* model() const OVERRIDE; | |
99 virtual void SaveStateToTab(content::WebContents* tab) OVERRIDE; | 95 virtual void SaveStateToTab(content::WebContents* tab) OVERRIDE; |
100 virtual void Update( | 96 virtual void Update( |
101 const content::WebContents* tab_for_state_restoring) OVERRIDE; | 97 const content::WebContents* tab_for_state_restoring) OVERRIDE; |
102 virtual void OpenMatch(const AutocompleteMatch& match, | |
103 WindowOpenDisposition disposition, | |
104 const GURL& alternate_nav_url, | |
105 size_t selected_line) OVERRIDE; | |
106 virtual string16 GetText() const OVERRIDE; | 98 virtual string16 GetText() const OVERRIDE; |
107 virtual bool IsEditingOrEmpty() const OVERRIDE; | |
108 virtual int GetIcon() const OVERRIDE; | |
109 virtual void SetUserText(const string16& text) OVERRIDE; | |
110 virtual void SetUserText(const string16& text, | |
111 const string16& display_text, | |
112 bool update_popup) OVERRIDE; | |
113 virtual void SetWindowTextAndCaretPos(const string16& text, | 99 virtual void SetWindowTextAndCaretPos(const string16& text, |
114 size_t caret_pos, | 100 size_t caret_pos, |
115 bool update_popup, | 101 bool update_popup, |
116 bool notify_text_changed) OVERRIDE; | 102 bool notify_text_changed) OVERRIDE; |
117 virtual void SetForcedQuery() OVERRIDE; | 103 virtual void SetForcedQuery() OVERRIDE; |
118 virtual bool IsSelectAll() const OVERRIDE; | 104 virtual bool IsSelectAll() const OVERRIDE; |
119 virtual bool DeleteAtEndPressed() OVERRIDE; | 105 virtual bool DeleteAtEndPressed() OVERRIDE; |
120 virtual void GetSelectionBounds(string16::size_type* start, | 106 virtual void GetSelectionBounds(string16::size_type* start, |
121 string16::size_type* end) const OVERRIDE; | 107 string16::size_type* end) const OVERRIDE; |
122 virtual void SelectAll(bool reversed) OVERRIDE; | 108 virtual void SelectAll(bool reversed) OVERRIDE; |
123 virtual void RevertAll() OVERRIDE; | |
124 virtual void UpdatePopup() OVERRIDE; | 109 virtual void UpdatePopup() OVERRIDE; |
125 virtual void ClosePopup() OVERRIDE; | |
126 virtual void SetFocus() OVERRIDE; | 110 virtual void SetFocus() OVERRIDE; |
127 virtual void OnTemporaryTextMaybeChanged( | 111 virtual void OnTemporaryTextMaybeChanged( |
128 const string16& display_text, | 112 const string16& display_text, |
129 bool save_original_selection) OVERRIDE; | 113 bool save_original_selection) OVERRIDE; |
130 virtual bool OnInlineAutocompleteTextMaybeChanged( | 114 virtual bool OnInlineAutocompleteTextMaybeChanged( |
131 const string16& display_text, size_t user_text_length) OVERRIDE; | 115 const string16& display_text, size_t user_text_length) OVERRIDE; |
132 virtual void OnRevertTemporaryText() OVERRIDE; | 116 virtual void OnRevertTemporaryText() OVERRIDE; |
133 virtual void OnBeforePossibleChange() OVERRIDE; | 117 virtual void OnBeforePossibleChange() OVERRIDE; |
134 virtual bool OnAfterPossibleChange() OVERRIDE; | 118 virtual bool OnAfterPossibleChange() OVERRIDE; |
135 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 119 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
136 virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE; | 120 virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE; |
137 virtual CommandUpdater* GetCommandUpdater() OVERRIDE; | |
138 virtual void SetInstantSuggestion(const string16& input, | 121 virtual void SetInstantSuggestion(const string16& input, |
139 bool animate_to_complete) OVERRIDE; | 122 bool animate_to_complete) OVERRIDE; |
140 virtual string16 GetInstantSuggestion() const OVERRIDE; | 123 virtual string16 GetInstantSuggestion() const OVERRIDE; |
141 virtual int TextWidth() const OVERRIDE; | 124 virtual int TextWidth() const OVERRIDE; |
142 virtual bool IsImeComposing() const OVERRIDE; | 125 virtual bool IsImeComposing() const OVERRIDE; |
143 virtual int GetMaxEditWidth(int entry_width) const OVERRIDE; | 126 virtual int GetMaxEditWidth(int entry_width) const OVERRIDE; |
144 virtual views::View* AddToView(views::View* parent) OVERRIDE; | 127 virtual views::View* AddToView(views::View* parent) OVERRIDE; |
145 virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE; | 128 virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE; |
146 virtual gfx::Font GetFont() OVERRIDE; | 129 virtual gfx::Font GetFont() OVERRIDE; |
147 virtual int WidthOfTextAfterCursor() OVERRIDE; | 130 virtual int WidthOfTextAfterCursor() OVERRIDE; |
(...skipping 16 matching lines...) Expand all Loading... |
164 #if defined(OS_CHROMEOS) | 147 #if defined(OS_CHROMEOS) |
165 // chromeos::input_method::InputMethodManager::CandidateWindowObserver: | 148 // chromeos::input_method::InputMethodManager::CandidateWindowObserver: |
166 virtual void CandidateWindowOpened( | 149 virtual void CandidateWindowOpened( |
167 chromeos::input_method::InputMethodManager* manager) OVERRIDE; | 150 chromeos::input_method::InputMethodManager* manager) OVERRIDE; |
168 virtual void CandidateWindowClosed( | 151 virtual void CandidateWindowClosed( |
169 chromeos::input_method::InputMethodManager* manager) OVERRIDE; | 152 chromeos::input_method::InputMethodManager* manager) OVERRIDE; |
170 #endif | 153 #endif |
171 | 154 |
172 private: | 155 private: |
173 // Return the number of characers in the current buffer. | 156 // Return the number of characers in the current buffer. |
| 157 virtual int GetOmniboxTextLength() const OVERRIDE; |
174 size_t GetTextLength() const; | 158 size_t GetTextLength() const; |
175 | 159 |
176 // Try to parse the current text as a URL and colorize the components. | 160 // Try to parse the current text as a URL and colorize the components. |
177 void EmphasizeURLComponents(); | 161 virtual void EmphasizeURLComponents() OVERRIDE; |
178 | |
179 // Internally invoked whenever the text changes in some way. | |
180 void TextChanged(); | |
181 | 162 |
182 // Update the field with |text| and set the selection. | 163 // Update the field with |text| and set the selection. |
183 void SetTextAndSelectedRange(const string16& text, | 164 void SetTextAndSelectedRange(const string16& text, |
184 const ui::Range& range); | 165 const ui::Range& range); |
185 | 166 |
186 // Returns the selected text. | 167 // Returns the selected text. |
187 string16 GetSelectedText() const; | 168 string16 GetSelectedText() const; |
188 | 169 |
189 views::Textfield* textfield_; | 170 views::Textfield* textfield_; |
190 | 171 |
191 // When true, the location bar view is read only and also is has a slightly | 172 // When true, the location bar view is read only and also is has a slightly |
192 // different presentation (smaller font size). This is used for popups. | 173 // different presentation (smaller font size). This is used for popups. |
193 bool popup_window_mode_; | 174 bool popup_window_mode_; |
194 | 175 |
195 scoped_ptr<OmniboxEditModel> model_; | |
196 scoped_ptr<OmniboxPopupView> popup_view_; | 176 scoped_ptr<OmniboxPopupView> popup_view_; |
197 OmniboxEditController* controller_; | |
198 ToolbarModel* toolbar_model_; | |
199 | |
200 // The object that handles additional command functionality exposed on the | |
201 // edit, such as invoking the keyword editor. | |
202 CommandUpdater* command_updater_; | |
203 | 177 |
204 ToolbarModel::SecurityLevel security_level_; | 178 ToolbarModel::SecurityLevel security_level_; |
205 | 179 |
206 // Selection at the point where the user started using the | 180 // Selection at the point where the user started using the |
207 // arrows to move around in the popup. | 181 // arrows to move around in the popup. |
208 ui::Range saved_temporary_selection_; | 182 ui::Range saved_temporary_selection_; |
209 | 183 |
210 // Tracking state before and after a possible change. | 184 // Tracking state before and after a possible change. |
211 string16 text_before_change_; | 185 string16 text_before_change_; |
212 ui::Range sel_before_change_; | 186 ui::Range sel_before_change_; |
(...skipping 11 matching lines...) Expand all Loading... |
224 // Should we select all the text when we see the mouse button get released? | 198 // Should we select all the text when we see the mouse button get released? |
225 // We select in response to a click that focuses the omnibox, but we defer | 199 // We select in response to a click that focuses the omnibox, but we defer |
226 // until release, setting this variable back to false if we saw a drag, to | 200 // until release, setting this variable back to false if we saw a drag, to |
227 // allow the user to select just a portion of the text. | 201 // allow the user to select just a portion of the text. |
228 bool select_all_on_mouse_release_; | 202 bool select_all_on_mouse_release_; |
229 | 203 |
230 DISALLOW_COPY_AND_ASSIGN(OmniboxViewViews); | 204 DISALLOW_COPY_AND_ASSIGN(OmniboxViewViews); |
231 }; | 205 }; |
232 | 206 |
233 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ | 207 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_ |
OLD | NEW |