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_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 27 matching lines...) Expand all Loading... | |
| 38 namespace content { | 38 namespace content { |
| 39 class WebContents; | 39 class WebContents; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // InstantController maintains a WebContents that is intended to give a preview | 42 // InstantController maintains a WebContents that is intended to give a preview |
| 43 // of search suggestions and results. InstantController is owned by Browser via | 43 // of search suggestions and results. InstantController is owned by Browser via |
| 44 // BrowserInstantController. | 44 // BrowserInstantController. |
| 45 class InstantController { | 45 class InstantController { |
| 46 public: | 46 public: |
| 47 InstantController(chrome::BrowserInstantController* browser, | 47 InstantController(chrome::BrowserInstantController* browser, |
| 48 bool extended_enabled); | 48 bool extended_enabled, |
| 49 bool incognito_mode); | |
|
dhollowa
2012/12/13 01:20:15
The notion of incognito is appropriate at the brow
Shishir
2012/12/13 22:57:58
Like we discussed, renamed to use_local_preview_on
| |
| 49 ~InstantController(); | 50 ~InstantController(); |
| 50 | 51 |
| 51 // Invoked as the user types into the omnibox. |user_text| is what the user | 52 // Invoked as the user types into the omnibox. |user_text| is what the user |
| 52 // has typed. |full_text| is what the omnibox is showing. These may differ if | 53 // has typed. |full_text| is what the omnibox is showing. These may differ if |
| 53 // the user typed only some text, and the rest was inline autocompleted. If | 54 // the user typed only some text, and the rest was inline autocompleted. If |
| 54 // |verbatim| is true, search results are shown for the exact omnibox text, | 55 // |verbatim| is true, search results are shown for the exact omnibox text, |
| 55 // rather than the best guess as to what the user means. Returns true if the | 56 // rather than the best guess as to what the user means. Returns true if the |
| 56 // update is accepted (i.e., if |match| is a search rather than a URL). | 57 // update is accepted (i.e., if |match| is a search rather than a URL). |
| 57 bool Update(const AutocompleteMatch& match, | 58 bool Update(const AutocompleteMatch& match, |
| 58 const string16& user_text, | 59 const string16& user_text, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 // Invoked by InstantLoader when the preview gains focus, usually due to the | 147 // Invoked by InstantLoader when the preview gains focus, usually due to the |
| 147 // user clicking on it. | 148 // user clicking on it. |
| 148 void InstantLoaderContentsFocused(); | 149 void InstantLoaderContentsFocused(); |
| 149 | 150 |
| 150 // Invoked by the InstantLoader when its RenderView crashes. | 151 // Invoked by the InstantLoader when its RenderView crashes. |
| 151 void InstantLoaderRenderViewGone(); | 152 void InstantLoaderRenderViewGone(); |
| 152 | 153 |
| 153 // Invoked by InstantLoader when the instant page is about to navigate. | 154 // Invoked by InstantLoader when the instant page is about to navigate. |
| 154 void InstantLoaderAboutToNavigateMainFrame(const GURL& url); | 155 void InstantLoaderAboutToNavigateMainFrame(const GURL& url); |
| 155 | 156 |
| 157 // The URL for the local omnibox popup. | |
| 158 static const char* kLocalOmniboxPopupURL; | |
|
dhollowa
2012/12/13 01:20:15
nit: static const data members should be declared
Shishir
2012/12/13 22:57:58
Done.
| |
| 159 | |
| 156 private: | 160 private: |
| 157 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); | 161 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); |
| 158 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); | 162 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); |
| 159 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); | 163 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); |
| 160 | 164 |
| 161 // Helper for OmniboxFocusChanged. Commit or discard the preview. | 165 // Helper for OmniboxFocusChanged. Commit or discard the preview. |
| 162 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); | 166 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); |
| 163 | 167 |
| 164 // Creates a new loader if necessary, using the instant_url property of the | 168 // Creates a new loader if necessary, using the instant_url property of the |
| 165 // |template_url| (for example, if the Instant URL has changed since the last | 169 // |template_url| (for example, if the Instant URL has changed since the last |
| 166 // time the loader was created). Returns false if the |template_url| doesn't | 170 // time the loader was created). If |use_fallback| is true will use |
| 167 // have a valid Instant URL; true otherwise. | 171 // kLocalOmniboxPopupURL as the fallback url (in extended mode) in case |
| 172 // the |template_url| doesn't have a valid Instant URL. Returns true if an | |
| 173 // instant URL could be determined. | |
| 168 bool ResetLoader(const TemplateURL* template_url, | 174 bool ResetLoader(const TemplateURL* template_url, |
| 169 const content::WebContents* active_tab); | 175 const content::WebContents* active_tab, |
| 176 bool use_fallback); | |
|
dhollowa
2012/12/13 01:20:15
nit: use_local
Shishir
2012/12/13 22:57:58
changed to fallback_to_local.
| |
| 170 | 177 |
| 171 // Ensures that the |loader_| uses the default Instant URL, recreating it if | 178 // Ensures that the |loader_| uses the default Instant URL, recreating it if |
| 172 // necessary, and returns true. Returns false if the Instant URL could not be | 179 // necessary, and returns true. Returns false if the Instant URL could not be |
| 173 // determined or the active tab is NULL (browser is shutting down). | 180 // determined or the active tab is NULL (browser is shutting down). |
| 174 bool CreateDefaultLoader(); | 181 bool CreateDefaultLoader(); |
| 175 | 182 |
| 176 // Called when the |loader_| might be stale. If it's actually stale, and the | 183 // Called when the |loader_| might be stale. If it's actually stale, and the |
| 177 // omnibox doesn't have focus, and the preview isn't showing, the |loader_| is | 184 // omnibox doesn't have focus, and the preview isn't showing, the |loader_| is |
| 178 // deleted and recreated. Else the refresh is skipped. | 185 // deleted and recreated. Else the refresh is skipped. |
| 179 void OnStaleLoader(); | 186 void OnStaleLoader(); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 210 bool GetInstantURL(const TemplateURL* template_url, | 217 bool GetInstantURL(const TemplateURL* template_url, |
| 211 std::string* instant_url) const; | 218 std::string* instant_url) const; |
| 212 | 219 |
| 213 chrome::BrowserInstantController* const browser_; | 220 chrome::BrowserInstantController* const browser_; |
| 214 | 221 |
| 215 // Whether the extended API and regular API are enabled. If both are false, | 222 // Whether the extended API and regular API are enabled. If both are false, |
| 216 // Instant is effectively disabled. | 223 // Instant is effectively disabled. |
| 217 const bool extended_enabled_; | 224 const bool extended_enabled_; |
| 218 bool instant_enabled_; | 225 bool instant_enabled_; |
| 219 | 226 |
| 227 // Whether the profile is in incognito mode. | |
| 228 const bool incognito_mode_; | |
| 229 | |
| 220 // The state of the preview page, i.e., the page owned by |loader_|. Ignored | 230 // The state of the preview page, i.e., the page owned by |loader_|. Ignored |
| 221 // if |instant_tab_| is in use. | 231 // if |instant_tab_| is in use. |
| 222 InstantModel model_; | 232 InstantModel model_; |
| 223 | 233 |
| 224 // The preview WebContents. | 234 // The preview WebContents. |
| 225 scoped_ptr<InstantLoader> loader_; | 235 scoped_ptr<InstantLoader> loader_; |
| 226 | 236 |
| 227 // A committed WebContents that supports Instant. If non-NULL, the |loader_| | 237 // A committed WebContents that supports Instant. If non-NULL, the |loader_| |
| 228 // is guaranteed to be hidden and messages will be sent to this instead. | 238 // is guaranteed to be hidden and messages will be sent to this instead. |
| 229 scoped_ptr<InstantTab> instant_tab_; | 239 scoped_ptr<InstantTab> instant_tab_; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 | 300 |
| 291 // Whether to allow the preview to show search suggestions. In general, the | 301 // Whether to allow the preview to show search suggestions. In general, the |
| 292 // preview is allowed to show search suggestions whenever |search_mode_| is | 302 // preview is allowed to show search suggestions whenever |search_mode_| is |
| 293 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. | 303 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. |
| 294 bool allow_preview_to_show_search_suggestions_; | 304 bool allow_preview_to_show_search_suggestions_; |
| 295 | 305 |
| 296 DISALLOW_COPY_AND_ASSIGN(InstantController); | 306 DISALLOW_COPY_AND_ASSIGN(InstantController); |
| 297 }; | 307 }; |
| 298 | 308 |
| 299 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 309 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| OLD | NEW |