Commit 7305c205 authored by sreeram@chromium.org's avatar sreeram@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124850 0039d316-1c4b-4281-b951-d872f2087c98
parent 33ca967d
// 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));
......
// 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.
......@@ -62,6 +70,10 @@ class UIThreadSearchTermsData : public SearchTermsData {
virtual string16 GetRlzParameterValue() const OVERRIDE;
#endif
// 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;
......
......@@ -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));
......@@ -392,6 +396,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;
......
......@@ -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,
......
......@@ -1109,7 +1109,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,
1,
};
......@@ -3172,7 +3172,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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment