Commit c4df81f9 authored by Mohamad Ahmadi's avatar Mohamad Ahmadi Committed by Commit Bot

Adds autofill::features::AutofillShowTypePredictions to the chrome://flags

This allows for debugging issues and verifying fixes in non-debug builds.

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I1a48af9c85df6aebbc39b7690143a45800a4ad8f
Reviewed-on: https://chromium-review.googlesource.com/832676Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarRoger McFarlane <rogerm@chromium.org>
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525262}
parent 64399d62
......@@ -27,6 +27,7 @@
#include "components/autofill/core/browser/keyboard_accessory_metrics_logger.h"
#include "components/autofill/core/browser/popup_item_ids.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/form_data.h"
......@@ -938,6 +939,11 @@ void GetFormAndField(autofill::FormData* form,
- (void)renderAutofillTypePredictions:
(const std::vector<autofill::FormStructure*>&)structure {
if (!base::FeatureList::IsEnabled(
autofill::features::kAutofillShowTypePredictions)) {
return;
}
base::DictionaryValue predictionData;
for (autofill::FormStructure* form : structure) {
auto formJSONData = base::MakeUnique<base::DictionaryValue>();
......
......@@ -21,6 +21,7 @@
#include "base/strings/sys_string_conversions.h"
#include "base/sys_info.h"
#include "base/task_scheduler/switches.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/dom_distiller/core/dom_distiller_switches.h"
#include "components/feature_engagement/public/feature_constants.h"
#include "components/feature_engagement/public/feature_list.h"
......@@ -202,7 +203,12 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
{"wk-http-system-cookie-store",
flag_descriptions::kWKHTTPSystemCookieStoreName,
flag_descriptions::kWKHTTPSystemCookieStoreName, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(web::features::kWKHTTPSystemCookieStore)}};
FEATURE_VALUE_TYPE(web::features::kWKHTTPSystemCookieStore)},
{"show-autofill-type-predictions",
flag_descriptions::kShowAutofillTypePredictionsName,
flag_descriptions::kShowAutofillTypePredictionsDescription,
flags_ui::kOsIos,
FEATURE_VALUE_TYPE(autofill::features::kAutofillShowTypePredictions)}};
// Add all switches from experimental flags to |command_line|.
void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
......
......@@ -192,8 +192,6 @@ showAutofillPopup:(const std::vector<autofill::Suggestion>&)popup_suggestions
- (void)sendAutofillTypePredictionsToRenderer:
(const std::vector<autofill::FormStructure*>&)forms {
NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults];
if ([standardDefaults boolForKey:@"ShowAutofillTypePredictions"])
[_autofillAgent renderAutofillTypePredictions:forms];
}
......
......@@ -117,6 +117,11 @@ const char kNewFileDownloadDescription[] =
"When enabled, uses new Download Manager UI and ios/web Download API as "
"backend.";
const char kShowAutofillTypePredictionsName[] = "Show Autofill predictions";
const char kShowAutofillTypePredictionsDescription[] =
"Annotates web forms with Autofill field type predictions as placeholder "
"text.";
const char kTabSwitcherPresentsBVCName[] = "TabSwitcher Presents BVC";
const char kTabSwitcherPresentsBVCDescription[] =
"When enabled, the tab switcher will present the BVC, so that when the "
......
......@@ -109,6 +109,11 @@ extern const char kNewPassKitDownloadDescription[];
extern const char kNewFileDownloadName[];
extern const char kNewFileDownloadDescription[];
// Title and description for the flag to enable annotating web forms with
// Autofill field type predictions as placeholder.
extern const char kShowAutofillTypePredictionsName[];
extern const char kShowAutofillTypePredictionsDescription[];
// Title and description for the flag to enable the TabSwitcher to present the
// BVC.
extern const char kTabSwitcherPresentsBVCName[];
......
......@@ -111,7 +111,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeMemoryDebugging,
ItemTypeViewSource,
ItemTypeLogJavascript,
ItemTypeShowAutofillTypePredictions,
ItemTypeCellCatalog,
ItemTypeArticlesForYou,
};
......@@ -119,7 +118,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
#if CHROMIUM_BUILD && !defined(NDEBUG)
NSString* kDevViewSourceKey = @"DevViewSource";
NSString* kLogJavascriptKey = @"LogJavascript";
NSString* kShowAutofillTypePredictionsKey = @"ShowAutofillTypePredictions";
#endif // CHROMIUM_BUILD && !defined(NDEBUG)
#pragma mark - SigninObserverBridge Class
......@@ -425,8 +423,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
toSectionWithIdentifier:SectionIdentifierDebug];
[model addItem:[self logJavascriptConsoleSwitchItem]
toSectionWithIdentifier:SectionIdentifierDebug];
[model addItem:[self showAutofillTypePredictionsSwitchItem]
toSectionWithIdentifier:SectionIdentifierDebug];
[model addItem:[self materialCatalogDetailItem]
toSectionWithIdentifier:SectionIdentifierDebug];
#endif // CHROMIUM_BUILD && !defined(NDEBUG)
......@@ -594,12 +590,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
withDefaultsKey:kLogJavascriptKey];
}
- (CollectionViewSwitchItem*)showAutofillTypePredictionsSwitchItem {
return [self switchItemWithType:ItemTypeShowAutofillTypePredictions
title:@"Show Autofill type predictions"
withDefaultsKey:kShowAutofillTypePredictionsKey];
}
- (CollectionViewDetailItem*)materialCatalogDetailItem {
return [self detailItemWithType:ItemTypeCellCatalog
text:@"Cell Catalog"
......@@ -725,18 +715,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
forControlEvents:UIControlEventValueChanged];
#else
NOTREACHED();
#endif // CHROMIUM_BUILD && !defined(NDEBUG)
break;
}
case ItemTypeShowAutofillTypePredictions: {
#if CHROMIUM_BUILD && !defined(NDEBUG)
CollectionViewSwitchCell* switchCell =
base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell);
[switchCell.switchView addTarget:self
action:@selector(showAutoFillSwitchToggled:)
forControlEvents:UIControlEventValueChanged];
#else
NOTREACHED();
#endif // CHROMIUM_BUILD && !defined(NDEBUG)
break;
}
......@@ -813,7 +791,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
case ItemTypeMemoryDebugging:
case ItemTypeViewSource:
case ItemTypeLogJavascript:
case ItemTypeShowAutofillTypePredictions:
// Taps on these don't do anything. They have a switch as accessory view
// and only the switch is tappable.
break;
......@@ -860,7 +837,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
switch (type) {
case ItemTypeLogJavascript:
case ItemTypeMemoryDebugging:
case ItemTypeShowAutofillTypePredictions:
case ItemTypeSigninPromo:
case ItemTypeViewSource:
return YES;
......@@ -927,21 +903,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
switchItem.on = newSwitchValue;
[self setBooleanNSUserDefaultsValue:newSwitchValue forKey:kLogJavascriptKey];
}
- (void)showAutoFillSwitchToggled:(UISwitch*)sender {
NSIndexPath* switchPath = [self.collectionViewModel
indexPathForItemType:ItemTypeShowAutofillTypePredictions
sectionIdentifier:SectionIdentifierDebug];
CollectionViewSwitchItem* switchItem =
base::mac::ObjCCastStrict<CollectionViewSwitchItem>(
[self.collectionViewModel itemAtIndexPath:switchPath]);
BOOL newSwitchValue = sender.isOn;
switchItem.on = newSwitchValue;
[self setBooleanNSUserDefaultsValue:newSwitchValue
forKey:kShowAutofillTypePredictionsKey];
}
#endif // CHROMIUM_BUILD && !defined(NDEBUG)
#pragma mark Private methods
......
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