diff options
author | shishir@chromium.org <shishir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-07 04:55:59 +0000 |
---|---|---|
committer | shishir@chromium.org <shishir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-07 04:55:59 +0000 |
commit | 411c9c04ef6059c27ebf6dc8872b0aaba5733e9a (patch) | |
tree | 23d50e8236f658ba866d8602a3c4dac0e33dee92 /chrome | |
parent | c6b94c384107f67d826cfaf67c86e75c877b957d (diff) | |
download | chromium_src-411c9c04ef6059c27ebf6dc8872b0aaba5733e9a.zip chromium_src-411c9c04ef6059c27ebf6dc8872b0aaba5733e9a.tar.gz chromium_src-411c9c04ef6059c27ebf6dc8872b0aaba5733e9a.tar.bz2 |
Instant Extended should respect the search prediction pref.
BUG=165903
Review URL: https://chromiumcodereview.appspot.com/12225021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181210 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/instant/instant_controller.cc | 22 | ||||
-rw-r--r-- | chrome/browser/instant/instant_controller.h | 13 | ||||
-rw-r--r-- | chrome/browser/instant/instant_test_utils.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/browser_instant_controller.cc | 15 |
4 files changed, 36 insertions, 18 deletions
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index b7b0f16..72bf030 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -167,12 +167,11 @@ const char* InstantController::kLocalOmniboxPopupURL = "chrome://local-omnibox-popup/local-omnibox-popup.html"; InstantController::InstantController(chrome::BrowserInstantController* browser, - bool extended_enabled, - bool use_local_preview_only) + bool extended_enabled) : browser_(browser), extended_enabled_(extended_enabled), instant_enabled_(false), - use_local_preview_only_(use_local_preview_only), + use_local_preview_only_(true), model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), last_omnibox_text_has_inline_autocompletion_(false), last_verbatim_(false), @@ -729,10 +728,21 @@ void InstantController::TabDeactivated(content::WebContents* contents) { CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); } -void InstantController::SetInstantEnabled(bool instant_enabled) { +void InstantController::SetInstantEnabled(bool instant_enabled, + bool use_local_preview_only) { LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( - "SetInstantEnabled: %d", instant_enabled)); + "SetInstantEnabled: instant_enabled=%d, use_local_preview_only=%d", + instant_enabled, use_local_preview_only)); + + // Non extended mode does not care about |use_local_preview_only|. + if (instant_enabled == instant_enabled_ && + (!extended_enabled_ || + use_local_preview_only == use_local_preview_only_)) { + return; + } + instant_enabled_ = instant_enabled; + use_local_preview_only_ = use_local_preview_only; HideInternal(); loader_.reset(); if (extended_enabled_ || instant_enabled_) @@ -859,7 +869,7 @@ void InstantController::InstantSupportDetermined( const content::WebContents* contents, bool supports_instant) { LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( - "InstantSupportDetermined: supports_instant= %d", supports_instant)); + "InstantSupportDetermined: supports_instant=%d", supports_instant)); if (instant_tab_ && instant_tab_->contents() == contents) { if (!supports_instant) diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h index 05ec11b..40bbfc8 100644 --- a/chrome/browser/instant/instant_controller.h +++ b/chrome/browser/instant/instant_controller.h @@ -53,11 +53,8 @@ class InstantController { // The URL for the local omnibox popup. static const char* kLocalOmniboxPopupURL; - // |use_local_preview_only| will force the use of kLocalOmniboxPopupURL as the - // instant URL and is only applicable if |extended_enabled| is true. InstantController(chrome::BrowserInstantController* browser, - bool extended_enabled, - bool use_local_preview_only); + bool extended_enabled); ~InstantController(); // Invoked as the user types into the omnibox. |user_text| is what the user @@ -123,8 +120,10 @@ class InstantController { // The user is about to switch tabs. Commit the preview if needed. void TabDeactivated(content::WebContents* contents); - // Sets whether Instant should show result previews. - void SetInstantEnabled(bool instant_enabled); + // Sets whether Instant should show result previews. |use_local_preview_only| + // will force the use of kLocalOmniboxPopupURL as the Instant URL and is only + // applicable if |extended_enabled_| is true. + void SetInstantEnabled(bool instant_enabled, bool use_local_preview_only); // The theme has changed. Pass the message to the preview page. void ThemeChanged(const ThemeBackgroundInfo& theme_info); @@ -274,7 +273,7 @@ class InstantController { bool instant_enabled_; // If true, the instant URL is set to kLocalOmniboxPopupURL. - const bool use_local_preview_only_; + bool use_local_preview_only_; // The state of the preview page, i.e., the page owned by |loader_|. Ignored // if |instant_tab_| is in use. diff --git a/chrome/browser/instant/instant_test_utils.cc b/chrome/browser/instant/instant_test_utils.cc index b8313a2..65451db 100644 --- a/chrome/browser/instant/instant_test_utils.cc +++ b/chrome/browser/instant/instant_test_utils.cc @@ -59,8 +59,8 @@ void InstantTestBase::SetupInstant() { SetupInstantUsingTemplateURL(); // TODO(shishir): Fix this ugly hack. - instant()->SetInstantEnabled(false); - instant()->SetInstantEnabled(true); + instant()->SetInstantEnabled(false, true); + instant()->SetInstantEnabled(true, false); } void InstantTestBase::SetupInstantUsingTemplateURL() { diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc index 4118de5..49d93da 100644 --- a/chrome/browser/ui/browser_instant_controller.cc +++ b/chrome/browser/ui/browser_instant_controller.cc @@ -39,8 +39,7 @@ namespace chrome { BrowserInstantController::BrowserInstantController(Browser* browser) : browser_(browser), instant_(ALLOW_THIS_IN_INITIALIZER_LIST(this), - chrome::search::IsInstantExtendedAPIEnabled(browser->profile()), - browser->profile()->IsOffTheRecord()), + chrome::search::IsInstantExtendedAPIEnabled(browser->profile())), instant_unload_handler_(browser), initialized_theme_info_(false), theme_area_height_(0) { @@ -49,6 +48,10 @@ BrowserInstantController::BrowserInstantController(Browser* browser) GetInstantPrefName(browser_->profile()), base::Bind(&BrowserInstantController::ResetInstant, base::Unretained(this))); + profile_pref_registrar_.Add( + prefs::kSearchSuggestEnabled, + base::Bind(&BrowserInstantController::ResetInstant, + base::Unretained(this))); ResetInstant(); browser_->search_model()->AddObserver(this); @@ -197,7 +200,13 @@ void BrowserInstantController::SetMarginSize(int start, int end) { } void BrowserInstantController::ResetInstant() { - instant_.SetInstantEnabled(IsInstantEnabled(browser_->profile())); + Profile* profile = browser_->profile(); + + bool instant_enabled = IsInstantEnabled(profile); + bool use_local_preview_only = profile->IsOffTheRecord() || + (!instant_enabled && + !profile->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled)); + instant_.SetInstantEnabled(instant_enabled, use_local_preview_only); } //////////////////////////////////////////////////////////////////////////////// |