summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 21:49:06 +0000
committersreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 21:49:06 +0000
commit9963020f467f7732de146832c0ca865393182678 (patch)
tree39ca5072b0f2d9f33d3fdf2968db53425cacc11a
parenta33339963667e05430c3e67a8a35d499b432710b (diff)
downloadchromium_src-9963020f467f7732de146832c0ca865393182678.zip
chromium_src-9963020f467f7732de146832c0ca865393182678.tar.gz
chromium_src-9963020f467f7732de146832c0ca865393182678.tar.bz2
Don't send omnibox bounds for hidden field trials.
When the preview is finally shown in these field trials, the dropdown will always be closed, so this may help avoid some flicker. In the process, change IsHiddenExperiment() to include the SILENT experiment (helps eliminate some calls). BUG=none TEST=none Review URL: http://codereview.chromium.org/8400068 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107801 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/instant/instant_controller.cc23
-rw-r--r--chrome/browser/instant/instant_field_trial.cc5
-rw-r--r--chrome/browser/instant/instant_field_trial.h6
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc2
4 files changed, 20 insertions, 16 deletions
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 22bbd06..07fdc19 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -45,7 +45,7 @@ InstantController::InstantController(Profile* profile,
last_transition_type_(content::PAGE_TRANSITION_LINK),
ALLOW_THIS_IN_INITIALIZER_LIST(destroy_factory_(this)) {
PrefService* service = profile->GetPrefs();
- if (service && !InstantFieldTrial::IsExperimentGroup(profile)) {
+ if (service && !InstantFieldTrial::IsInstantExperiment(profile)) {
// kInstantEnabledOnce was added after instant, set it now to make sure it
// is correctly set.
service->SetBoolean(prefs::kInstantEnabledOnce, true);
@@ -97,7 +97,7 @@ void InstantController::RecordMetrics(Profile* profile) {
bool InstantController::IsEnabled(Profile* profile) {
PrefService* prefs = profile->GetPrefs();
return prefs->GetBoolean(prefs::kInstantEnabled) ||
- InstantFieldTrial::IsExperimentGroup(profile);
+ InstantFieldTrial::IsInstantExperiment(profile);
}
// static
@@ -200,8 +200,11 @@ void InstantController::SetOmniboxBounds(const gfx::Rect& bounds) {
// Always track the omnibox bounds. That way if Update is later invoked the
// bounds are in sync.
omnibox_bounds_ = bounds;
- if (loader_.get())
+
+ if (loader_.get() && !is_out_of_date_ &&
+ !InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile())) {
loader_->SetOmniboxBounds(bounds);
+ }
}
void InstantController::DestroyPreviewContents() {
@@ -238,10 +241,8 @@ bool InstantController::PrepareForCommit() {
// If we are not in the HIDDEN or SILENT field trials, return the status of
// the preview.
- if (!InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile()) &&
- !InstantFieldTrial::IsSilentExperiment(tab_contents_->profile())) {
+ if (!InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile()))
return IsCurrent();
- }
TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(
tab_contents_->profile());
@@ -370,7 +371,7 @@ void InstantController::OnAutocompleteGotFocus(
TabContentsWrapper* tab_contents) {
CommandLine* cl = CommandLine::ForCurrentProcess();
if (!cl->HasSwitch(switches::kPreloadInstantSearch) &&
- !InstantFieldTrial::IsExperimentGroup(tab_contents->profile())) {
+ !InstantFieldTrial::IsInstantExperiment(tab_contents->profile())) {
return;
}
@@ -496,12 +497,14 @@ void InstantController::UpdateLoader(const TemplateURL* template_url,
bool verbatim,
string16* suggested_text) {
is_out_of_date_ = false;
- loader_->SetOmniboxBounds(omnibox_bounds_);
+ bool hidden = InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile());
+ if (!hidden)
+ loader_->SetOmniboxBounds(omnibox_bounds_);
loader_->Update(tab_contents_, template_url, url, transition_type, user_text,
verbatim, suggested_text);
UpdateIsDisplayable();
- // For the HIDDEN field trial, don't send back suggestions to the omnibox.
- if (InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile()))
+ // For the HIDDEN and SILENT field trials, don't send back suggestions.
+ if (hidden)
suggested_text->clear();
}
diff --git a/chrome/browser/instant/instant_field_trial.cc b/chrome/browser/instant/instant_field_trial.cc
index 0e1c5d2..66b51e6 100644
--- a/chrome/browser/instant/instant_field_trial.cc
+++ b/chrome/browser/instant/instant_field_trial.cc
@@ -118,7 +118,7 @@ InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) {
}
// static
-bool InstantFieldTrial::IsExperimentGroup(Profile* profile) {
+bool InstantFieldTrial::IsInstantExperiment(Profile* profile) {
Group group = GetGroup(profile);
return group == INSTANT_EXPERIMENT_A || group == INSTANT_EXPERIMENT_B ||
group == HIDDEN_EXPERIMENT_A || group == HIDDEN_EXPERIMENT_B ||
@@ -128,7 +128,8 @@ bool InstantFieldTrial::IsExperimentGroup(Profile* profile) {
// static
bool InstantFieldTrial::IsHiddenExperiment(Profile* profile) {
Group group = GetGroup(profile);
- return group == HIDDEN_EXPERIMENT_A || group == HIDDEN_EXPERIMENT_B;
+ return group == HIDDEN_EXPERIMENT_A || group == HIDDEN_EXPERIMENT_B ||
+ group == SILENT_EXPERIMENT_A || group == SILENT_EXPERIMENT_B;
}
// static
diff --git a/chrome/browser/instant/instant_field_trial.h b/chrome/browser/instant/instant_field_trial.h
index 38fb746..52765d5 100644
--- a/chrome/browser/instant/instant_field_trial.h
+++ b/chrome/browser/instant/instant_field_trial.h
@@ -69,10 +69,10 @@ class InstantFieldTrial {
// Return the field trial group this profile belongs to.
static Group GetGroup(Profile* profile);
- // Check if the user is in one of the EXPERIMENT groups.
- static bool IsExperimentGroup(Profile* profile);
+ // Check if the user is in any of the EXPERIMENT groups.
+ static bool IsInstantExperiment(Profile* profile);
- // Check if the user is in the HIDDEN_EXPERIMENT group.
+ // Check if the user is in the HIDDEN or SILENT EXPERIMENT groups.
static bool IsHiddenExperiment(Profile* profile);
// Check if the user is in the SILENT EXPERIMENT group.
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index 7c7dba4..bfdde36 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -462,7 +462,7 @@ void BrowserOptionsHandler::DisableInstant(const ListValue* args) {
void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) {
base::FundamentalValue enabled(
- InstantFieldTrial::IsExperimentGroup(Profile::FromWebUI(web_ui_)));
+ InstantFieldTrial::IsInstantExperiment(Profile::FromWebUI(web_ui_)));
web_ui_->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus",
enabled);
}