omnibox: experiment with restoring placeholder when caret shows
Shows the "Search Google or type a URL" omnibox placeholder even when
the caret (text edit cursor) is showing / when focused. views::Textfield
works this way, as does <input placeholder="">. Omnibox and the NTP's
"fakebox" are exceptions in this regard and this experiment makes this
more consistent.
R=tommycli@chromium.org
BUG=955585
Change-Id: I23c299c0973f2feb43f7a2be3bd3425a80b06c2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1582315
Commit-Queue: Dan Beam <dbeam@chromium.org>
Reviewed-by: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654279}
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index df2eda6c..c544137 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -1420,8 +1420,11 @@
}
bool OmniboxViewViews::ShouldShowPlaceholderText() const {
+ bool show_with_caret = base::FeatureList::IsEnabled(
+ omnibox::kUIExperimentShowPlaceholderWhenCaretShowing);
return Textfield::ShouldShowPlaceholderText() &&
- !model()->is_caret_visible() && !model()->is_keyword_selected();
+ (show_with_caret || !model()->is_caret_visible()) &&
+ !model()->is_keyword_selected();
}
#if defined(OS_CHROMEOS)
diff --git a/components/omnibox/common/omnibox_features.cc b/components/omnibox/common/omnibox_features.cc
index fbf4a3d..cda0d01 100644
--- a/components/omnibox/common/omnibox_features.cc
+++ b/components/omnibox/common/omnibox_features.cc
@@ -258,6 +258,14 @@
"OmniboxUIExperimentUnboldSuggestionText",
base::FEATURE_DISABLED_BY_DEFAULT};
+// Shows the "Search Google or type a URL" omnibox placeholder even when the
+// caret (text edit cursor) is showing / when focused. views::Textfield works
+// this way, as does <input placeholder="">. Omnibox and the NTP's "fakebox"
+// are exceptions in this regard and this experiment makes this more consistent.
+const base::Feature kUIExperimentShowPlaceholderWhenCaretShowing{
+ "OmniboxUIExperimentShowPlaceholderWhenCaretShowing",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
// Feature used to enable speculatively starting a service worker associated
// with the destination of the default match when the user's input looks like a
// query.
diff --git a/components/omnibox/common/omnibox_features.h b/components/omnibox/common/omnibox_features.h
index 1457be7a..02b8932 100644
--- a/components/omnibox/common/omnibox_features.h
+++ b/components/omnibox/common/omnibox_features.h
@@ -9,6 +9,7 @@
namespace omnibox {
+// TODO(dbeam): why is this list not sorted alphabetically?
extern const base::Feature kHideFileUrlScheme;
extern const base::Feature kHideSteadyStateUrlScheme;
extern const base::Feature kHideSteadyStateUrlTrivialSubdomains;
@@ -45,6 +46,7 @@
extern const base::Feature kUIExperimentWhiteBackgroundOnBlur;
extern const base::Feature kUIExperimentUseGenericSearchEngineIcon;
extern const base::Feature kUIExperimentUnboldSuggestionText;
+extern const base::Feature kUIExperimentShowPlaceholderWhenCaretShowing;
extern const base::Feature kSpeculativeServiceWorkerStartOnQueryInput;
extern const base::Feature kDocumentProvider;
extern const base::Feature kDedupeGoogleDriveURLs;