Chromium Code Reviews| Index: chrome/browser/ui/omnibox/omnibox_edit_model.h |
| diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.h b/chrome/browser/ui/omnibox/omnibox_edit_model.h |
| index f8444f67bb086fe528660a87a103a257bdf3e1f8..bf69bc5504d816149ad9b66434b229c7be3a02dd 100644 |
| --- a/chrome/browser/ui/omnibox/omnibox_edit_model.h |
| +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.h |
| @@ -12,6 +12,7 @@ |
| #include "base/time.h" |
| #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
| #include "chrome/browser/autocomplete/autocomplete_match.h" |
| +#include "chrome/browser/ui/omnibox/omnibox_types.h" |
| #include "chrome/common/metrics/proto/omnibox_event.pb.h" |
| #include "content/public/common/page_transition_types.h" |
| #include "googleurl/src/gurl.h" |
| @@ -38,14 +39,14 @@ class OmniboxEditModel : public AutocompleteControllerDelegate { |
| const string16& user_text, |
| const string16& keyword, |
| bool is_keyword_hint, |
| - bool is_caret_visible); |
| + OmniboxFocusState focus_state); |
| ~State(); |
| bool user_input_in_progress; |
| const string16 user_text; |
| const string16 keyword; |
| const bool is_keyword_hint; |
| - const bool is_caret_visible; |
| + OmniboxFocusState focus_state; |
| }; |
| OmniboxEditModel(OmniboxView* view, |
| @@ -191,8 +192,11 @@ class OmniboxEditModel : public AutocompleteControllerDelegate { |
| const GURL& alternate_nav_url, |
| size_t index); |
| - bool has_focus() const { return has_focus_; } |
| - bool is_caret_visible() const { return is_caret_visible_; } |
| + OmniboxFocusState focus_state() const { return focus_state_; } |
| + bool has_focus() const { return focus_state_ != OMNIBOX_FOCUS_NONE; } |
| + bool is_caret_visible() const { |
| + return focus_state_ == OMNIBOX_FOCUS_VISIBLE; |
| + } |
|
Peter Kasting
2012/12/11 19:20:50
Normally I would not provide the has_focus() and i
samarth
2012/12/12 01:11:26
I left these in because I thought it made the call
Peter Kasting
2012/12/12 01:21:42
OK.
|
| // Accessors for keyword-related state (see comments on keyword_ and |
| // is_keyword_hint_). |
| @@ -217,12 +221,13 @@ class OmniboxEditModel : public AutocompleteControllerDelegate { |
| void OnSetFocus(bool control_down); |
| // Sets the visibility of the caret in the omnibox, if it has focus. The |
| - // visibility of the caret is reset to visible if any of the following |
| - // happens: |
| - // - User starts typing in the omnibox |
| - // - User clicks in the omnibox |
| - // - Omnibox loses and then regains focus |
| - // - SetFocus() is explicitly called again |
| + // visibility of the caret is reset to visible if either |
| + // - The user starts typing, or |
| + // - We explicitly focus the omnibox again. |
| + // The latter case must be handled in three separate places--OnSetFocus(), |
| + // OmniboxView::SetFocus(), and the mouse handlers in OmniboxView. See |
| + // accompanying comments for why each of these is necessary. |
| + // |
| // Caret visibility is tracked per-tab and updates automatically upon |
| // switching tabs. |
| void SetCaretVisibility(bool visible); |
| @@ -407,6 +412,12 @@ class OmniboxEditModel : public AutocompleteControllerDelegate { |
| AutocompleteMatch* match, |
| GURL* alternate_nav_url) const; |
| + // If focus_state_ does not match |state|, we update it and notify the |
| + // InstantController about the change (passing along the |reason| for the |
| + // change). If the caret visibility changes, we call ApplyCaretVisibility() on |
| + // the view. |
| + void SetFocusState(OmniboxFocusState state, OmniboxFocusChangeReason reason); |
| + |
| scoped_ptr<AutocompleteController> autocomplete_controller_; |
| OmniboxView* view_; |
| @@ -415,11 +426,7 @@ class OmniboxEditModel : public AutocompleteControllerDelegate { |
| OmniboxEditController* controller_; |
| - // Whether the edit has focus. |
| - bool has_focus_; |
| - |
| - // Is the caret visible? Only meaningful if has_focus_ is true. |
| - bool is_caret_visible_; |
| + OmniboxFocusState focus_state_; |
| // The URL of the currently displayed page. |
| string16 permanent_text_; |