Commit 9963020f authored by sreeram@chromium.org's avatar sreeram@chromium.org

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
parent a3333996
...@@ -45,7 +45,7 @@ InstantController::InstantController(Profile* profile, ...@@ -45,7 +45,7 @@ InstantController::InstantController(Profile* profile,
last_transition_type_(content::PAGE_TRANSITION_LINK), last_transition_type_(content::PAGE_TRANSITION_LINK),
ALLOW_THIS_IN_INITIALIZER_LIST(destroy_factory_(this)) { ALLOW_THIS_IN_INITIALIZER_LIST(destroy_factory_(this)) {
PrefService* service = profile->GetPrefs(); 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 // kInstantEnabledOnce was added after instant, set it now to make sure it
// is correctly set. // is correctly set.
service->SetBoolean(prefs::kInstantEnabledOnce, true); service->SetBoolean(prefs::kInstantEnabledOnce, true);
...@@ -97,7 +97,7 @@ void InstantController::RecordMetrics(Profile* profile) { ...@@ -97,7 +97,7 @@ void InstantController::RecordMetrics(Profile* profile) {
bool InstantController::IsEnabled(Profile* profile) { bool InstantController::IsEnabled(Profile* profile) {
PrefService* prefs = profile->GetPrefs(); PrefService* prefs = profile->GetPrefs();
return prefs->GetBoolean(prefs::kInstantEnabled) || return prefs->GetBoolean(prefs::kInstantEnabled) ||
InstantFieldTrial::IsExperimentGroup(profile); InstantFieldTrial::IsInstantExperiment(profile);
} }
// static // static
...@@ -200,8 +200,11 @@ void InstantController::SetOmniboxBounds(const gfx::Rect& bounds) { ...@@ -200,8 +200,11 @@ void InstantController::SetOmniboxBounds(const gfx::Rect& bounds) {
// Always track the omnibox bounds. That way if Update is later invoked the // Always track the omnibox bounds. That way if Update is later invoked the
// bounds are in sync. // bounds are in sync.
omnibox_bounds_ = bounds; omnibox_bounds_ = bounds;
if (loader_.get())
if (loader_.get() && !is_out_of_date_ &&
!InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile())) {
loader_->SetOmniboxBounds(bounds); loader_->SetOmniboxBounds(bounds);
}
} }
void InstantController::DestroyPreviewContents() { void InstantController::DestroyPreviewContents() {
...@@ -238,10 +241,8 @@ bool InstantController::PrepareForCommit() { ...@@ -238,10 +241,8 @@ bool InstantController::PrepareForCommit() {
// If we are not in the HIDDEN or SILENT field trials, return the status of // If we are not in the HIDDEN or SILENT field trials, return the status of
// the preview. // the preview.
if (!InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile()) && if (!InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile()))
!InstantFieldTrial::IsSilentExperiment(tab_contents_->profile())) {
return IsCurrent(); return IsCurrent();
}
TemplateURLService* model = TemplateURLServiceFactory::GetForProfile( TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(
tab_contents_->profile()); tab_contents_->profile());
...@@ -370,7 +371,7 @@ void InstantController::OnAutocompleteGotFocus( ...@@ -370,7 +371,7 @@ void InstantController::OnAutocompleteGotFocus(
TabContentsWrapper* tab_contents) { TabContentsWrapper* tab_contents) {
CommandLine* cl = CommandLine::ForCurrentProcess(); CommandLine* cl = CommandLine::ForCurrentProcess();
if (!cl->HasSwitch(switches::kPreloadInstantSearch) && if (!cl->HasSwitch(switches::kPreloadInstantSearch) &&
!InstantFieldTrial::IsExperimentGroup(tab_contents->profile())) { !InstantFieldTrial::IsInstantExperiment(tab_contents->profile())) {
return; return;
} }
...@@ -496,12 +497,14 @@ void InstantController::UpdateLoader(const TemplateURL* template_url, ...@@ -496,12 +497,14 @@ void InstantController::UpdateLoader(const TemplateURL* template_url,
bool verbatim, bool verbatim,
string16* suggested_text) { string16* suggested_text) {
is_out_of_date_ = false; is_out_of_date_ = false;
bool hidden = InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile());
if (!hidden)
loader_->SetOmniboxBounds(omnibox_bounds_); loader_->SetOmniboxBounds(omnibox_bounds_);
loader_->Update(tab_contents_, template_url, url, transition_type, user_text, loader_->Update(tab_contents_, template_url, url, transition_type, user_text,
verbatim, suggested_text); verbatim, suggested_text);
UpdateIsDisplayable(); UpdateIsDisplayable();
// For the HIDDEN field trial, don't send back suggestions to the omnibox. // For the HIDDEN and SILENT field trials, don't send back suggestions.
if (InstantFieldTrial::IsHiddenExperiment(tab_contents_->profile())) if (hidden)
suggested_text->clear(); suggested_text->clear();
} }
......
...@@ -118,7 +118,7 @@ InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { ...@@ -118,7 +118,7 @@ InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) {
} }
// static // static
bool InstantFieldTrial::IsExperimentGroup(Profile* profile) { bool InstantFieldTrial::IsInstantExperiment(Profile* profile) {
Group group = GetGroup(profile); Group group = GetGroup(profile);
return group == INSTANT_EXPERIMENT_A || group == INSTANT_EXPERIMENT_B || return group == INSTANT_EXPERIMENT_A || group == INSTANT_EXPERIMENT_B ||
group == HIDDEN_EXPERIMENT_A || group == HIDDEN_EXPERIMENT_B || group == HIDDEN_EXPERIMENT_A || group == HIDDEN_EXPERIMENT_B ||
...@@ -128,7 +128,8 @@ bool InstantFieldTrial::IsExperimentGroup(Profile* profile) { ...@@ -128,7 +128,8 @@ bool InstantFieldTrial::IsExperimentGroup(Profile* profile) {
// static // static
bool InstantFieldTrial::IsHiddenExperiment(Profile* profile) { bool InstantFieldTrial::IsHiddenExperiment(Profile* profile) {
Group group = GetGroup(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 // static
......
...@@ -69,10 +69,10 @@ class InstantFieldTrial { ...@@ -69,10 +69,10 @@ class InstantFieldTrial {
// Return the field trial group this profile belongs to. // Return the field trial group this profile belongs to.
static Group GetGroup(Profile* profile); static Group GetGroup(Profile* profile);
// Check if the user is in one of the EXPERIMENT groups. // Check if the user is in any of the EXPERIMENT groups.
static bool IsExperimentGroup(Profile* profile); 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); static bool IsHiddenExperiment(Profile* profile);
// Check if the user is in the SILENT EXPERIMENT group. // Check if the user is in the SILENT EXPERIMENT group.
......
...@@ -462,7 +462,7 @@ void BrowserOptionsHandler::DisableInstant(const ListValue* args) { ...@@ -462,7 +462,7 @@ void BrowserOptionsHandler::DisableInstant(const ListValue* args) {
void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) {
base::FundamentalValue enabled( base::FundamentalValue enabled(
InstantFieldTrial::IsExperimentGroup(Profile::FromWebUI(web_ui_))); InstantFieldTrial::IsInstantExperiment(Profile::FromWebUI(web_ui_)));
web_ui_->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", web_ui_->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus",
enabled); enabled);
} }
......
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