Commit 576cf9e3 authored by Justin Donnelly's avatar Justin Donnelly Committed by Commit Bot

[omnibox] Enable experimental UI features with the kExperimentalUi flag.

Enables the following features:
- New answer layout
- Tab switch suggestions
- Steady-state elision of scheme and trivial subdomains
- Favicons
- Increased vertical margins (10px)
- Swap title and URL

This new flag was introduced to make it easier for everyone to enable
all of the UI features under development.

Change-Id: I551d75053fb1aa12ca9f76fb7e38f7c85683b8aa
Reviewed-on: https://chromium-review.googlesource.com/1083215
Commit-Queue: Justin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564997}
parent 4fb7e01e
...@@ -103,20 +103,16 @@ gfx::Insets GetMarginInsets(int text_height, bool is_two_line) { ...@@ -103,20 +103,16 @@ gfx::Insets GetMarginInsets(int text_height, bool is_two_line) {
// Regardless of the text size, we ensure a minimum size for the content line // Regardless of the text size, we ensure a minimum size for the content line
// here. This minimum is larger for hybrid mouse/touch devices to ensure an // here. This minimum is larger for hybrid mouse/touch devices to ensure an
// adequately sized touch target. // adequately sized touch target.
using Md = ui::MaterialDesignController;
const int kIconVerticalPad = base::GetFieldTrialParamByFeatureAsInt(
omnibox::kUIExperimentVerticalMargin,
OmniboxFieldTrial::kUIVerticalMarginParam,
Md::GetMode() == Md::MATERIAL_HYBRID ? 8 : 4);
const int min_height_for_icon = const int min_height_for_icon =
GetLayoutConstant(LOCATION_BAR_ICON_SIZE) + (kIconVerticalPad * 2); GetLayoutConstant(LOCATION_BAR_ICON_SIZE) +
(OmniboxFieldTrial::GetSuggestionVerticalMargin() * 2);
const int min_height_for_text = text_height + 2 * kMinVerticalMargin; const int min_height_for_text = text_height + 2 * kMinVerticalMargin;
int min_height = std::max(min_height_for_icon, min_height_for_text); int min_height = std::max(min_height_for_icon, min_height_for_text);
int alignment_offset = GetIconAlignmentOffset(); int alignment_offset = GetIconAlignmentOffset();
// Make sure the minimum height of an omnibox result matches the height of the // Make sure the minimum height of an omnibox result matches the height of the
// location bar view / non-results section of the omnibox popup in touch. // location bar view / non-results section of the omnibox popup in touch.
if (Md::IsTouchOptimizedUiEnabled()) { if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled()) {
min_height = std::max( min_height = std::max(
min_height, RoundedOmniboxResultsFrame::GetNonResultSectionHeight()); min_height, RoundedOmniboxResultsFrame::GetNonResultSectionHeight());
if (is_two_line) { if (is_two_line) {
...@@ -255,8 +251,7 @@ void OmniboxMatchCellView::OnMatchUpdate(const OmniboxResultView* result_view, ...@@ -255,8 +251,7 @@ void OmniboxMatchCellView::OnMatchUpdate(const OmniboxResultView* result_view,
const AutocompleteMatch& match) { const AutocompleteMatch& match) {
is_old_style_answer_ = !!match.answer; is_old_style_answer_ = !!match.answer;
is_rich_suggestion_ = is_rich_suggestion_ =
(base::FeatureList::IsEnabled(omnibox::kOmniboxNewAnswerLayout) && (OmniboxFieldTrial::IsNewAnswerLayoutEnabled() && !!match.answer) ||
!!match.answer) ||
(base::FeatureList::IsEnabled(omnibox::kOmniboxRichEntitySuggestions) && (base::FeatureList::IsEnabled(omnibox::kOmniboxRichEntitySuggestions) &&
!match.image_url.empty()); !match.image_url.empty());
is_search_type_ = AutocompleteMatch::IsSearchType(match.type); is_search_type_ = AutocompleteMatch::IsSearchType(match.type);
......
...@@ -254,7 +254,7 @@ std::unique_ptr<gfx::RenderText> OmniboxTextView::CreateText( ...@@ -254,7 +254,7 @@ std::unique_ptr<gfx::RenderText> OmniboxTextView::CreateText(
const SuggestionAnswer::ImageLine& line) const { const SuggestionAnswer::ImageLine& line) const {
std::unique_ptr<gfx::RenderText> destination = std::unique_ptr<gfx::RenderText> destination =
CreateRenderText(base::string16()); CreateRenderText(base::string16());
if (!base::FeatureList::IsEnabled(omnibox::kOmniboxNewAnswerLayout)) { if (!OmniboxFieldTrial::IsNewAnswerLayoutEnabled()) {
// This assumes that the first text type in the line can be used to specify // This assumes that the first text type in the line can be used to specify
// the font for all the text fields in the line. For now this works but // the font for all the text fields in the line. For now this works but
// eventually it may be necessary to get RenderText to support multiple font // eventually it may be necessary to get RenderText to support multiple font
...@@ -325,7 +325,7 @@ void OmniboxTextView::AppendTextHelper(gfx::RenderText* destination, ...@@ -325,7 +325,7 @@ void OmniboxTextView::AppendTextHelper(gfx::RenderText* destination,
int offset = destination->text().length(); int offset = destination->text().length();
gfx::Range range(offset, offset + text.length()); gfx::Range range(offset, offset + text.length());
destination->AppendText(text); destination->AppendText(text);
if (base::FeatureList::IsEnabled(omnibox::kOmniboxNewAnswerLayout)) { if (OmniboxFieldTrial::IsNewAnswerLayoutEnabled()) {
destination->ApplyColor( destination->ApplyColor(
result_view_->GetColor(OmniboxPart::RESULTS_TEXT_DIMMED), range); result_view_->GetColor(OmniboxPart::RESULTS_TEXT_DIMMED), range);
} else { } else {
......
...@@ -583,10 +583,8 @@ void OmniboxViewViews::ClearAccessibilityLabel() { ...@@ -583,10 +583,8 @@ void OmniboxViewViews::ClearAccessibilityLabel() {
} }
bool OmniboxViewViews::UnapplySteadyStateElisions(UnelisionGesture gesture) { bool OmniboxViewViews::UnapplySteadyStateElisions(UnelisionGesture gesture) {
if (!base::FeatureList::IsEnabled( if (!OmniboxFieldTrial::IsHideSteadyStateUrlSchemeAndSubdomainsEnabled())
omnibox::kUIExperimentHideSteadyStateUrlSchemeAndSubdomains)) {
return false; return false;
}
// No need to update the text if the user is already inputting text. // No need to update the text if the user is already inputting text.
if (model()->user_input_in_progress()) if (model()->user_input_in_progress())
......
...@@ -492,7 +492,7 @@ void AutocompleteController::UpdateResult( ...@@ -492,7 +492,7 @@ void AutocompleteController::UpdateResult(
// Sort the matches and trim to a small number of "best" matches. // Sort the matches and trim to a small number of "best" matches.
result_.SortAndCull(input_, template_url_service_); result_.SortAndCull(input_, template_url_service_);
if (OmniboxFieldTrial::InTabSwitchSuggestionTrial()) if (OmniboxFieldTrial::IsTabSwitchSuggestionsEnabled())
result_.ConvertOpenTabMatches(provider_client_.get(), &input_); result_.ConvertOpenTabMatches(provider_client_.get(), &input_);
// Need to validate before invoking CopyOldMatches as the old matches are not // Need to validate before invoking CopyOldMatches as the old matches are not
......
...@@ -209,8 +209,7 @@ bool OmniboxEditModel::ResetDisplayUrls() { ...@@ -209,8 +209,7 @@ bool OmniboxEditModel::ResetDisplayUrls() {
url_for_editing_ = controller()->GetToolbarModel()->GetFormattedFullURL(); url_for_editing_ = controller()->GetToolbarModel()->GetFormattedFullURL();
display_only_url_ = display_only_url_ =
base::FeatureList::IsEnabled( OmniboxFieldTrial::IsHideSteadyStateUrlSchemeAndSubdomainsEnabled()
omnibox::kUIExperimentHideSteadyStateUrlSchemeAndSubdomains)
? controller()->GetToolbarModel()->GetURLForDisplay() ? controller()->GetToolbarModel()->GetURLForDisplay()
: url_for_editing_; : url_for_editing_;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "components/variations/variations_associated_data.h" #include "components/variations/variations_associated_data.h"
#include "third_party/metrics_proto/omnibox_event.pb.h" #include "third_party/metrics_proto/omnibox_event.pb.h"
#include "ui/base/material_design/material_design_controller.h" #include "ui/base/material_design/material_design_controller.h"
#include "ui/base/ui_base_features.h"
using metrics::OmniboxEventProto; using metrics::OmniboxEventProto;
...@@ -639,8 +640,10 @@ int OmniboxFieldTrial::KeywordScoreForSufficientlyCompleteMatch() { ...@@ -639,8 +640,10 @@ int OmniboxFieldTrial::KeywordScoreForSufficientlyCompleteMatch() {
OmniboxFieldTrial::EmphasizeTitlesCondition OmniboxFieldTrial::EmphasizeTitlesCondition
OmniboxFieldTrial::GetEmphasizeTitlesConditionForInput( OmniboxFieldTrial::GetEmphasizeTitlesConditionForInput(
const AutocompleteInput& input) { const AutocompleteInput& input) {
if (base::FeatureList::IsEnabled(omnibox::kUIExperimentSwapTitleAndUrl)) if (base::FeatureList::IsEnabled(omnibox::kUIExperimentSwapTitleAndUrl) ||
base::FeatureList::IsEnabled(features::kExperimentalUi)) {
return EMPHASIZE_WHEN_NONEMPTY; return EMPHASIZE_WHEN_NONEMPTY;
}
// Touch-optimized UI and MD Refresh also always swap title and URL. // Touch-optimized UI and MD Refresh also always swap title and URL.
if (ui::MaterialDesignController::is_mode_initialized() && if (ui::MaterialDesignController::is_mode_initialized() &&
...@@ -676,9 +679,36 @@ OmniboxFieldTrial::GetEmphasizeTitlesConditionForInput( ...@@ -676,9 +679,36 @@ OmniboxFieldTrial::GetEmphasizeTitlesConditionForInput(
return static_cast<EmphasizeTitlesCondition>(value); return static_cast<EmphasizeTitlesCondition>(value);
} }
// static bool OmniboxFieldTrial::IsNewAnswerLayoutEnabled() {
bool OmniboxFieldTrial::InTabSwitchSuggestionTrial() { return base::FeatureList::IsEnabled(omnibox::kOmniboxNewAnswerLayout) ||
return base::FeatureList::IsEnabled(omnibox::kOmniboxTabSwitchSuggestions); base::FeatureList::IsEnabled(features::kExperimentalUi);
}
bool OmniboxFieldTrial::IsTabSwitchSuggestionsEnabled() {
return base::FeatureList::IsEnabled(omnibox::kOmniboxTabSwitchSuggestions) ||
base::FeatureList::IsEnabled(features::kExperimentalUi);
}
bool OmniboxFieldTrial::IsHideSteadyStateUrlSchemeAndSubdomainsEnabled() {
return base::FeatureList::IsEnabled(
omnibox::kUIExperimentHideSteadyStateUrlSchemeAndSubdomains) ||
base::FeatureList::IsEnabled(features::kExperimentalUi);
}
bool OmniboxFieldTrial::IsShowSuggestionFaviconsEnabled() {
return base::FeatureList::IsEnabled(
omnibox::kUIExperimentShowSuggestionFavicons) ||
base::FeatureList::IsEnabled(features::kExperimentalUi);
}
int OmniboxFieldTrial::GetSuggestionVerticalMargin() {
if (base::FeatureList::IsEnabled(features::kExperimentalUi))
return 10;
using Md = ui::MaterialDesignController;
return base::GetFieldTrialParamByFeatureAsInt(
omnibox::kUIExperimentVerticalMargin, kUIVerticalMarginParam,
Md::GetMode() == Md::MATERIAL_HYBRID ? 8 : 4);
} }
const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] =
......
...@@ -408,8 +408,25 @@ class OmniboxFieldTrial { ...@@ -408,8 +408,25 @@ class OmniboxFieldTrial {
// --------------------------------------------------------- // ---------------------------------------------------------
// For tab switch suggestions related experiments. // For tab switch suggestions related experiments.
// Returns whether the tab switch suggestion experiment is enabled. // Returns true if either the new answer layout flag or the
static bool InTabSwitchSuggestionTrial(); // #upcoming-ui-features flag is enabled.
static bool IsNewAnswerLayoutEnabled();
// Returns true if either the tab switch suggestions flag or the
// #upcoming-ui-features flag is enabled.
static bool IsTabSwitchSuggestionsEnabled();
// Returns true if either the steady-state elision flag or the
// #upcoming-ui-features flag is enabled.
static bool IsHideSteadyStateUrlSchemeAndSubdomainsEnabled();
// Returns true if either the show suggestion favicons flag or the
// #upcoming-ui-features flag is enabled.
static bool IsShowSuggestionFaviconsEnabled();
// Returns the size of the vertical margin that should be used in the
// suggestion view.
static int GetSuggestionVerticalMargin();
// --------------------------------------------------------- // ---------------------------------------------------------
// Clipboard URL suggestions: // Clipboard URL suggestions:
......
...@@ -277,8 +277,7 @@ gfx::Image OmniboxPopupModel::GetMatchIcon(const AutocompleteMatch& match, ...@@ -277,8 +277,7 @@ gfx::Image OmniboxPopupModel::GetMatchIcon(const AutocompleteMatch& match,
if (!extension_icon.IsEmpty()) if (!extension_icon.IsEmpty())
return extension_icon; return extension_icon;
if (base::FeatureList::IsEnabled( if (OmniboxFieldTrial::IsShowSuggestionFaviconsEnabled() &&
omnibox::kUIExperimentShowSuggestionFavicons) &&
!AutocompleteMatch::IsSearchType(match.type)) { !AutocompleteMatch::IsSearchType(match.type)) {
// Because the Views UI code calls GetMatchIcon in both the layout and // Because the Views UI code calls GetMatchIcon in both the layout and
// painting code, we may generate multiple OnFaviconFetched callbacks, // painting code, we may generate multiple OnFaviconFetched callbacks,
......
...@@ -238,7 +238,7 @@ std::unique_ptr<SuggestionAnswer> SuggestionAnswer::ParseAnswer( ...@@ -238,7 +238,7 @@ std::unique_ptr<SuggestionAnswer> SuggestionAnswer::ParseAnswer(
std::string image_url; std::string image_url;
const base::DictionaryValue* optional_image; const base::DictionaryValue* optional_image;
if (base::FeatureList::IsEnabled(omnibox::kOmniboxNewAnswerLayout) && if (OmniboxFieldTrial::IsNewAnswerLayoutEnabled() &&
answer_json->GetDictionary("i", &optional_image) && answer_json->GetDictionary("i", &optional_image) &&
optional_image->GetString("d", &image_url)) { optional_image->GetString("d", &image_url)) {
result->image_url_ = GURL(image_url); result->image_url_ = GURL(image_url);
......
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