Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Unified Diff: components/autofill/core/common/autofill_util.cc

Issue 2874933008: Adds animation as feature variation to keyboard accessory. (Closed)
Patch Set: Switch to base/metrics/field_trial_params.h API from variations:: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/common/autofill_util.cc
diff --git a/components/autofill/core/common/autofill_util.cc b/components/autofill/core/common/autofill_util.cc
index c20ac562e437da1251f2ebd97580db54080fa7ee..50e50176d8c336e700bef8af1c7e6bfd865250fd 100644
--- a/components/autofill/core/common/autofill_util.cc
+++ b/components/autofill/core/common/autofill_util.cc
@@ -7,8 +7,11 @@
#include <algorithm>
#include "base/command_line.h"
+#include "base/feature_list.h"
#include "base/i18n/case_conversion.h"
#include "base/metrics/field_trial.h"
+#include "base/metrics/field_trial_params.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -18,6 +21,15 @@
namespace autofill {
+const base::Feature kAutofillKeyboardAccessory{
+ "AutofillKeyboardAccessory", base::FEATURE_DISABLED_BY_DEFAULT};
+const char kAutofillKeyboardAccessoryAnimationDurationKey[] =
+ "animation_duration_millis";
+const char kAutofillKeyboardAccessoryLimitLabelWidthKey[] =
+ "should_limit_label_width";
+const char kAutofillKeyboardAccessoryHintKey[] =
+ "is_hint_shown_before_suggestion";
+
namespace {
const char kSplitCharacters[] = " .,-_@";
@@ -49,13 +61,40 @@ bool IsShowAutofillSignaturesEnabled() {
bool IsKeyboardAccessoryEnabled() {
#if defined(OS_ANDROID)
- return base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableAccessorySuggestionView) ||
- (base::FieldTrialList::FindFullName("AutofillKeyboardAccessory") ==
- "Enabled" &&
- !base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableAccessorySuggestionView));
+ return base::FeatureList::IsEnabled(kAutofillKeyboardAccessory);
+#else // !defined(OS_ANDROID)
+ return false;
+#endif
+}
+
+unsigned int GetKeyboardAccessoryAnimationDuration() {
+#if defined(OS_ANDROID)
+ return base::GetFieldTrialParamByFeatureAsInt(
+ kAutofillKeyboardAccessory,
+ kAutofillKeyboardAccessoryAnimationDurationKey, 0);
+#else // !defined(OS_ANDROID)
+ NOTREACHED();
+ return 0;
+#endif
+}
+
+bool ShouldLimitKeyboardAccessorySuggestionLabelWidth() {
+#if defined(OS_ANDROID)
+ return base::GetFieldTrialParamByFeatureAsBool(
+ kAutofillKeyboardAccessory, kAutofillKeyboardAccessoryLimitLabelWidthKey,
+ false);
+#else // !defined(OS_ANDROID)
+ NOTREACHED();
+ return false;
+#endif
+}
+
+bool IsHintEnabledInKeyboardAccessory() {
+#if defined(OS_ANDROID)
+ return base::GetFieldTrialParamByFeatureAsBool(
+ kAutofillKeyboardAccessory, kAutofillKeyboardAccessoryHintKey, false);
#else // !defined(OS_ANDROID)
+ NOTREACHED();
return false;
#endif
}
« no previous file with comments | « components/autofill/core/common/autofill_util.h ('k') | components/resources/autofill_scaled_resources.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698