| 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" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 bool allow_exact_keyword_match, | 50 bool allow_exact_keyword_match, |
| 51 int omnibox_start_margin) const; | 51 int omnibox_start_margin) const; |
| 52 | 52 |
| 53 // AutocompleteControllerDelegate: | 53 // AutocompleteControllerDelegate: |
| 54 virtual void OnResultChanged(bool default_match_changed) OVERRIDE; | 54 virtual void OnResultChanged(bool default_match_changed) OVERRIDE; |
| 55 | 55 |
| 56 AutocompleteController* autocomplete_controller() { | 56 AutocompleteController* autocomplete_controller() { |
| 57 return autocomplete_controller_.get(); | 57 return autocomplete_controller_.get(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool DoInstant(const AutocompleteMatch& match, | |
| 61 string16 user_text, | |
| 62 string16 full_text, | |
| 63 size_t selection_start, | |
| 64 size_t selection_end, | |
| 65 bool user_input_in_progress, | |
| 66 bool in_escape_handler, | |
| 67 bool just_deleted_text, | |
| 68 bool keyword_is_selected); | |
| 69 | |
| 70 // Sets the suggestion text. | 60 // Sets the suggestion text. |
| 71 void SetInstantSuggestion(const InstantSuggestion& suggestion); | 61 void SetInstantSuggestion(const InstantSuggestion& suggestion); |
| 72 | 62 |
| 73 // Set |current_match_| to an invalid value, indicating that we do not yet | 63 // Set |current_match_| to an invalid value, indicating that we do not yet |
| 74 // have a valid match for the current text in the omnibox. | 64 // have a valid match for the current text in the omnibox. |
| 75 void InvalidateCurrentMatch(); | 65 void InvalidateCurrentMatch(); |
| 76 | 66 |
| 77 void set_popup_model(OmniboxPopupModel* popup_model) { | 67 void set_popup_model(OmniboxPopupModel* popup_model) { |
| 78 popup_ = popup_model; | 68 popup_ = popup_model; |
| 79 } | 69 } |
| 80 | 70 |
| 81 // TODO(beaudoin): The edit and popup model should be siblings owned by the | 71 // TODO(beaudoin): The edit and popup model should be siblings owned by the |
| 82 // LocationBarView, making this accessor unnecessary. | 72 // LocationBarView, making this accessor unnecessary. |
| 83 OmniboxPopupModel* popup_model() const { return popup_; } | 73 OmniboxPopupModel* popup_model() const { return popup_; } |
| 84 | 74 |
| 85 const AutocompleteMatch& current_match() const { return current_match_; } | 75 const AutocompleteMatch& current_match() const { return current_match_; } |
| 86 | 76 |
| 87 const string16& gray_suggestion() const { return gray_suggestion_; } | |
| 88 | |
| 89 // Turns off keyword mode for the current match. | 77 // Turns off keyword mode for the current match. |
| 90 void ClearPopupKeywordMode() const; | 78 void ClearPopupKeywordMode() const; |
| 91 | 79 |
| 92 const AutocompleteResult& result() const { | 80 const AutocompleteResult& result() const { |
| 93 return autocomplete_controller_->result(); | 81 return autocomplete_controller_->result(); |
| 94 } | 82 } |
| 95 | 83 |
| 96 // TODO(beaudoin): Make private once OmniboxEditModel no longer refers to it. | 84 // TODO(beaudoin): Make private once OmniboxEditModel no longer refers to it. |
| 97 void DoPreconnect(const AutocompleteMatch& match); | 85 void DoPreconnect(const AutocompleteMatch& match); |
| 98 | 86 |
| 99 // TODO(beaudoin): Make private once OmniboxEditModel no longer refers to it. | |
| 100 // Invoked when the popup has changed its bounds to |bounds|. |bounds| here | |
| 101 // is in screen coordinates. | |
| 102 void OnPopupBoundsChanged(const gfx::Rect& bounds); | |
| 103 | |
| 104 private: | 87 private: |
| 105 | 88 |
| 106 // Returns true if a verbatim query should be used for Instant. A verbatim | 89 // Returns true if a verbatim query should be used for Instant. A verbatim |
| 107 // query is forced in certain situations, such as pressing delete at the end | 90 // query is forced in certain situations, such as pressing delete at the end |
| 108 // of the edit. | 91 // of the edit. |
| 109 bool UseVerbatimInstant(bool just_deleted_text) const; | 92 bool UseVerbatimInstant(bool just_deleted_text) const; |
| 110 | 93 |
| 111 // Access the instant controller from the OmniboxEditModel. We need to do this | 94 // Access the instant controller from the OmniboxEditModel. We need to do this |
| 112 // because the only valid pointer to InstantController is kept in Browser, | 95 // because the only valid pointer to InstantController is kept in Browser, |
| 113 // which OmniboxEditModel has some ways of reaching. | 96 // which OmniboxEditModel has some ways of reaching. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 129 InstantController* instant_controller_; | 112 InstantController* instant_controller_; |
| 130 | 113 |
| 131 scoped_ptr<AutocompleteController> autocomplete_controller_; | 114 scoped_ptr<AutocompleteController> autocomplete_controller_; |
| 132 | 115 |
| 133 // TODO(beaudoin): This AutocompleteMatch is used to let the OmniboxEditModel | 116 // TODO(beaudoin): This AutocompleteMatch is used to let the OmniboxEditModel |
| 134 // know what it should display. Not every field is required for that purpose, | 117 // know what it should display. Not every field is required for that purpose, |
| 135 // but the ones specifically needed are unclear. We should therefore spend | 118 // but the ones specifically needed are unclear. We should therefore spend |
| 136 // some time to extract these fields and use a tighter structure here. | 119 // some time to extract these fields and use a tighter structure here. |
| 137 AutocompleteMatch current_match_; | 120 AutocompleteMatch current_match_; |
| 138 | 121 |
| 139 // The completion suggested by instant, displayed in gray text besides | |
| 140 // |fill_into_edit|. | |
| 141 string16 gray_suggestion_; | |
| 142 | |
| 143 DISALLOW_COPY_AND_ASSIGN(OmniboxController); | 122 DISALLOW_COPY_AND_ASSIGN(OmniboxController); |
| 144 }; | 123 }; |
| 145 | 124 |
| 146 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CONTROLLER_H_ | 125 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_CONTROLLER_H_ |
| OLD | NEW |