Commit 34b5e629 authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

Mac: Create share submenu when initially building main menu

When the native share menu was an experiment, we needed to replace the
Email Page Location menu item at runtime if the experiment was enabled.

It's now been enabled for a while, so this change removes the Email
Page Location menu item entirely and creates the Share menu item as
part of the initial menu creation.

Also removes the experiment infrastructure for share menu.

Bug: 770804
Change-Id: If5f17c213ffb185b461ee4e766423c647cb43e18
Reviewed-on: https://chromium-review.googlesource.com/1152007
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579110}
parent 9451b87d
...@@ -7448,9 +7448,6 @@ Please help our engineers fix this problem. Tell us what happened right before y ...@@ -7448,9 +7448,6 @@ Please help our engineers fix this problem. Tell us what happened right before y
<message name="IDS_EMAIL_LINK_MAC" desc="The Mac menu item to email a link to the current page in the share submenu"> <message name="IDS_EMAIL_LINK_MAC" desc="The Mac menu item to email a link to the current page in the share submenu">
Email Link Email Link
</message> </message>
<message name="IDS_EMAIL_PAGE_LOCATION_MAC" desc="The Mac menu item to email the page location in the file menu.">
Email Page Location
</message>
<message name="IDS_SHARING_MORE_MAC" desc="The Mac menu item to see more macOS share extensions in the share menu."> <message name="IDS_SHARING_MORE_MAC" desc="The Mac menu item to see more macOS share extensions in the share menu.">
More... More...
</message> </message>
......
...@@ -3537,11 +3537,6 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -3537,11 +3537,6 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kHtmlBasedUsernameDetectorDescription, kOsAll, flag_descriptions::kHtmlBasedUsernameDetectorDescription, kOsAll,
FEATURE_VALUE_TYPE( FEATURE_VALUE_TYPE(
password_manager::features::kHtmlBasedUsernameDetector)}, password_manager::features::kHtmlBasedUsernameDetector)},
#if defined(OS_MACOSX)
{"mac-system-share-menu", flag_descriptions::kMacSystemShareMenuName,
flag_descriptions::kMacSystemShareMenuDescription, kOsMac,
FEATURE_VALUE_TYPE(features::kMacSystemShareMenu)},
#endif // defined(OS_MACOSX)
{"enable-new-preconnect", flag_descriptions::kSpeculativePreconnectName, {"enable-new-preconnect", flag_descriptions::kSpeculativePreconnectName,
flag_descriptions::kSpeculativePreconnectDescription, kOsAll, flag_descriptions::kSpeculativePreconnectDescription, kOsAll,
......
...@@ -417,12 +417,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session; ...@@ -417,12 +417,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
[viewMenu removeItem:customizeItem]; [viewMenu removeItem:customizeItem];
} }
// In |applicationWillFinishLaunching| because FeatureList isn't [self initShareMenu];
// available at init time.
if (base::FeatureList::IsEnabled(features::kMacSystemShareMenu)) {
// Initialize the share menu.
[self initShareMenu];
}
// Remove "Enable Javascript in Apple Events" if the feature is disabled. // Remove "Enable Javascript in Apple Events" if the feature is disabled.
if (!base::FeatureList::IsEnabled( if (!base::FeatureList::IsEnabled(
...@@ -1298,21 +1293,11 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session; ...@@ -1298,21 +1293,11 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
NSMenu* mainMenu = [NSApp mainMenu]; NSMenu* mainMenu = [NSApp mainMenu];
NSMenu* fileMenu = [[mainMenu itemWithTag:IDC_FILE_MENU] submenu]; NSMenu* fileMenu = [[mainMenu itemWithTag:IDC_FILE_MENU] submenu];
NSString* shareMenuTitle = l10n_util::GetNSString(IDS_SHARE_MAC); NSString* shareMenuTitle = l10n_util::GetNSString(IDS_SHARE_MAC);
base::scoped_nsobject<NSMenuItem> shareMenuItem([[NSMenuItem alloc] NSMenuItem* shareMenuItem = [fileMenu itemWithTitle:shareMenuTitle];
initWithTitle:shareMenuTitle
action:NULL
keyEquivalent:@""]);
base::scoped_nsobject<NSMenu> shareSubmenu( base::scoped_nsobject<NSMenu> shareSubmenu(
[[NSMenu alloc] initWithTitle:shareMenuTitle]); [[NSMenu alloc] initWithTitle:shareMenuTitle]);
[shareSubmenu setDelegate:shareMenuController_]; [shareSubmenu setDelegate:shareMenuController_];
[shareMenuItem setSubmenu:shareSubmenu]; [shareMenuItem setSubmenu:shareSubmenu];
// Replace "Email Page Location" with Share.
// TODO(crbug.com/770804): Remove this code and update the XIB when
// the share menu launches.
NSInteger index = [fileMenu indexOfItemWithTag:IDC_EMAIL_PAGE_LOCATION];
DCHECK(index != -1);
[fileMenu removeItemAtIndex:index];
[fileMenu insertItem:shareMenuItem atIndex:index];
} }
// The Confirm to Quit preference is atypical in that the preference lives in // The Confirm to Quit preference is atypical in that the preference lives in
......
...@@ -2896,10 +2896,6 @@ const char kHostedAppsInWindowsDescription[] = ...@@ -2896,10 +2896,6 @@ const char kHostedAppsInWindowsDescription[] =
const char kMacRTLName[] = "Enable RTL"; const char kMacRTLName[] = "Enable RTL";
const char kMacRTLDescription[] = "Mirrors the UI for RTL language users"; const char kMacRTLDescription[] = "Mirrors the UI for RTL language users";
const char kMacSystemShareMenuName[] = "Enable System Share Menu";
const char kMacSystemShareMenuDescription[] =
"Enables sharing via macOS share extensions.";
const char kMacTouchBarName[] = "Hardware Touch Bar"; const char kMacTouchBarName[] = "Hardware Touch Bar";
const char kMacTouchBarDescription[] = "Control the use of the Touch Bar."; const char kMacTouchBarDescription[] = "Control the use of the Touch Bar.";
......
...@@ -1753,9 +1753,6 @@ extern const char kHostedAppsInWindowsDescription[]; ...@@ -1753,9 +1753,6 @@ extern const char kHostedAppsInWindowsDescription[];
extern const char kMacRTLName[]; extern const char kMacRTLName[];
extern const char kMacRTLDescription[]; extern const char kMacRTLDescription[];
extern const char kMacSystemShareMenuName[];
extern const char kMacSystemShareMenuDescription[];
extern const char kMacTouchBarName[]; extern const char kMacTouchBarName[];
extern const char kMacTouchBarDescription[]; extern const char kMacTouchBarDescription[];
......
...@@ -96,8 +96,7 @@ base::scoped_nsobject<NSMenuItem> BuildFileMenu(NSApplication* nsapp, ...@@ -96,8 +96,7 @@ base::scoped_nsobject<NSMenuItem> BuildFileMenu(NSApplication* nsapp,
Item(IDS_CLOSE_TAB_MAC).command_id(IDC_CLOSE_TAB), Item(IDS_CLOSE_TAB_MAC).command_id(IDC_CLOSE_TAB),
Item(IDS_SAVE_PAGE_MAC).command_id(IDC_SAVE_PAGE), Item(IDS_SAVE_PAGE_MAC).command_id(IDC_SAVE_PAGE),
Item().is_separator(), Item().is_separator(),
Item(IDS_EMAIL_PAGE_LOCATION_MAC) Item(IDS_SHARE_MAC),
.command_id(IDC_EMAIL_PAGE_LOCATION),
Item().is_separator(), Item(IDS_PRINT).command_id(IDC_PRINT), Item().is_separator(), Item(IDS_PRINT).command_id(IDC_PRINT),
Item(IDS_PRINT_USING_SYSTEM_DIALOG_MAC) Item(IDS_PRINT_USING_SYSTEM_DIALOG_MAC)
.command_id(IDC_BASIC_PRINT) .command_id(IDC_BASIC_PRINT)
......
...@@ -352,9 +352,6 @@ const base::Feature kMacRTL{"MacRTL", base::FEATURE_ENABLED_BY_DEFAULT}; ...@@ -352,9 +352,6 @@ const base::Feature kMacRTL{"MacRTL", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kMacFullSizeContentView{"MacFullSizeContentView", const base::Feature kMacFullSizeContentView{"MacFullSizeContentView",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
// Enables "Share" submenu in File menu.
const base::Feature kMacSystemShareMenu{"MacSystemShareMenu",
base::FEATURE_ENABLED_BY_DEFAULT};
#endif #endif
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
......
...@@ -192,7 +192,6 @@ extern const base::Feature kLsdPermissionPrompt; ...@@ -192,7 +192,6 @@ extern const base::Feature kLsdPermissionPrompt;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
extern const base::Feature kMacRTL; extern const base::Feature kMacRTL;
extern const base::Feature kMacFullSizeContentView; extern const base::Feature kMacFullSizeContentView;
extern const base::Feature kMacSystemShareMenu;
#endif #endif
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
......
...@@ -21,7 +21,6 @@ IDS_OPEN_LOCATION_MAC 120 ...@@ -21,7 +21,6 @@ IDS_OPEN_LOCATION_MAC 120
IDS_CLOSE_WINDOW_MAC 121 IDS_CLOSE_WINDOW_MAC 121
IDS_CLOSE_TAB_MAC 122 IDS_CLOSE_TAB_MAC 122
IDS_SAVE_PAGE_MAC 123 IDS_SAVE_PAGE_MAC 123
IDS_EMAIL_PAGE_LOCATION_MAC 124
IDS_PRINT 125 IDS_PRINT 125
IDS_PRINT_USING_SYSTEM_DIALOG_MAC 126 IDS_PRINT_USING_SYSTEM_DIALOG_MAC 126
IDS_EDIT_MENU_MAC 127 IDS_EDIT_MENU_MAC 127
......
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