summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-05 21:21:03 +0000
committersreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-05 21:21:03 +0000
commit015946ab8165af0ce071482ed6ef6507bfbaa4d4 (patch)
tree1a21164880ffd8fa30813f602441811d4c705b47
parent56af8a1d740bf29e5e579beaea4afed689d50717 (diff)
downloadchromium_src-015946ab8165af0ce071482ed6ef6507bfbaa4d4.zip
chromium_src-015946ab8165af0ce071482ed6ef6507bfbaa4d4.tar.gz
chromium_src-015946ab8165af0ce071482ed6ef6507bfbaa4d4.tar.bz2
Merge 124850 - Don't set ion=1 for hidden Instant modes.
Setting ion=1 overrides google.com preferences, which can be a surprise. Visible Instant is not such a surprise, since the user can actually see the previews and thus associate it with Chrome Instant. BUG=105390 TEST=Start with --instant-field-trial=hidden and observe that the Instant homepage requests don't have ion=1. Turn off Google Instant (using google.com/preferences) and observe that Google Instant remains turned off on an omnibox-initiated search. Review URL: http://codereview.chromium.org/9581026 TBR=sreeram@chromium.org Review URL: https://chromiumcodereview.appspot.com/9578028 git-svn-id: svn://svn.chromium.org/chrome/branches/1025/src@124999 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/search_engines/search_terms_data.cc17
-rw-r--r--chrome/browser/search_engines/search_terms_data.h18
-rw-r--r--chrome/browser/search_engines/template_url.cc8
-rw-r--r--chrome/browser/search_engines/template_url.h1
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data.cc4
5 files changed, 42 insertions, 6 deletions
diff --git a/chrome/browser/search_engines/search_terms_data.cc b/chrome/browser/search_engines/search_terms_data.cc
index 5a06cc3..fc11f1d 100644
--- a/chrome/browser/search_engines/search_terms_data.cc
+++ b/chrome/browser/search_engines/search_terms_data.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,6 +8,7 @@
#include "base/metrics/field_trial.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_url_tracker.h"
+#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/instant/instant_field_trial.h"
#include "content/public/browser/browser_thread.h"
#include "googleurl/src/gurl.h"
@@ -45,6 +46,10 @@ std::string SearchTermsData::GoogleBaseSuggestURLValue() const {
return base_url.ReplaceComponents(repl).spec();
}
+std::string SearchTermsData::InstantEnabledParam() const {
+ return std::string();
+}
+
std::string SearchTermsData::InstantFieldTrialUrlParam() const {
return std::string();
}
@@ -91,6 +96,16 @@ string16 UIThreadSearchTermsData::GetRlzParameterValue() const {
}
#endif
+std::string UIThreadSearchTermsData::InstantEnabledParam() const {
+ DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
+ BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (profile_ && InstantController::IsEnabled(profile_) &&
+ !InstantFieldTrial::IsHiddenExperiment(profile_)) {
+ return "&ion=1";
+ }
+ return std::string();
+}
+
std::string UIThreadSearchTermsData::InstantFieldTrialUrlParam() const {
DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::UI));
diff --git a/chrome/browser/search_engines/search_terms_data.h b/chrome/browser/search_engines/search_terms_data.h
index dd4468a..3590058 100644
--- a/chrome/browser/search_engines/search_terms_data.h
+++ b/chrome/browser/search_engines/search_terms_data.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -35,6 +35,14 @@ class SearchTermsData {
virtual string16 GetRlzParameterValue() const = 0;
#endif
+ // Returns a string indicating whether Instant (in the visible-preview mode)
+ // is enabled, suitable for adding as a query string param to the homepage
+ // (instant_url) request. Returns an empty string if Instant is disabled,
+ // or if it's only active in a hidden field trial mode. Determining this
+ // requires accessing the Profile, so this can only ever be non-empty for
+ // UIThreadSearchTermsData.
+ virtual std::string InstantEnabledParam() const;
+
// Returns a string indicating the Instant field trial group, suitable for
// adding as a query string param to suggest/search URLs, or an empty string
// if the field trial is not active. Checking the field trial group requires
@@ -51,8 +59,8 @@ class UIThreadSearchTermsData : public SearchTermsData {
public:
UIThreadSearchTermsData();
- // Callers who need an accurate answer from InstantFieldTrialUrlParam() must
- // set the profile here before calling that.
+ // Callers who need an accurate answer from InstantFieldTrialUrlParam() or
+ // InstantEnabledParam() must set the profile here before calling them.
void set_profile(Profile* profile) { profile_ = profile; }
// Implementation of SearchTermsData.
@@ -64,6 +72,10 @@ class UIThreadSearchTermsData : public SearchTermsData {
// This returns the empty string unless set_profile() has been called with a
// non-NULL Profile.
+ virtual std::string InstantEnabledParam() const OVERRIDE;
+
+ // This returns the empty string unless set_profile() has been called with a
+ // non-NULL Profile.
virtual std::string InstantFieldTrialUrlParam() const OVERRIDE;
// Used by tests to set the value for the Google base url. This takes
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index fc6e1fc..71def9b 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -56,6 +56,8 @@ static const char kGoogleBaseSuggestURLParameter[] =
"google:baseSuggestURL";
static const char kGoogleBaseSuggestURLParameterFull[] =
"{google:baseSuggestURL}";
+static const char kGoogleInstantEnabledParameter[] =
+ "google:instantEnabledParameter";
static const char kGoogleInstantFieldTrialGroupParameter[] =
"google:instantFieldTrialGroupParameter";
static const char kGoogleOriginalQueryForSuggestionParameter[] =
@@ -152,6 +154,8 @@ bool TemplateURLRef::ParseParameter(size_t start,
replacements->push_back(Replacement(GOOGLE_BASE_URL, start));
} else if (parameter == kGoogleBaseSuggestURLParameter) {
replacements->push_back(Replacement(GOOGLE_BASE_SUGGEST_URL, start));
+ } else if (parameter == kGoogleInstantEnabledParameter) {
+ replacements->push_back(Replacement(GOOGLE_INSTANT_ENABLED, start));
} else if (parameter == kGoogleInstantFieldTrialGroupParameter) {
replacements->push_back(Replacement(GOOGLE_INSTANT_FIELD_TRIAL_GROUP,
start));
@@ -398,6 +402,10 @@ std::string TemplateURLRef::ReplaceSearchTermsUsingTermsData(
url.insert(i->index, search_terms_data.GoogleBaseSuggestURLValue());
break;
+ case GOOGLE_INSTANT_ENABLED:
+ url.insert(i->index, search_terms_data.InstantEnabledParam());
+ break;
+
case GOOGLE_INSTANT_FIELD_TRIAL_GROUP:
url.insert(i->index, search_terms_data.InstantFieldTrialUrlParam());
break;
diff --git a/chrome/browser/search_engines/template_url.h b/chrome/browser/search_engines/template_url.h
index e4af72f..f39b872 100644
--- a/chrome/browser/search_engines/template_url.h
+++ b/chrome/browser/search_engines/template_url.h
@@ -168,6 +168,7 @@ class TemplateURLRef {
GOOGLE_ACCEPTED_SUGGESTION,
GOOGLE_BASE_URL,
GOOGLE_BASE_SUGGEST_URL,
+ GOOGLE_INSTANT_ENABLED,
GOOGLE_INSTANT_FIELD_TRIAL_GROUP,
GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION,
GOOGLE_RLZ,
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc
index 2f65c87..a7404d1 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -1194,7 +1194,7 @@ const PrepopulatedEngine google = {
L"client=chrome&hl={language}&q={searchTerms}",
L"{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant&"
L"{google:instantFieldTrialGroupParameter}"
- L"ie={inputEncoding}&ion=1{searchTerms}",
+ L"ie={inputEncoding}{google:instantEnabledParameter}{searchTerms}",
SEARCH_ENGINE_GOOGLE,
IDR_SEARCH_ENGINE_LOGO_GOOGLE,
1,
@@ -3330,7 +3330,7 @@ void RegisterUserPrefs(PrefService* prefs) {
int GetDataVersion(PrefService* prefs) {
// Increment this if you change the above data in ways that mean users with
// existing data should get a new version.
- const int kCurrentDataVersion = 37;
+ const int kCurrentDataVersion = 38;
if (!prefs)
return kCurrentDataVersion;
// If a version number exist in the preferences file, it overrides the