| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CONTROLLER_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" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 12 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | 13 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 14 | 15 |
| 15 struct AutocompleteMatch; | 16 struct AutocompleteMatch; |
| 16 class AutocompleteResult; | 17 class AutocompleteResult; |
| 17 class GURL; | 18 class GURL; |
| 18 class InstantController; | 19 class InstantController; |
| 20 struct InstantSuggestion; |
| 19 class OmniboxEditModel; | 21 class OmniboxEditModel; |
| 20 class OmniboxPopupModel; | 22 class OmniboxPopupModel; |
| 21 class Profile; | 23 class Profile; |
| 22 | 24 |
| 23 namespace gfx { | 25 namespace gfx { |
| 24 class Rect; | 26 class Rect; |
| 25 } | 27 } |
| 26 | 28 |
| 27 // This class controls the various services that can modify the content | 29 // This class controls the various services that can modify the content |
| 28 // for the omnibox, including AutocompleteController and InstantController. It | 30 // for the omnibox, including AutocompleteController and InstantController. It |
| (...skipping 26 matching lines...) Expand all Loading... |
| 55 bool DoInstant(const AutocompleteMatch& match, | 57 bool DoInstant(const AutocompleteMatch& match, |
| 56 string16 user_text, | 58 string16 user_text, |
| 57 string16 full_text, | 59 string16 full_text, |
| 58 size_t selection_start, | 60 size_t selection_start, |
| 59 size_t selection_end, | 61 size_t selection_end, |
| 60 bool user_input_in_progress, | 62 bool user_input_in_progress, |
| 61 bool in_escape_handler, | 63 bool in_escape_handler, |
| 62 bool just_deleted_text, | 64 bool just_deleted_text, |
| 63 bool keyword_is_selected); | 65 bool keyword_is_selected); |
| 64 | 66 |
| 67 // Calls through to SearchProvider::FinalizeInstantQuery. |
| 68 void FinalizeInstantQuery(const string16& input_text, |
| 69 const InstantSuggestion& suggestion); |
| 70 |
| 71 // Sets the suggestion text. |
| 72 void SetInstantSuggestion(const InstantSuggestion& suggestion); |
| 73 |
| 74 // Set |current_match_| to an invalid value, indicating that we do not yet |
| 75 // have a valid match for the current text in the omnibox. |
| 76 void InvalidateCurrentMatch(); |
| 77 |
| 65 void set_popup_model(OmniboxPopupModel* popup_model) { | 78 void set_popup_model(OmniboxPopupModel* popup_model) { |
| 66 popup_ = popup_model; | 79 popup_ = popup_model; |
| 67 } | 80 } |
| 68 | 81 |
| 69 // TODO(beaudoin): The edit and popup model should be siblings owned by the | 82 // TODO(beaudoin): The edit and popup model should be siblings owned by the |
| 70 // LocationBarView, making this accessor unnecessary. | 83 // LocationBarView, making this accessor unnecessary. |
| 71 OmniboxPopupModel* popup_model() const { return popup_; } | 84 OmniboxPopupModel* popup_model() const { return popup_; } |
| 72 | 85 |
| 86 const AutocompleteMatch& current_match() const { return current_match_; } |
| 87 |
| 73 // Turns off keyword mode for the current match. | 88 // Turns off keyword mode for the current match. |
| 74 void ClearPopupKeywordMode() const; | 89 void ClearPopupKeywordMode() const; |
| 75 | 90 |
| 76 const AutocompleteResult& result() const { | 91 const AutocompleteResult& result() const { |
| 77 return autocomplete_controller_->result(); | 92 return autocomplete_controller_->result(); |
| 78 } | 93 } |
| 79 | 94 |
| 80 // TODO(beaudoin): Make private once OmniboxEditModel no longer refers to it. | 95 // TODO(beaudoin): Make private once OmniboxEditModel no longer refers to it. |
| 81 void DoPreconnect(const AutocompleteMatch& match); | 96 void DoPreconnect(const AutocompleteMatch& match); |
| 82 | 97 |
| 83 // TODO(beaudoin): Make private once OmniboxEditModel no longer refers to it. | 98 // TODO(beaudoin): Make private once OmniboxEditModel no longer refers to it. |
| 84 // Invoked when the popup has changed its bounds to |bounds|. |bounds| here | 99 // Invoked when the popup has changed its bounds to |bounds|. |bounds| here |
| 85 // is in screen coordinates. | 100 // is in screen coordinates. |
| 86 void OnPopupBoundsChanged(const gfx::Rect& bounds); | 101 void OnPopupBoundsChanged(const gfx::Rect& bounds); |
| 87 | 102 |
| 88 private: | 103 private: |
| 89 | 104 |
| 90 // Returns true if a verbatim query should be used for Instant. A verbatim | 105 // Returns true if a verbatim query should be used for Instant. A verbatim |
| 91 // query is forced in certain situations, such as pressing delete at the end | 106 // query is forced in certain situations, such as pressing delete at the end |
| 92 // of the edit. | 107 // of the edit. |
| 93 bool UseVerbatimInstant(bool just_deleted_text) const; | 108 bool UseVerbatimInstant(bool just_deleted_text) const; |
| 94 | 109 |
| 95 // Access the instant controller from the OmniboxEditModel. We need to do this | 110 // Access the instant controller from the OmniboxEditModel. We need to do this |
| 96 // because the only valid pointer to InstantController is kept in Browser, | 111 // because the only valid pointer to InstantController is kept in Browser, |
| 97 // which OmniboxEditModel has some ways of reaching. | 112 // which OmniboxEditModel has some ways of reaching. |
| 98 InstantController* GetInstantController() const; | 113 InstantController* GetInstantController() const; |
| 99 | 114 |
| 115 // Creates an AutocompleteMatch for an instant result and sets it into |
| 116 // |current_match_|. |
| 117 void CreateAndSetInstantMatch(string16 query_string, |
| 118 string16 input_text, |
| 119 AutocompleteMatchType::Type match_type); |
| 100 // Weak, it owns us. | 120 // Weak, it owns us. |
| 101 // TODO(beaudoin): Consider defining a delegate to ease unit testing. | 121 // TODO(beaudoin): Consider defining a delegate to ease unit testing. |
| 102 OmniboxEditModel* omnibox_edit_model_; | 122 OmniboxEditModel* omnibox_edit_model_; |
| 103 | 123 |
| 104 Profile* profile_; | 124 Profile* profile_; |
| 105 | 125 |
| 106 OmniboxPopupModel* popup_; | 126 OmniboxPopupModel* popup_; |
| 107 | 127 |
| 128 InstantController* instant_controller_; |
| 129 |
| 108 scoped_ptr<AutocompleteController> autocomplete_controller_; | 130 scoped_ptr<AutocompleteController> autocomplete_controller_; |
| 109 | 131 |
| 132 // TODO(beaudoin): This AutocompleteMatch is used to let the OmniboxEditModel |
| 133 // know what it should display. Not every field is required for that purpose, |
| 134 // but the ones specifically needed are unclear. We should therefore spend |
| 135 // some time to extract these fields and use a tighter structure here. |
| 136 AutocompleteMatch current_match_; |
| 137 |
| 110 DISALLOW_COPY_AND_ASSIGN(OmniboxController); | 138 DISALLOW_COPY_AND_ASSIGN(OmniboxController); |
| 111 }; | 139 }; |
| 112 | 140 |
| 113 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CONTROLLER_H_ | 141 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CONTROLLER_H_ |
| OLD | NEW |