Chromium Code Reviews| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 | 89 |
| 90 // Returns the current state. This assumes we are switching tabs, and changes | 90 // Returns the current state. This assumes we are switching tabs, and changes |
| 91 // the internal state appropriately. | 91 // the internal state appropriately. |
| 92 const State GetStateForTabSwitch(); | 92 const State GetStateForTabSwitch(); |
| 93 | 93 |
| 94 // Restores local state from the saved |state|. | 94 // Restores local state from the saved |state|. |
| 95 void RestoreState(const State& state); | 95 void RestoreState(const State& state); |
| 96 | 96 |
| 97 // Returns the match for the current text. If the user has not edited the text | 97 // Returns the match for the current text. If the user has not edited the text |
| 98 // this is the match corresponding to the permanent text. | 98 // this is the match corresponding to the permanent text. |
| 99 AutocompleteMatch CurrentMatch(); | 99 AutocompleteMatch CurrentMatch() const; |
| 100 | 100 |
| 101 // Called when the user wants to export the entire current text as a URL. | 101 // Called when the user wants to export the entire current text as a URL. |
| 102 // Sets the url, and if known, the title and favicon. | 102 // Sets the url, and if known, the title and favicon. |
| 103 void GetDataForURLExport(GURL* url, string16* title, gfx::Image* favicon); | 103 void GetDataForURLExport(GURL* url, string16* title, gfx::Image* favicon); |
| 104 | 104 |
| 105 // Returns true if the current edit contents will be treated as a | 105 // Returns true if the current edit contents will be treated as a |
| 106 // URL/navigation, as opposed to a search. | 106 // URL/navigation, as opposed to a search. |
| 107 bool CurrentTextIsURL() const; | 107 bool CurrentTextIsURL() const; |
| 108 | 108 |
| 109 // Returns the match type for the current edit contents. | 109 // Returns the match type for the current edit contents. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 131 // change should be immediately user-visible, because either the user is not | 131 // change should be immediately user-visible, because either the user is not |
| 132 // editing or the edit does not have focus. | 132 // editing or the edit does not have focus. |
| 133 bool UpdatePermanentText(const string16& new_permanent_text); | 133 bool UpdatePermanentText(const string16& new_permanent_text); |
| 134 | 134 |
| 135 // Returns the URL corresponding to the permanent text. | 135 // Returns the URL corresponding to the permanent text. |
| 136 GURL PermanentURL(); | 136 GURL PermanentURL(); |
| 137 | 137 |
| 138 // Sets the user_text_ to |text|. Only the View should call this. | 138 // Sets the user_text_ to |text|. Only the View should call this. |
| 139 void SetUserText(const string16& text); | 139 void SetUserText(const string16& text); |
| 140 | 140 |
| 141 // Calls through to SearchProvider::FinalizeInstantQuery. | |
| 142 void FinalizeInstantQuery(const string16& input_text, | |
| 143 const InstantSuggestion& suggestion); | |
| 144 | |
| 145 // Sets the suggestion text. | 141 // Sets the suggestion text. |
| 146 void SetInstantSuggestion(const InstantSuggestion& suggestion); | 142 void SetInstantSuggestion(const InstantSuggestion& suggestion); |
| 147 | 143 |
| 148 // Commits the gray suggested text as if it's been input by the user. | 144 // Commits the gray suggested text as if it's been input by the user. |
| 149 // Returns true if the text was committed. | 145 // Returns true if the text was committed. |
| 150 // TODO: can the return type be void? | 146 // TODO: can the return type be void? |
| 151 bool CommitSuggestedText(); | 147 bool CommitSuggestedText(); |
| 152 | 148 |
| 153 // Invoked any time the text may have changed in the edit. Updates Instant and | 149 // Invoked any time the text may have changed in the edit. Updates Instant and |
| 154 // notifies the controller. | 150 // notifies the controller. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 bool allow_keyword_ui_change); | 296 bool allow_keyword_ui_change); |
| 301 | 297 |
| 302 // TODO(beaudoin): Mac code still calls this here. We should try to untangle | 298 // TODO(beaudoin): Mac code still calls this here. We should try to untangle |
| 303 // this. | 299 // this. |
| 304 // Invoked when the popup has changed its bounds to |bounds|. |bounds| here | 300 // Invoked when the popup has changed its bounds to |bounds|. |bounds| here |
| 305 // is in screen coordinates. | 301 // is in screen coordinates. |
| 306 void OnPopupBoundsChanged(const gfx::Rect& bounds) { | 302 void OnPopupBoundsChanged(const gfx::Rect& bounds) { |
| 307 omnibox_controller_->OnPopupBoundsChanged(bounds); | 303 omnibox_controller_->OnPopupBoundsChanged(bounds); |
| 308 } | 304 } |
| 309 | 305 |
| 310 // Called when the results have changed in the OmniboxController. | 306 // Called when the current match has changed in the OmniboxController. |
| 311 void OnResultChanged(bool default_match_changed); | 307 void OnCurrentMatchChanged(bool is_temporary_set_by_instant); |
| 308 | |
| 309 // Access the current view text. | |
| 310 string16 GetViewText() const; | |
| 311 | |
| 312 string16 user_text() const { return user_text_; } | |
|
Peter Kasting
2013/06/11 22:42:55
Musing: It seems like we have some accessors above
beaudoin
2013/06/14 21:39:38
I agree. Let's push that back to a future CL if yo
| |
| 312 | 313 |
| 313 // TODO(beaudoin): We need this to allow OmniboxController access the | 314 // TODO(beaudoin): We need this to allow OmniboxController access the |
| 314 // InstantController via OmniboxEditController, because the only valid pointer | 315 // InstantController via OmniboxEditController, because the only valid pointer |
| 315 // to InstantController is kept in Browser. We should try to get rid of this, | 316 // to InstantController is kept in Browser. We should try to get rid of this, |
| 316 // maybe by ensuring InstantController lives as long as Browser. | 317 // maybe by ensuring InstantController lives as long as Browser. |
| 317 InstantController* GetInstantController() const; | 318 InstantController* GetInstantController() const; |
| 318 | 319 |
| 319 private: | 320 private: |
| 320 friend class InstantTestBase; | 321 friend class InstantTestBase; |
| 321 friend class OmniboxControllerTest; | 322 friend class OmniboxControllerTest; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 // an exact keyword match. If this is true then keyword mode will be | 556 // an exact keyword match. If this is true then keyword mode will be |
| 556 // triggered automatically if the input is "<keyword> <search string>". We | 557 // triggered automatically if the input is "<keyword> <search string>". We |
| 557 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. | 558 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. |
| 558 // This has no effect if we're already in keyword mode. | 559 // This has no effect if we're already in keyword mode. |
| 559 bool allow_exact_keyword_match_; | 560 bool allow_exact_keyword_match_; |
| 560 | 561 |
| 561 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); | 562 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); |
| 562 }; | 563 }; |
| 563 | 564 |
| 564 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ | 565 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ |
| OLD | NEW |