| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_INSTANT_INSTANT_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 InstantController(InstantControllerDelegate* delegate, Mode mode); | 69 InstantController(InstantControllerDelegate* delegate, Mode mode); |
| 70 virtual ~InstantController(); | 70 virtual ~InstantController(); |
| 71 | 71 |
| 72 // Registers Instant related preferences. | 72 // Registers Instant related preferences. |
| 73 static void RegisterUserPrefs(PrefService* prefs); | 73 static void RegisterUserPrefs(PrefService* prefs); |
| 74 | 74 |
| 75 // Returns true if Instant is enabled for the given |profile|. | 75 // Returns true if Instant is enabled for the given |profile|. |
| 76 static bool IsEnabled(Profile* profile); | 76 static bool IsEnabled(Profile* profile); |
| 77 | 77 |
| 78 // Invoked as the user types into the omnibox. |user_text| is what the user | 78 // Invoked as the user types into the omnibox. |user_text| is what the user |
| 79 // has typed. |suggested_text| is the current inline autocomplete text. It | 79 // has typed. |full_text| is what the omnibox is showing. These may differ if |
| 80 // may be replaced by Instant's autocomplete suggestion, if any. If |verbatim| | 80 // the user typed only some text, and the rest was inline autocompleted. If |
| 81 // is true, search results are shown for |user_text| rather than the best | 81 // |verbatim| is true, search results are shown for the exact omnibox text, |
| 82 // guess as to what Instant thinks the user means. Returns true if the update | 82 // rather than the best guess as to what the user means. Returns true if the |
| 83 // is processed by Instant (i.e., if |match| is a search rather than a URL). | 83 // update is accepted (i.e., if |match| is a search rather than a URL). |
| 84 bool Update(const AutocompleteMatch& match, | 84 bool Update(const AutocompleteMatch& match, |
| 85 const string16& user_text, | 85 const string16& user_text, |
| 86 bool verbatim, | 86 const string16& full_text, |
| 87 string16* suggested_text, | 87 bool verbatim); |
| 88 InstantCompleteBehavior* complete_behavior); | |
| 89 | 88 |
| 90 // Sets the bounds of the omnibox dropdown, in screen coordinates. | 89 // Sets the bounds of the omnibox dropdown, in screen coordinates. |
| 91 void SetOmniboxBounds(const gfx::Rect& bounds); | 90 void SetOmniboxBounds(const gfx::Rect& bounds); |
| 92 | 91 |
| 93 // Send autocomplete results from |providers| to the preview page. | 92 // Send autocomplete results from |providers| to the preview page. |
| 94 void HandleAutocompleteResults( | 93 void HandleAutocompleteResults( |
| 95 const std::vector<AutocompleteProvider*>& providers); | 94 const std::vector<AutocompleteProvider*>& providers); |
| 96 | 95 |
| 97 // The preview TabContents. May be NULL if ReleasePreviewContents() has been | 96 // The preview TabContents. May be NULL if ReleasePreviewContents() has been |
| 98 // called, with no subsequent successful call to Update(). InstantController | 97 // called, with no subsequent successful call to Update(). InstantController |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 183 |
| 185 // See the enum description above. | 184 // See the enum description above. |
| 186 const Mode mode_; | 185 const Mode mode_; |
| 187 | 186 |
| 188 // The active tab at the time of the last Update(). Used by IsOutOfDate() to | 187 // The active tab at the time of the last Update(). Used by IsOutOfDate() to |
| 189 // know whether the user switched tabs. ***NEVER DEREFERENCE THIS POINTER.*** | 188 // know whether the user switched tabs. ***NEVER DEREFERENCE THIS POINTER.*** |
| 190 // It may be a dangling pointer to a freed object. Should only be used for | 189 // It may be a dangling pointer to a freed object. Should only be used for |
| 191 // pointer comparisons. | 190 // pointer comparisons. |
| 192 const void* last_active_tab_; | 191 const void* last_active_tab_; |
| 193 | 192 |
| 194 // The most recent full omnibox query text known to us. If this is empty, it | 193 // The most recent full_text passed to Update(). |
| 195 // could also mean that the omnibox text was a URL (or something else that | |
| 196 // we shouldn't be processing). | |
| 197 string16 last_full_text_; | 194 string16 last_full_text_; |
| 198 | 195 |
| 199 // The most recent user_text passed to Update(). | 196 // The most recent user_text passed to Update(). |
| 200 string16 last_user_text_; | 197 string16 last_user_text_; |
| 201 | 198 |
| 202 // The most recent verbatim passed to Update(). | 199 // The most recent verbatim passed to Update(). |
| 203 bool last_verbatim_; | 200 bool last_verbatim_; |
| 204 | 201 |
| 205 // The most recent suggestion received from the page, minus any prefix that | 202 // The most recent suggestion received from the page, minus any prefix that |
| 206 // the user has typed. | 203 // the user has typed. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 236 // Search terms extraction (for autocomplete history matches) doesn't work | 233 // Search terms extraction (for autocomplete history matches) doesn't work |
| 237 // on Instant URLs. So, whenever the user commits an Instant search, we add | 234 // on Instant URLs. So, whenever the user commits an Instant search, we add |
| 238 // an equivalent non-Instant search URL to history, so that the search shows | 235 // an equivalent non-Instant search URL to history, so that the search shows |
| 239 // up in autocomplete history matches. | 236 // up in autocomplete history matches. |
| 240 GURL url_for_history_; | 237 GURL url_for_history_; |
| 241 | 238 |
| 242 DISALLOW_COPY_AND_ASSIGN(InstantController); | 239 DISALLOW_COPY_AND_ASSIGN(InstantController); |
| 243 }; | 240 }; |
| 244 | 241 |
| 245 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 242 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| OLD | NEW |