| 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_caret_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_caret_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_; } |
| 195 bool is_caret_visible() const { return is_caret_visible_; } |
| 193 | 196 |
| 194 // Accessors for keyword-related state (see comments on keyword_ and | 197 // Accessors for keyword-related state (see comments on keyword_ and |
| 195 // is_keyword_hint_). | 198 // is_keyword_hint_). |
| 196 const string16& keyword() const { return keyword_; } | 199 const string16& keyword() const { return keyword_; } |
| 197 bool is_keyword_hint() const { return is_keyword_hint_; } | 200 bool is_keyword_hint() const { return is_keyword_hint_; } |
| 198 | 201 |
| 199 // Accepts the current keyword hint as a keyword. It always returns true for | 202 // Accepts the current keyword hint as a keyword. It always returns true for |
| 200 // caller convenience. | 203 // caller convenience. |
| 201 bool AcceptKeyword(); | 204 bool AcceptKeyword(); |
| 202 | 205 |
| 203 // Clears the current keyword. |visible_text| is the (non-keyword) text | 206 // Clears the current keyword. |visible_text| is the (non-keyword) text |
| 204 // currently visible in the edit. | 207 // currently visible in the edit. |
| 205 void ClearKeyword(const string16& visible_text); | 208 void ClearKeyword(const string16& visible_text); |
| 206 | 209 |
| 207 // Returns the current autocomplete result. This logic should in the future | 210 // Returns the current autocomplete result. This logic should in the future |
| 208 // live in AutocompleteController but resides here for now. This method is | 211 // live in AutocompleteController but resides here for now. This method is |
| 209 // used by AutomationProvider::AutocompleteEditGetMatches. | 212 // used by AutomationProvider::AutocompleteEditGetMatches. |
| 210 const AutocompleteResult& result() const; | 213 const AutocompleteResult& result() const; |
| 211 | 214 |
| 212 // Called when the view is gaining focus. |control_down| is whether the | 215 // Called when the view is gaining focus. |control_down| is whether the |
| 213 // control key is down (at the time we're gaining focus). | 216 // control key is down (at the time we're gaining focus). |
| 214 void OnSetFocus(bool control_down); | 217 void OnSetFocus(bool control_down); |
| 215 | 218 |
| 219 // Sets the visibility of the caret in the omnibox, if it has focus. The |
| 220 // visibility of the caret is reset (to visible) if the omnibox loses focus or |
| 221 // if it is explicitly given focus again. Caret visibility is tracked per-tab |
| 222 // and updates automatically upon switching tabs. |
| 223 void SetCaretVisibility(bool visible); |
| 224 |
| 216 // Sent before |OnKillFocus| and before the popup is closed. | 225 // Sent before |OnKillFocus| and before the popup is closed. |
| 217 void OnWillKillFocus(gfx::NativeView view_gaining_focus); | 226 void OnWillKillFocus(gfx::NativeView view_gaining_focus); |
| 218 | 227 |
| 219 // Called when the view is losing focus. Resets some state. | 228 // Called when the view is losing focus. Resets some state. |
| 220 void OnKillFocus(); | 229 void OnKillFocus(); |
| 221 | 230 |
| 222 // Called when the user presses the escape key. Decides what, if anything, to | 231 // 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. | 232 // revert about any current edits. Returns whether the key was handled. |
| 224 bool OnEscapeKeyPressed(); | 233 bool OnEscapeKeyPressed(); |
| 225 | 234 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 406 |
| 398 OmniboxView* view_; | 407 OmniboxView* view_; |
| 399 | 408 |
| 400 OmniboxPopupModel* popup_; | 409 OmniboxPopupModel* popup_; |
| 401 | 410 |
| 402 OmniboxEditController* controller_; | 411 OmniboxEditController* controller_; |
| 403 | 412 |
| 404 // Whether the edit has focus. | 413 // Whether the edit has focus. |
| 405 bool has_focus_; | 414 bool has_focus_; |
| 406 | 415 |
| 416 // Is the caret visible? Only meaningful if has_focus_ is true. |
| 417 bool is_caret_visible_; |
| 418 |
| 407 // The URL of the currently displayed page. | 419 // The URL of the currently displayed page. |
| 408 string16 permanent_text_; | 420 string16 permanent_text_; |
| 409 | 421 |
| 410 // This flag is true when the user has modified the contents of the edit, but | 422 // 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 | 423 // 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 | 424 // state (on switching tabs) and whether changes to the page URL should be |
| 413 // immediately displayed. | 425 // immediately displayed. |
| 414 // This flag will be true in a superset of the cases where the popup is open. | 426 // This flag will be true in a superset of the cases where the popup is open. |
| 415 bool user_input_in_progress_; | 427 bool user_input_in_progress_; |
| 416 | 428 |
| (...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 | 516 // an exact keyword match. If this is true then keyword mode will be |
| 505 // triggered automatically if the input is "<keyword> <search string>". We | 517 // triggered automatically if the input is "<keyword> <search string>". We |
| 506 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. | 518 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. |
| 507 // This has no effect if we're already in keyword mode. | 519 // This has no effect if we're already in keyword mode. |
| 508 bool allow_exact_keyword_match_; | 520 bool allow_exact_keyword_match_; |
| 509 | 521 |
| 510 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); | 522 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); |
| 511 }; | 523 }; |
| 512 | 524 |
| 513 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ | 525 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ |
| OLD | NEW |