OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ |
6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ | 6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 class Image; | 30 class Image; |
31 class Rect; | 31 class Rect; |
32 } | 32 } |
33 | 33 |
34 class OmniboxEditModel : public AutocompleteControllerDelegate { | 34 class OmniboxEditModel : public AutocompleteControllerDelegate { |
35 public: | 35 public: |
36 struct State { | 36 struct State { |
37 State(bool user_input_in_progress, | 37 State(bool user_input_in_progress, |
38 const string16& user_text, | 38 const string16& user_text, |
39 const string16& keyword, | 39 const string16& keyword, |
40 bool is_keyword_hint); | 40 bool is_keyword_hint, |
41 bool is_focus_visible); | |
41 ~State(); | 42 ~State(); |
42 | 43 |
43 bool user_input_in_progress; | 44 bool user_input_in_progress; |
44 const string16 user_text; | 45 const string16 user_text; |
45 const string16 keyword; | 46 const string16 keyword; |
46 const bool is_keyword_hint; | 47 const bool is_keyword_hint; |
48 const bool is_focus_visible; | |
47 }; | 49 }; |
48 | 50 |
49 OmniboxEditModel(OmniboxView* view, | 51 OmniboxEditModel(OmniboxView* view, |
50 OmniboxEditController* controller, | 52 OmniboxEditController* controller, |
51 Profile* profile); | 53 Profile* profile); |
52 virtual ~OmniboxEditModel(); | 54 virtual ~OmniboxEditModel(); |
53 | 55 |
54 AutocompleteController* autocomplete_controller() const { | 56 AutocompleteController* autocomplete_controller() const { |
55 return autocomplete_controller_.get(); | 57 return autocomplete_controller_.get(); |
56 } | 58 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 void AcceptInput(WindowOpenDisposition disposition, | 185 void AcceptInput(WindowOpenDisposition disposition, |
184 bool for_drop); | 186 bool for_drop); |
185 | 187 |
186 // Asks the browser to load the item at |index|, with the given properties. | 188 // Asks the browser to load the item at |index|, with the given properties. |
187 void OpenMatch(const AutocompleteMatch& match, | 189 void OpenMatch(const AutocompleteMatch& match, |
188 WindowOpenDisposition disposition, | 190 WindowOpenDisposition disposition, |
189 const GURL& alternate_nav_url, | 191 const GURL& alternate_nav_url, |
190 size_t index); | 192 size_t index); |
191 | 193 |
192 bool has_focus() const { return has_focus_; } | 194 bool has_focus() const { return has_focus_; } |
193 | 195 |
Peter Kasting
2012/12/04 02:00:52
Nit: Blank line unnecessary
samarth
2012/12/04 04:55:35
Done.
| |
196 bool is_focus_visible() const { return is_focus_visible_; } | |
197 | |
194 // Accessors for keyword-related state (see comments on keyword_ and | 198 // Accessors for keyword-related state (see comments on keyword_ and |
195 // is_keyword_hint_). | 199 // is_keyword_hint_). |
196 const string16& keyword() const { return keyword_; } | 200 const string16& keyword() const { return keyword_; } |
197 bool is_keyword_hint() const { return is_keyword_hint_; } | 201 bool is_keyword_hint() const { return is_keyword_hint_; } |
198 | 202 |
199 // Accepts the current keyword hint as a keyword. It always returns true for | 203 // Accepts the current keyword hint as a keyword. It always returns true for |
200 // caller convenience. | 204 // caller convenience. |
201 bool AcceptKeyword(); | 205 bool AcceptKeyword(); |
202 | 206 |
203 // Clears the current keyword. |visible_text| is the (non-keyword) text | 207 // Clears the current keyword. |visible_text| is the (non-keyword) text |
204 // currently visible in the edit. | 208 // currently visible in the edit. |
205 void ClearKeyword(const string16& visible_text); | 209 void ClearKeyword(const string16& visible_text); |
206 | 210 |
207 // Returns the current autocomplete result. This logic should in the future | 211 // Returns the current autocomplete result. This logic should in the future |
208 // live in AutocompleteController but resides here for now. This method is | 212 // live in AutocompleteController but resides here for now. This method is |
209 // used by AutomationProvider::AutocompleteEditGetMatches. | 213 // used by AutomationProvider::AutocompleteEditGetMatches. |
210 const AutocompleteResult& result() const; | 214 const AutocompleteResult& result() const; |
211 | 215 |
212 // Called when the view is gaining focus. |control_down| is whether the | 216 // Called when the view is gaining focus. |control_down| is whether the |
213 // control key is down (at the time we're gaining focus). | 217 // control key is down (at the time we're gaining focus). |
214 void OnSetFocus(bool control_down); | 218 void OnSetFocus(bool control_down); |
215 | 219 |
220 // Sets the visibility of omnibox focus. Does not impact whether the omnibox | |
221 // currently has focus or not. | |
Peter Kasting
2012/12/04 02:00:52
Nit: Add note like "This setting will be reset to
samarth
2012/12/04 04:55:35
Done.
| |
222 void SetFocusVisibility(bool visible); | |
223 | |
216 // Sent before |OnKillFocus| and before the popup is closed. | 224 // Sent before |OnKillFocus| and before the popup is closed. |
217 void OnWillKillFocus(gfx::NativeView view_gaining_focus); | 225 void OnWillKillFocus(gfx::NativeView view_gaining_focus); |
218 | 226 |
219 // Called when the view is losing focus. Resets some state. | 227 // Called when the view is losing focus. Resets some state. |
220 void OnKillFocus(); | 228 void OnKillFocus(); |
221 | 229 |
222 // Called when the user presses the escape key. Decides what, if anything, to | 230 // Called when the user presses the escape key. Decides what, if anything, to |
223 // revert about any current edits. Returns whether the key was handled. | 231 // revert about any current edits. Returns whether the key was handled. |
224 bool OnEscapeKeyPressed(); | 232 bool OnEscapeKeyPressed(); |
225 | 233 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 | 405 |
398 OmniboxView* view_; | 406 OmniboxView* view_; |
399 | 407 |
400 OmniboxPopupModel* popup_; | 408 OmniboxPopupModel* popup_; |
401 | 409 |
402 OmniboxEditController* controller_; | 410 OmniboxEditController* controller_; |
403 | 411 |
404 // Whether the edit has focus. | 412 // Whether the edit has focus. |
405 bool has_focus_; | 413 bool has_focus_; |
406 | 414 |
415 // Will the focus be visible? Note that this does NOT describe whether the | |
416 // omnibox currently has focus, only whether focusing will be visible when it | |
417 // is focused. | |
418 bool is_focus_visible_; | |
419 | |
407 // The URL of the currently displayed page. | 420 // The URL of the currently displayed page. |
408 string16 permanent_text_; | 421 string16 permanent_text_; |
409 | 422 |
410 // This flag is true when the user has modified the contents of the edit, but | 423 // This flag is true when the user has modified the contents of the edit, but |
411 // not yet accepted them. We use this to determine when we need to save | 424 // not yet accepted them. We use this to determine when we need to save |
412 // state (on switching tabs) and whether changes to the page URL should be | 425 // state (on switching tabs) and whether changes to the page URL should be |
413 // immediately displayed. | 426 // immediately displayed. |
414 // This flag will be true in a superset of the cases where the popup is open. | 427 // This flag will be true in a superset of the cases where the popup is open. |
415 bool user_input_in_progress_; | 428 bool user_input_in_progress_; |
416 | 429 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 // an exact keyword match. If this is true then keyword mode will be | 517 // an exact keyword match. If this is true then keyword mode will be |
505 // triggered automatically if the input is "<keyword> <search string>". We | 518 // triggered automatically if the input is "<keyword> <search string>". We |
506 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. | 519 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. |
507 // This has no effect if we're already in keyword mode. | 520 // This has no effect if we're already in keyword mode. |
508 bool allow_exact_keyword_match_; | 521 bool allow_exact_keyword_match_; |
509 | 522 |
510 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); | 523 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); |
511 }; | 524 }; |
512 | 525 |
513 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ | 526 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ |
OLD | NEW |