| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 Profile* profile() const { return profile_; } | 88 Profile* profile() const { return profile_; } |
| 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. Returns the |
| 99 AutocompleteMatch CurrentMatch(); | 99 // alternate nav URL, if |alternate_nav_url| is non-NULL and there is such a |
| 100 // URL. |
| 101 AutocompleteMatch CurrentMatch(GURL* alternate_nav_url) const; |
| 100 | 102 |
| 101 // Called when the user wants to export the entire current text as a URL. | 103 // 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. | 104 // Sets the url, and if known, the title and favicon. |
| 103 void GetDataForURLExport(GURL* url, string16* title, gfx::Image* favicon); | 105 void GetDataForURLExport(GURL* url, string16* title, gfx::Image* favicon); |
| 104 | 106 |
| 105 // Returns true if the current edit contents will be treated as a | 107 // Returns true if the current edit contents will be treated as a |
| 106 // URL/navigation, as opposed to a search. | 108 // URL/navigation, as opposed to a search. |
| 107 bool CurrentTextIsURL() const; | 109 bool CurrentTextIsURL() const; |
| 108 | 110 |
| 109 // Returns the match type for the current edit contents. | 111 // 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 | 133 // change should be immediately user-visible, because either the user is not |
| 132 // editing or the edit does not have focus. | 134 // editing or the edit does not have focus. |
| 133 bool UpdatePermanentText(const string16& new_permanent_text); | 135 bool UpdatePermanentText(const string16& new_permanent_text); |
| 134 | 136 |
| 135 // Returns the URL corresponding to the permanent text. | 137 // Returns the URL corresponding to the permanent text. |
| 136 GURL PermanentURL(); | 138 GURL PermanentURL(); |
| 137 | 139 |
| 138 // Sets the user_text_ to |text|. Only the View should call this. | 140 // Sets the user_text_ to |text|. Only the View should call this. |
| 139 void SetUserText(const string16& text); | 141 void SetUserText(const string16& text); |
| 140 | 142 |
| 141 // Calls through to SearchProvider::FinalizeInstantQuery. | |
| 142 void FinalizeInstantQuery(const string16& input_text, | |
| 143 const InstantSuggestion& suggestion); | |
| 144 | |
| 145 // Sets the suggestion text. | 143 // Sets the suggestion text. |
| 146 void SetInstantSuggestion(const InstantSuggestion& suggestion); | 144 void SetInstantSuggestion(const InstantSuggestion& suggestion); |
| 147 | 145 |
| 148 // Commits the gray suggested text as if it's been input by the user. | 146 // Commits the gray suggested text as if it's been input by the user. |
| 149 // Returns true if the text was committed. | 147 // Returns true if the text was committed. |
| 150 // TODO: can the return type be void? | 148 // TODO: can the return type be void? |
| 151 bool CommitSuggestedText(); | 149 bool CommitSuggestedText(); |
| 152 | 150 |
| 153 // Invoked any time the text may have changed in the edit. Updates Instant and | 151 // Invoked any time the text may have changed in the edit. Updates Instant and |
| 154 // notifies the controller. | 152 // notifies the controller. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 bool allow_keyword_ui_change); | 298 bool allow_keyword_ui_change); |
| 301 | 299 |
| 302 // TODO(beaudoin): Mac code still calls this here. We should try to untangle | 300 // TODO(beaudoin): Mac code still calls this here. We should try to untangle |
| 303 // this. | 301 // this. |
| 304 // Invoked when the popup has changed its bounds to |bounds|. |bounds| here | 302 // Invoked when the popup has changed its bounds to |bounds|. |bounds| here |
| 305 // is in screen coordinates. | 303 // is in screen coordinates. |
| 306 void OnPopupBoundsChanged(const gfx::Rect& bounds) { | 304 void OnPopupBoundsChanged(const gfx::Rect& bounds) { |
| 307 omnibox_controller_->OnPopupBoundsChanged(bounds); | 305 omnibox_controller_->OnPopupBoundsChanged(bounds); |
| 308 } | 306 } |
| 309 | 307 |
| 310 // Called when the results have changed in the OmniboxController. | 308 // Called when the current match has changed in the OmniboxController. |
| 311 void OnResultChanged(bool default_match_changed); | 309 void OnCurrentMatchChanged(bool is_temporary_set_by_instant); |
| 310 |
| 311 // Callend when the gray text suggestion has changed in the OmniboxController. |
| 312 void OnGrayTextChanged(); |
| 313 |
| 314 // Access the current view text. |
| 315 string16 GetViewText() const; |
| 316 |
| 317 string16 user_text() const { return user_text_; } |
| 312 | 318 |
| 313 // TODO(beaudoin): We need this to allow OmniboxController access the | 319 // TODO(beaudoin): We need this to allow OmniboxController access the |
| 314 // InstantController via OmniboxEditController, because the only valid pointer | 320 // InstantController via OmniboxEditController, because the only valid pointer |
| 315 // to InstantController is kept in Browser. We should try to get rid of this, | 321 // to InstantController is kept in Browser. We should try to get rid of this, |
| 316 // maybe by ensuring InstantController lives as long as Browser. | 322 // maybe by ensuring InstantController lives as long as Browser. |
| 317 InstantController* GetInstantController() const; | 323 InstantController* GetInstantController() const; |
| 318 | 324 |
| 319 private: | 325 private: |
| 320 friend class InstantTestBase; | 326 friend class InstantTestBase; |
| 321 friend class OmniboxControllerTest; | 327 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 | 561 // an exact keyword match. If this is true then keyword mode will be |
| 556 // triggered automatically if the input is "<keyword> <search string>". We | 562 // triggered automatically if the input is "<keyword> <search string>". We |
| 557 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. | 563 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. |
| 558 // This has no effect if we're already in keyword mode. | 564 // This has no effect if we're already in keyword mode. |
| 559 bool allow_exact_keyword_match_; | 565 bool allow_exact_keyword_match_; |
| 560 | 566 |
| 561 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); | 567 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); |
| 562 }; | 568 }; |
| 563 | 569 |
| 564 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ | 570 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ |
| OLD | NEW |