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 @@ ...@@ -27,6 +27,7 @@
#include "components/autofill/core/browser/keyboard_accessory_metrics_logger.h" #include "components/autofill/core/browser/keyboard_accessory_metrics_logger.h"
#include "components/autofill/core/browser/popup_item_ids.h" #include "components/autofill/core/browser/popup_item_ids.h"
#include "components/autofill/core/common/autofill_constants.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_pref_names.h"
#include "components/autofill/core/common/autofill_util.h" #include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/form_data.h"
...@@ -938,6 +939,11 @@ void GetFormAndField(autofill::FormData* form, ...@@ -938,6 +939,11 @@ void GetFormAndField(autofill::FormData* form,
- (void)renderAutofillTypePredictions: - (void)renderAutofillTypePredictions:
(const std::vector<autofill::FormStructure*>&)structure { (const std::vector<autofill::FormStructure*>&)structure {
if (!base::FeatureList::IsEnabled(
autofill::features::kAutofillShowTypePredictions)) {
return;
}
base::DictionaryValue predictionData; base::DictionaryValue predictionData;
for (autofill::FormStructure* form : structure) { for (autofill::FormStructure* form : structure) {
auto formJSONData = base::MakeUnique<base::DictionaryValue>(); auto formJSONData = base::MakeUnique<base::DictionaryValue>();
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/sys_info.h" #include "base/sys_info.h"
#include "base/task_scheduler/switches.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/dom_distiller/core/dom_distiller_switches.h"
#include "components/feature_engagement/public/feature_constants.h" #include "components/feature_engagement/public/feature_constants.h"
#include "components/feature_engagement/public/feature_list.h" #include "components/feature_engagement/public/feature_list.h"
...@@ -202,7 +203,12 @@ const flags_ui::FeatureEntry kFeatureEntries[] = { ...@@ -202,7 +203,12 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
{"wk-http-system-cookie-store", {"wk-http-system-cookie-store",
flag_descriptions::kWKHTTPSystemCookieStoreName, flag_descriptions::kWKHTTPSystemCookieStoreName,
flag_descriptions::kWKHTTPSystemCookieStoreName, flags_ui::kOsIos, 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|. // Add all switches from experimental flags to |command_line|.
void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) { void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
......
...@@ -192,9 +192,7 @@ showAutofillPopup:(const std::vector<autofill::Suggestion>&)popup_suggestions ...@@ -192,9 +192,7 @@ showAutofillPopup:(const std::vector<autofill::Suggestion>&)popup_suggestions
- (void)sendAutofillTypePredictionsToRenderer: - (void)sendAutofillTypePredictionsToRenderer:
(const std::vector<autofill::FormStructure*>&)forms { (const std::vector<autofill::FormStructure*>&)forms {
NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults]; [_autofillAgent renderAutofillTypePredictions:forms];
if ([standardDefaults boolForKey:@"ShowAutofillTypePredictions"])
[_autofillAgent renderAutofillTypePredictions:forms];
} }
@end @end
...@@ -117,6 +117,11 @@ const char kNewFileDownloadDescription[] = ...@@ -117,6 +117,11 @@ const char kNewFileDownloadDescription[] =
"When enabled, uses new Download Manager UI and ios/web Download API as " "When enabled, uses new Download Manager UI and ios/web Download API as "
"backend."; "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 kTabSwitcherPresentsBVCName[] = "TabSwitcher Presents BVC";
const char kTabSwitcherPresentsBVCDescription[] = const char kTabSwitcherPresentsBVCDescription[] =
"When enabled, the tab switcher will present the BVC, so that when the " "When enabled, the tab switcher will present the BVC, so that when the "
......
...@@ -109,6 +109,11 @@ extern const char kNewPassKitDownloadDescription[]; ...@@ -109,6 +109,11 @@ extern const char kNewPassKitDownloadDescription[];
extern const char kNewFileDownloadName[]; extern const char kNewFileDownloadName[];
extern const char kNewFileDownloadDescription[]; 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 // Title and description for the flag to enable the TabSwitcher to present the
// BVC. // BVC.
extern const char kTabSwitcherPresentsBVCName[]; extern const char kTabSwitcherPresentsBVCName[];
......
...@@ -111,7 +111,6 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -111,7 +111,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeMemoryDebugging, ItemTypeMemoryDebugging,
ItemTypeViewSource, ItemTypeViewSource,
ItemTypeLogJavascript, ItemTypeLogJavascript,
ItemTypeShowAutofillTypePredictions,
ItemTypeCellCatalog, ItemTypeCellCatalog,
ItemTypeArticlesForYou, ItemTypeArticlesForYou,
}; };
...@@ -119,7 +118,6 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -119,7 +118,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
#if CHROMIUM_BUILD && !defined(NDEBUG) #if CHROMIUM_BUILD && !defined(NDEBUG)
NSString* kDevViewSourceKey = @"DevViewSource"; NSString* kDevViewSourceKey = @"DevViewSource";
NSString* kLogJavascriptKey = @"LogJavascript"; NSString* kLogJavascriptKey = @"LogJavascript";
NSString* kShowAutofillTypePredictionsKey = @"ShowAutofillTypePredictions";
#endif // CHROMIUM_BUILD && !defined(NDEBUG) #endif // CHROMIUM_BUILD && !defined(NDEBUG)
#pragma mark - SigninObserverBridge Class #pragma mark - SigninObserverBridge Class
...@@ -425,8 +423,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id, ...@@ -425,8 +423,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
toSectionWithIdentifier:SectionIdentifierDebug]; toSectionWithIdentifier:SectionIdentifierDebug];
[model addItem:[self logJavascriptConsoleSwitchItem] [model addItem:[self logJavascriptConsoleSwitchItem]
toSectionWithIdentifier:SectionIdentifierDebug]; toSectionWithIdentifier:SectionIdentifierDebug];
[model addItem:[self showAutofillTypePredictionsSwitchItem]
toSectionWithIdentifier:SectionIdentifierDebug];
[model addItem:[self materialCatalogDetailItem] [model addItem:[self materialCatalogDetailItem]
toSectionWithIdentifier:SectionIdentifierDebug]; toSectionWithIdentifier:SectionIdentifierDebug];
#endif // CHROMIUM_BUILD && !defined(NDEBUG) #endif // CHROMIUM_BUILD && !defined(NDEBUG)
...@@ -594,12 +590,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id, ...@@ -594,12 +590,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
withDefaultsKey:kLogJavascriptKey]; withDefaultsKey:kLogJavascriptKey];
} }
- (CollectionViewSwitchItem*)showAutofillTypePredictionsSwitchItem {
return [self switchItemWithType:ItemTypeShowAutofillTypePredictions
title:@"Show Autofill type predictions"
withDefaultsKey:kShowAutofillTypePredictionsKey];
}
- (CollectionViewDetailItem*)materialCatalogDetailItem { - (CollectionViewDetailItem*)materialCatalogDetailItem {
return [self detailItemWithType:ItemTypeCellCatalog return [self detailItemWithType:ItemTypeCellCatalog
text:@"Cell Catalog" text:@"Cell Catalog"
...@@ -725,18 +715,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id, ...@@ -725,18 +715,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
forControlEvents:UIControlEventValueChanged]; forControlEvents:UIControlEventValueChanged];
#else #else
NOTREACHED(); 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) #endif // CHROMIUM_BUILD && !defined(NDEBUG)
break; break;
} }
...@@ -813,7 +791,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id, ...@@ -813,7 +791,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
case ItemTypeMemoryDebugging: case ItemTypeMemoryDebugging:
case ItemTypeViewSource: case ItemTypeViewSource:
case ItemTypeLogJavascript: case ItemTypeLogJavascript:
case ItemTypeShowAutofillTypePredictions:
// Taps on these don't do anything. They have a switch as accessory view // Taps on these don't do anything. They have a switch as accessory view
// and only the switch is tappable. // and only the switch is tappable.
break; break;
...@@ -860,7 +837,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id, ...@@ -860,7 +837,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
switch (type) { switch (type) {
case ItemTypeLogJavascript: case ItemTypeLogJavascript:
case ItemTypeMemoryDebugging: case ItemTypeMemoryDebugging:
case ItemTypeShowAutofillTypePredictions:
case ItemTypeSigninPromo: case ItemTypeSigninPromo:
case ItemTypeViewSource: case ItemTypeViewSource:
return YES; return YES;
...@@ -927,21 +903,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id, ...@@ -927,21 +903,6 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
switchItem.on = newSwitchValue; switchItem.on = newSwitchValue;
[self setBooleanNSUserDefaultsValue:newSwitchValue forKey:kLogJavascriptKey]; [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) #endif // CHROMIUM_BUILD && !defined(NDEBUG)
#pragma mark Private methods #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