Commit 9d8386d4 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Remove flag kCopiedContentBehavior

The feature has been ramped to 100% and enabled by default for a few
months, so now the flag can be removed.

Bug: 932116
Change-Id: I97a1c9f8abf59bf1db2e969443b60a2c190bbd69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865225
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706873}
parent 0f83eee8
......@@ -1228,8 +1228,6 @@ enum class EnterTabSwitcherSnapshotResult {
NSString* fieldTrialValueKey =
base::SysUTF8ToNSString(app_group::kChromeExtensionFieldTrialPreference);
NSNumber* copiedContentBehaviorValue = [NSNumber
numberWithBool:base::FeatureList::IsEnabled(kCopiedContentBehavior)];
// Add other field trial values here if they are needed by extensions.
// The general format is
......@@ -1240,10 +1238,6 @@ enum class EnterTabSwitcherSnapshotResult {
// }
// }
NSDictionary* fieldTrialValues = @{
base::SysUTF8ToNSString(kCopiedContentBehavior.name) : @{
kFieldTrialValueKey : copiedContentBehaviorValue,
kFieldTrialVersionKey : kCopiedContentBehaviorVersion
}
};
[sharedDefaults setObject:fieldTrialValues forKey:fieldTrialValueKey];
}
......
......@@ -2089,9 +2089,6 @@ New Search
<message name="IDS_IOS_OPEN_REPEATEDLY_ANOTHER_APP_BLOCK" desc="Text on the button, when tapped will block opening an external application for this browsing session. [iOS only]">
Block
</message>
<message name="IDS_IOS_PASTE_AND_GO" desc="Text in the editing menu shown when long-pressing the omnibox. Enables pasting the current contents of the clipboard and searching the text or navigating to the url. [iOS only]">
Paste and Go
</message>
<message name="IDS_IOS_NAVIGATION_BAR_ADD_BUTTON" desc="Label of the button allowing the user to add a new credit card to the list of their saved credit cards.">
Add
</message>
......
......@@ -423,9 +423,6 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
flag_descriptions::kEnableClipboardProviderImageSuggestionsDescription,
flags_ui::kOsIos,
FEATURE_VALUE_TYPE(omnibox::kEnableClipboardProviderImageSuggestions)},
{"copied-content-behavior", flag_descriptions::kCopiedContentBehaviorName,
flag_descriptions::kCopiedContentBehaviorName, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(kCopiedContentBehavior)},
{"snapshot-draw-view", flag_descriptions::kSnapshotDrawViewName,
flag_descriptions::kSnapshotDrawViewDescription, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(kSnapshotDrawView)},
......
......@@ -124,12 +124,6 @@ const char kConfirmInfobarMessagesUIName[] = "Confirm Infobars Messages UI";
const char kConfirmInfobarMessagesUIDescription[] =
"When enabled Confirm Infobars use the new Messages UI.";
const char kCopiedContentBehaviorName[] =
"Enable differentiating between copied urls, text, and images";
const char kCopiedContentBehaviorDescription[] =
"When enabled, places that handled copied urls (omnibox long-press, toolbar"
"menus) will differentiate between copied urls, text, and images.";
const char kCreditCardScannerName[] = "Enable the 'Use Camera' button";
const char kCreditCardScannerDescription[] =
"Allow a user to scan a credit card using the credit card camera scanner."
......
......@@ -97,11 +97,6 @@ extern const char kCollectionsCardPresentationStyleDescription[];
extern const char kConfirmInfobarMessagesUIName[];
extern const char kConfirmInfobarMessagesUIDescription[];
// Title and description for the flag to diffentiate between copied
// urls, strings, and images.
extern const char kCopiedContentBehaviorName[];
extern const char kCopiedContentBehaviorDescription[];
// Title and description for the flag to scan a new credit card using the
// camera.
extern const char kCreditCardScannerName[];
......
......@@ -451,25 +451,18 @@ const double kFullscreenProgressBadgeViewThreshold = 0.85;
// when it's the first time setting the first responder.
dispatch_async(dispatch_get_main_queue(), ^{
UIMenuController* menu = [UIMenuController sharedMenuController];
if (base::FeatureList::IsEnabled(kCopiedContentBehavior)) {
UIMenuItem* searchCopiedImage = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString((IDS_IOS_SEARCH_COPIED_IMAGE))
action:@selector(searchCopiedImage:)];
UIMenuItem* visitCopiedLink = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_VISIT_COPIED_LINK)
action:@selector(visitCopiedLink:)];
UIMenuItem* searchCopiedText = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_SEARCH_COPIED_TEXT)
action:@selector(searchCopiedText:)];
[menu setMenuItems:@[
searchCopiedImage, visitCopiedLink, searchCopiedText
]];
} else {
UIMenuItem* pasteAndGo = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_PASTE_AND_GO)
action:@selector(pasteAndGo:)];
[menu setMenuItems:@[ pasteAndGo ]];
}
UIMenuItem* searchCopiedImage = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString((IDS_IOS_SEARCH_COPIED_IMAGE))
action:@selector(searchCopiedImage:)];
UIMenuItem* visitCopiedLink = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_VISIT_COPIED_LINK)
action:@selector(visitCopiedLink:)];
UIMenuItem* searchCopiedText = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_SEARCH_COPIED_TEXT)
action:@selector(searchCopiedText:)];
[menu setMenuItems:@[
searchCopiedImage, visitCopiedLink, searchCopiedText
]];
[menu setTargetRect:self.locationBarSteadyView.frame inView:self.view];
[menu setMenuVisible:YES animated:YES];
......@@ -487,18 +480,11 @@ const double kFullscreenProgressBadgeViewThreshold = 0.85;
return YES;
}
// remove along with flag kCopiedContentBehavior
if (action == @selector(pasteAndGo:)) {
DCHECK(!base::FeatureList::IsEnabled(kCopiedContentBehavior));
return UIPasteboard.generalPasteboard.string.length > 0;
}
if (action == @selector(searchCopiedImage:) ||
action == @selector(visitCopiedLink:) ||
action == @selector(searchCopiedText:)) {
ClipboardRecentContent* clipboardRecentContent =
ClipboardRecentContent::GetInstance();
DCHECK(base::FeatureList::IsEnabled(kCopiedContentBehavior));
if (self.searchByImageEnabled &&
clipboardRecentContent->GetRecentImageFromClipboard().has_value()) {
return action == @selector(searchCopiedImage:);
......@@ -519,7 +505,6 @@ const double kFullscreenProgressBadgeViewThreshold = 0.85;
}
- (void)searchCopiedImage:(id)sender {
DCHECK(base::FeatureList::IsEnabled(kCopiedContentBehavior));
if (base::Optional<gfx::Image> optionalImage =
ClipboardRecentContent::GetInstance()
->GetRecentImageFromClipboard()) {
......@@ -540,18 +525,14 @@ const double kFullscreenProgressBadgeViewThreshold = 0.85;
// so we need two different selectors.
- (void)pasteAndGo:(id)sender {
NSString* query;
if (base::FeatureList::IsEnabled(kCopiedContentBehavior)) {
ClipboardRecentContent* clipboardRecentContent =
ClipboardRecentContent::GetInstance();
if (base::Optional<GURL> optionalUrl =
clipboardRecentContent->GetRecentURLFromClipboard()) {
query = base::SysUTF8ToNSString(optionalUrl.value().spec());
} else if (base::Optional<base::string16> optionalText =
clipboardRecentContent->GetRecentTextFromClipboard()) {
query = base::SysUTF16ToNSString(optionalText.value());
}
} else {
query = UIPasteboard.generalPasteboard.string;
ClipboardRecentContent* clipboardRecentContent =
ClipboardRecentContent::GetInstance();
if (base::Optional<GURL> optionalUrl =
clipboardRecentContent->GetRecentURLFromClipboard()) {
query = base::SysUTF8ToNSString(optionalUrl.value().spec());
} else if (base::Optional<base::string16> optionalText =
clipboardRecentContent->GetRecentTextFromClipboard()) {
query = base::SysUTF16ToNSString(optionalText.value());
}
[self.dispatcher loadQuery:query immediately:YES];
}
......
......@@ -92,24 +92,16 @@ const CGFloat kClearButtonSize = 28.0f;
// Add Paste and Go option to the editing menu
UIMenuController* menu = [UIMenuController sharedMenuController];
if (base::FeatureList::IsEnabled(kCopiedContentBehavior)) {
UIMenuItem* searchCopiedImage = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_SEARCH_COPIED_IMAGE)
action:@selector(searchCopiedImage:)];
UIMenuItem* visitCopiedLink = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_VISIT_COPIED_LINK)
action:@selector(visitCopiedLink:)];
UIMenuItem* searchCopiedText = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_SEARCH_COPIED_TEXT)
action:@selector(searchCopiedText:)];
[menu
setMenuItems:@[ searchCopiedImage, visitCopiedLink, searchCopiedText ]];
} else {
UIMenuItem* pasteAndGo = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_PASTE_AND_GO)
action:NSSelectorFromString(@"pasteAndGo:")];
[menu setMenuItems:@[ pasteAndGo ]];
}
UIMenuItem* searchCopiedImage = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_SEARCH_COPIED_IMAGE)
action:@selector(searchCopiedImage:)];
UIMenuItem* visitCopiedLink = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_VISIT_COPIED_LINK)
action:@selector(visitCopiedLink:)];
UIMenuItem* searchCopiedText = [[UIMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_IOS_SEARCH_COPIED_TEXT)
action:@selector(searchCopiedText:)];
[menu setMenuItems:@[ searchCopiedImage, visitCopiedLink, searchCopiedText ]];
self.textField.placeholderTextColor = [self placeholderAndClearButtonColor];
self.textField.placeholder = l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT);
......@@ -309,12 +301,6 @@ const CGFloat kClearButtonSize = 28.0f;
#pragma mark - UIMenuItem
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
// Remove with flag kCopiedContentBehavior
if (action == @selector(pasteAndGo:)) {
DCHECK(!base::FeatureList::IsEnabled(kCopiedContentBehavior));
return UIPasteboard.generalPasteboard.string.length > 0;
}
if (action == @selector(searchCopiedImage:) ||
action == @selector(visitCopiedLink:) ||
action == @selector(searchCopiedText:)) {
......@@ -336,7 +322,6 @@ const CGFloat kClearButtonSize = 28.0f;
}
- (void)searchCopiedImage:(id)sender {
DCHECK(base::FeatureList::IsEnabled(kCopiedContentBehavior));
if (base::Optional<gfx::Image> optionalImage =
ClipboardRecentContent::GetInstance()
->GetRecentImageFromClipboard()) {
......@@ -358,18 +343,14 @@ const CGFloat kClearButtonSize = 28.0f;
// so we need two different selectors.
- (void)pasteAndGo:(id)sender {
NSString* query;
if (base::FeatureList::IsEnabled(kCopiedContentBehavior)) {
ClipboardRecentContent* clipboardRecentContent =
ClipboardRecentContent::GetInstance();
if (base::Optional<GURL> optionalUrl =
clipboardRecentContent->GetRecentURLFromClipboard()) {
query = base::SysUTF8ToNSString(optionalUrl.value().spec());
} else if (base::Optional<base::string16> optionalText =
clipboardRecentContent->GetRecentTextFromClipboard()) {
query = base::SysUTF16ToNSString(optionalText.value());
}
} else {
query = UIPasteboard.generalPasteboard.string;
ClipboardRecentContent* clipboardRecentContent =
ClipboardRecentContent::GetInstance();
if (base::Optional<GURL> optionalUrl =
clipboardRecentContent->GetRecentURLFromClipboard()) {
query = base::SysUTF8ToNSString(optionalUrl.value().spec());
} else if (base::Optional<base::string16> optionalText =
clipboardRecentContent->GetRecentTextFromClipboard()) {
query = base::SysUTF16ToNSString(optionalText.value());
}
[self.dispatcher loadQuery:query immediately:YES];
[self.dispatcher cancelOmniboxEdit];
......
......@@ -136,18 +136,14 @@ using base::UserMetricsAction;
case PopupMenuActionPasteAndGo: {
RecordAction(UserMetricsAction("MobileMenuPasteAndGo"));
NSString* query;
if (base::FeatureList::IsEnabled(kCopiedContentBehavior)) {
ClipboardRecentContent* clipboardRecentContent =
ClipboardRecentContent::GetInstance();
if (base::Optional<GURL> optional_url =
clipboardRecentContent->GetRecentURLFromClipboard()) {
query = base::SysUTF8ToNSString(optional_url.value().spec());
} else if (base::Optional<base::string16> optional_text =
clipboardRecentContent->GetRecentTextFromClipboard()) {
query = base::SysUTF16ToNSString(optional_text.value());
}
} else {
query = [UIPasteboard generalPasteboard].string;
ClipboardRecentContent* clipboardRecentContent =
ClipboardRecentContent::GetInstance();
if (base::Optional<GURL> optional_url =
clipboardRecentContent->GetRecentURLFromClipboard()) {
query = base::SysUTF8ToNSString(optional_url.value().spec());
} else if (base::Optional<base::string16> optional_text =
clipboardRecentContent->GetRecentTextFromClipboard()) {
query = base::SysUTF16ToNSString(optional_text.value());
}
[self.dispatcher loadQuery:query immediately:YES];
break;
......@@ -175,7 +171,6 @@ using base::UserMetricsAction;
[self.dispatcher showQRScanner];
break;
case PopupMenuActionSearchCopiedImage: {
DCHECK(base::FeatureList::IsEnabled(kCopiedContentBehavior));
RecordAction(UserMetricsAction("MobileMenuSearchCopiedImage"));
ClipboardRecentContent* clipboardRecentContent =
ClipboardRecentContent::GetInstance();
......
......@@ -705,32 +705,23 @@ PopupMenuToolsItem* CreateTableViewItem(int titleID,
// represent a section in the popup menu. Having one sub array means having
// all the items in the same section.
PopupMenuToolsItem* copiedContentItem = nil;
if (base::FeatureList::IsEnabled(kCopiedContentBehavior)) {
ClipboardRecentContent* clipboardRecentContent =
ClipboardRecentContent::GetInstance();
if (search_engines::SupportsSearchByImage(self.templateURLService) &&
clipboardRecentContent->GetRecentImageFromClipboard()) {
copiedContentItem = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_SEARCH_COPIED_IMAGE,
PopupMenuActionSearchCopiedImage, @"popup_menu_paste_and_go",
kToolsMenuCopiedImageSearch);
} else if (clipboardRecentContent->GetRecentURLFromClipboard()) {
copiedContentItem = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_VISIT_COPIED_LINK, PopupMenuActionPasteAndGo,
@"popup_menu_paste_and_go", kToolsMenuPasteAndGo);
} else if (clipboardRecentContent->GetRecentTextFromClipboard()) {
copiedContentItem = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_SEARCH_COPIED_TEXT, PopupMenuActionPasteAndGo,
@"popup_menu_paste_and_go", kToolsMenuPasteAndGo);
}
} else {
NSString* pasteboardString = [UIPasteboard generalPasteboard].string;
if (pasteboardString) {
copiedContentItem = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_PASTE_AND_GO, PopupMenuActionPasteAndGo,
@"popup_menu_paste_and_go", kToolsMenuPasteAndGo);
}
ClipboardRecentContent* clipboardRecentContent =
ClipboardRecentContent::GetInstance();
if (search_engines::SupportsSearchByImage(self.templateURLService) &&
clipboardRecentContent->GetRecentImageFromClipboard()) {
copiedContentItem = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_SEARCH_COPIED_IMAGE,
PopupMenuActionSearchCopiedImage, @"popup_menu_paste_and_go",
kToolsMenuCopiedImageSearch);
} else if (clipboardRecentContent->GetRecentURLFromClipboard()) {
copiedContentItem = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_VISIT_COPIED_LINK, PopupMenuActionPasteAndGo,
@"popup_menu_paste_and_go", kToolsMenuPasteAndGo);
} else if (clipboardRecentContent->GetRecentTextFromClipboard()) {
copiedContentItem = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_SEARCH_COPIED_TEXT, PopupMenuActionPasteAndGo,
@"popup_menu_paste_and_go", kToolsMenuPasteAndGo);
}
if (copiedContentItem) {
if (base::FeatureList::IsEnabled(kToolbarNewTabButton)) {
......
......@@ -16,9 +16,6 @@ const base::Feature kOmniboxPopupShortcutIconsInZeroState{
const base::Feature kSnapshotDrawView{"SnapshotDrawView",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kCopiedContentBehavior{"CopiedContentBehavior",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kSettingsRefresh{"SettingsRefresh",
base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -17,11 +17,6 @@ extern const base::Feature kOmniboxPopupShortcutIconsInZeroState;
// Feature to take snapshots using |-drawViewHierarchy:|.
extern const base::Feature kSnapshotDrawView;
// Feature to rework handling of copied content (url/string/image) in the ui.
// This feature is used in extensions. If you modify it significantly, you may
// want to update the version in |app_group_field_trial_version|.
extern const base::Feature kCopiedContentBehavior;
// Feature to apply UI Refresh theme to the settings.
extern const base::Feature kSettingsRefresh;
......
......@@ -17,7 +17,4 @@ extern NSString* const kFieldTrialValueKey;
// The dictionary key for the trial version.
extern NSString* const kFieldTrialVersionKey;
// The current version of the copied content behavior feature.
extern NSNumber* const kCopiedContentBehaviorVersion;
#endif /* IOS_CHROME_COMMON_APP_GROUP_APP_GROUP_FIELD_TRIAL_VERSION_H_ */
......@@ -10,5 +10,3 @@
NSString* const kFieldTrialValueKey = @"FieldTrialValue";
NSString* const kFieldTrialVersionKey = @"FieldTrialVersion";
NSNumber* const kCopiedContentBehaviorVersion = [NSNumber numberWithInt:0];
......@@ -30,7 +30,6 @@
@property(nonatomic, copy, nullable) NSDictionary* fieldTrialValues;
// Whether the current default search engine supports search by image
@property(nonatomic, assign) BOOL supportsSearchByImage;
@property(nonatomic, readonly) BOOL copiedContentBehaviorEnabled;
@property(nonatomic, strong) AppGroupCommand* command;
@end
......@@ -117,14 +116,15 @@
UIImage* copiedImage;
CopiedContentType type = CopiedContentTypeNone;
if (UIImage* image = [self getCopiedImageUsingFlag]) {
if (UIImage* image = [self getCopiedImageFromClipboard]) {
copiedImage = image;
type = CopiedContentTypeImage;
} else if (NSURL* url =
[self.clipboardRecentContent recentURLFromClipboard]) {
copiedText = url.absoluteString;
type = CopiedContentTypeURL;
} else if (NSString* text = [self getCopiedTextUsingFlag]) {
} else if (NSString* text =
[self.clipboardRecentContent recentTextFromClipboard]) {
copiedText = text;
type = CopiedContentTypeString;
}
......@@ -134,21 +134,10 @@
copiedImage:copiedImage];
}
// Helper method to encapsulate both checking the flag and getting the copied
// text.
// TODO(crbug.com/932116): Can be removed when the flag is cleaned up.
- (NSString*)getCopiedTextUsingFlag {
if (!self.copiedContentBehaviorEnabled) {
return nil;
}
return [self.clipboardRecentContent recentTextFromClipboard];
}
// Helper method to encapsulate both checking the flag and getting the copied
// image.
// TODO(crbug.com/932116): Can be removed when the flag is cleaned up.
- (UIImage*)getCopiedImageUsingFlag {
if (!self.copiedContentBehaviorEnabled || !self.supportsSearchByImage) {
// Helper method to encapsulate checking whether the current search engine
// supports search-by-image and getting the copied image.
- (UIImage*)getCopiedImageFromClipboard {
if (!self.supportsSearchByImage) {
return nil;
}
return [self.clipboardRecentContent recentImageFromClipboard];
......@@ -285,16 +274,4 @@
}
}
- (BOOL)copiedContentBehaviorEnabled {
NSDictionary* storedData = self.fieldTrialValues[@"CopiedContentBehavior"];
NSNumber* storedVersion =
base::mac::ObjCCast<NSNumber>(storedData[kFieldTrialVersionKey]);
if (!storedVersion ||
![kCopiedContentBehaviorVersion isEqualToNumber:storedVersion]) {
return NO;
}
return [storedData[kFieldTrialValueKey] boolValue];
}
@end
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