Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1328)

Side by Side Diff: chrome/browser/instant/instant_controller.h

Issue 11555033: Adding local html page used in Instant Extended mode when instant is disabled or unavailable. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressing comments from estade, dhollowa and samarth. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
37 37
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 // The URL for the local omnibox popup.
48 static const char* kLocalOmniboxPopupURL;
49
50 // |use_local_preview_only| will force the use of kLocalOmniboxPopupURL as the
51 // instant URL and is only applicable if |extended_enabled| is true.
47 InstantController(chrome::BrowserInstantController* browser, 52 InstantController(chrome::BrowserInstantController* browser,
48 bool extended_enabled); 53 bool extended_enabled,
54 bool use_local_preview_only);
49 ~InstantController(); 55 ~InstantController();
50 56
51 // Invoked as the user types into the omnibox. |user_text| is what the user 57 // 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 58 // 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 59 // 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, 60 // |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 61 // 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). 62 // update is accepted (i.e., if |match| is a search rather than a URL).
57 bool Update(const AutocompleteMatch& match, 63 bool Update(const AutocompleteMatch& match,
58 const string16& user_text, 64 const string16& user_text,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 private: 163 private:
158 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); 164 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant);
159 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); 165 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider);
160 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); 166 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh);
161 167
162 // Helper for OmniboxFocusChanged. Commit or discard the preview. 168 // Helper for OmniboxFocusChanged. Commit or discard the preview.
163 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); 169 void OmniboxLostFocus(gfx::NativeView view_gaining_focus);
164 170
165 // Creates a new loader if necessary, using the instant_url property of the 171 // Creates a new loader if necessary, using the instant_url property of the
166 // |template_url| (for example, if the Instant URL has changed since the last 172 // |template_url| (for example, if the Instant URL has changed since the last
167 // time the loader was created). Returns false if the |template_url| doesn't 173 // time the loader was created). If |fallback_to_local| is true will use
168 // have a valid Instant URL; true otherwise. 174 // kLocalOmniboxPopupURL as the fallback url (in extended mode) in case
175 // the |template_url| doesn't have a valid Instant URL. Returns true if an
176 // instant URL could be determined.
169 bool ResetLoader(const TemplateURL* template_url, 177 bool ResetLoader(const TemplateURL* template_url,
170 const content::WebContents* active_tab); 178 const content::WebContents* active_tab,
179 bool fallback_to_local);
171 180
172 // Ensures that the |loader_| uses the default Instant URL, recreating it if 181 // Ensures that the |loader_| uses the default Instant URL, recreating it if
173 // necessary, and returns true. Returns false if the Instant URL could not be 182 // necessary, and returns true. Returns false if the Instant URL could not be
174 // determined or the active tab is NULL (browser is shutting down). 183 // determined or the active tab is NULL (browser is shutting down).
175 bool CreateDefaultLoader(); 184 bool CreateDefaultLoader();
176 185
177 // Called when the |loader_| might be stale. If it's actually stale, and the 186 // Called when the |loader_| might be stale. If it's actually stale, and the
178 // omnibox doesn't have focus, and the preview isn't showing, the |loader_| is 187 // omnibox doesn't have focus, and the preview isn't showing, the |loader_| is
179 // deleted and recreated. Else the refresh is skipped. 188 // deleted and recreated. Else the refresh is skipped.
180 void OnStaleLoader(); 189 void OnStaleLoader();
(...skipping 30 matching lines...) Expand all
211 bool GetInstantURL(const TemplateURL* template_url, 220 bool GetInstantURL(const TemplateURL* template_url,
212 std::string* instant_url) const; 221 std::string* instant_url) const;
213 222
214 chrome::BrowserInstantController* const browser_; 223 chrome::BrowserInstantController* const browser_;
215 224
216 // Whether the extended API and regular API are enabled. If both are false, 225 // Whether the extended API and regular API are enabled. If both are false,
217 // Instant is effectively disabled. 226 // Instant is effectively disabled.
218 const bool extended_enabled_; 227 const bool extended_enabled_;
219 bool instant_enabled_; 228 bool instant_enabled_;
220 229
230 // If true, the instant URL is set to kLocalOmniboxPopupURL.
231 const bool use_local_preview_only_;
232
221 // The state of the preview page, i.e., the page owned by |loader_|. Ignored 233 // The state of the preview page, i.e., the page owned by |loader_|. Ignored
222 // if |instant_tab_| is in use. 234 // if |instant_tab_| is in use.
223 InstantModel model_; 235 InstantModel model_;
224 236
225 // The preview WebContents. 237 // The preview WebContents.
226 scoped_ptr<InstantLoader> loader_; 238 scoped_ptr<InstantLoader> loader_;
227 239
228 // A committed WebContents that supports Instant. If non-NULL, the |loader_| 240 // A committed WebContents that supports Instant. If non-NULL, the |loader_|
229 // is guaranteed to be hidden and messages will be sent to this instead. 241 // is guaranteed to be hidden and messages will be sent to this instead.
230 scoped_ptr<InstantTab> instant_tab_; 242 scoped_ptr<InstantTab> instant_tab_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 303
292 // Whether to allow the preview to show search suggestions. In general, the 304 // Whether to allow the preview to show search suggestions. In general, the
293 // preview is allowed to show search suggestions whenever |search_mode_| is 305 // preview is allowed to show search suggestions whenever |search_mode_| is
294 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. 306 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false.
295 bool allow_preview_to_show_search_suggestions_; 307 bool allow_preview_to_show_search_suggestions_;
296 308
297 DISALLOW_COPY_AND_ASSIGN(InstantController); 309 DISALLOW_COPY_AND_ASSIGN(InstantController);
298 }; 310 };
299 311
300 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ 312 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698