| 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 processed by Instant (i.e., if |match| is a search rather than a |
| 84 // URL). |suggested_text| and |complete_behavior| will be modified if Instant |
| 85 // has a suggestion that should be inlined into the omnibox. |
| 84 bool Update(const AutocompleteMatch& match, | 86 bool Update(const AutocompleteMatch& match, |
| 85 const string16& user_text, | 87 const string16& user_text, |
| 88 const string16& full_text, |
| 86 bool verbatim, | 89 bool verbatim, |
| 87 string16* suggested_text, | 90 string16* suggested_text, |
| 88 InstantCompleteBehavior* complete_behavior); | 91 InstantCompleteBehavior* complete_behavior); |
| 89 | 92 |
| 90 // Sets the bounds of the omnibox dropdown, in screen coordinates. | 93 // Sets the bounds of the omnibox dropdown, in screen coordinates. |
| 91 void SetOmniboxBounds(const gfx::Rect& bounds); | 94 void SetOmniboxBounds(const gfx::Rect& bounds); |
| 92 | 95 |
| 93 // Send autocomplete results from |providers| to the preview page. | 96 // Send autocomplete results from |providers| to the preview page. |
| 94 void HandleAutocompleteResults( | 97 void HandleAutocompleteResults( |
| 95 const std::vector<AutocompleteProvider*>& providers); | 98 const std::vector<AutocompleteProvider*>& providers); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 187 |
| 185 // See the enum description above. | 188 // See the enum description above. |
| 186 const Mode mode_; | 189 const Mode mode_; |
| 187 | 190 |
| 188 // The active tab at the time of the last Update(). Used by IsOutOfDate() to | 191 // 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.*** | 192 // 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 | 193 // It may be a dangling pointer to a freed object. Should only be used for |
| 191 // pointer comparisons. | 194 // pointer comparisons. |
| 192 const void* last_active_tab_; | 195 const void* last_active_tab_; |
| 193 | 196 |
| 194 // The most recent full omnibox query text known to us. If this is empty, it | 197 // 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_; | 198 string16 last_full_text_; |
| 198 | 199 |
| 199 // The most recent user_text passed to Update(). | 200 // The most recent user_text passed to Update(). |
| 200 string16 last_user_text_; | 201 string16 last_user_text_; |
| 201 | 202 |
| 202 // The most recent verbatim passed to Update(). | 203 // The most recent verbatim passed to Update(). |
| 203 bool last_verbatim_; | 204 bool last_verbatim_; |
| 204 | 205 |
| 205 // The most recent suggestion received from the page, minus any prefix that | 206 // The most recent suggestion received from the page, minus any prefix that |
| 206 // the user has typed. | 207 // the user has typed. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 236 // Search terms extraction (for autocomplete history matches) doesn't work | 237 // Search terms extraction (for autocomplete history matches) doesn't work |
| 237 // on Instant URLs. So, whenever the user commits an Instant search, we add | 238 // 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 | 239 // an equivalent non-Instant search URL to history, so that the search shows |
| 239 // up in autocomplete history matches. | 240 // up in autocomplete history matches. |
| 240 GURL url_for_history_; | 241 GURL url_for_history_; |
| 241 | 242 |
| 242 DISALLOW_COPY_AND_ASSIGN(InstantController); | 243 DISALLOW_COPY_AND_ASSIGN(InstantController); |
| 243 }; | 244 }; |
| 244 | 245 |
| 245 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 246 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| OLD | NEW |