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

Unified Diff: chrome/browser/instant/instant_controller.h

Issue 10879043: Centralize logic around Instant modes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: profile keyed Created 8 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/instant/instant_controller.h
diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h
index 242466731d88fd70a3f9db86afc97537cf8a7324..8e202bfb6c821efef81a44a9fe362ede562fee08 100644
--- a/chrome/browser/instant/instant_controller.h
+++ b/chrome/browser/instant/instant_controller.h
@@ -50,6 +50,8 @@ class InstantController : public InstantLoaderDelegate {
static const int kInlineAutocompleteFadeInTimeMS = 300;
// InstantController may operate in one of these modes:
+ // EXTENDED: Similar to INSTANT, but with extended functionality, such as
+ // rendering suggestions within the preview and previews of URLs.
// INSTANT: The default search engine is preloaded when the omnibox gets
// focus. Queries are issued as the user types. Predicted queries are
// inline autocompleted into the omnibox. Result previews are shown.
@@ -57,24 +59,34 @@ class InstantController : public InstantLoaderDelegate {
// HIDDEN: Same as SUGGEST, without the inline autocompletion.
// SILENT: Same as HIDDEN, without issuing queries as the user types. The
// query is sent only after the user presses <Enter>.
- // EXTENDED: Similar to INSTANT, but with extended functionality, such as
- // rendering suggestions within the preview and previews of URLs.
+ // DISABLED: Instant is disabled.
enum Mode {
+ EXTENDED,
INSTANT,
SUGGEST,
HIDDEN,
SILENT,
- EXTENDED,
+ DISABLED,
};
- InstantController(InstantControllerDelegate* delegate, Mode mode);
- virtual ~InstantController();
+ // Returns true if Instant is enabled and supports the extended API.
+ static bool IsExtendedAPIEnabled(Profile* profile);
+
+ // Returns true if Instant is enabled in a visible, preview-showing mode.
+ static bool IsInstantEnabled(Profile* profile);
+
+ // Returns true if Instant will provide autocomplete suggestions.
+ static bool IsSuggestEnabled(Profile* profile);
// Registers Instant related preferences.
static void RegisterUserPrefs(PrefService* prefs);
- // Returns true if Instant is enabled for the given |profile|.
- static bool IsEnabled(Profile* profile);
+ // Factory-style constructor. The |profile| pointer is not cached, so the
+ // underlying object need not live beyond this call. May return NULL, which
+ // means that Instant is disabled in this profile.
+ static InstantController* GetInstance(Profile* profile,
sky 2012/08/30 22:33:13 Naming this Get is misleading since it always crea
sreeram 2012/08/30 23:23:51 Done.
+ InstantControllerDelegate* delegate);
+ virtual ~InstantController();
sky 2012/08/30 22:33:13 constructor/destructor before any methods (includi
sreeram 2012/08/30 23:23:51 Done.
// Invoked as the user types into the omnibox. |user_text| is what the user
// has typed. |full_text| is what the omnibox is showing. These may differ if
@@ -155,6 +167,8 @@ class InstantController : public InstantLoaderDelegate {
private:
FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh);
+ InstantController(InstantControllerDelegate* delegate, Mode mode);
+
// Creates a new loader if necessary (for example, if the |instant_url| has
// changed since the last time we created the loader).
void ResetLoader(const std::string& instant_url,

Powered by Google App Engine
This is Rietveld 408576698