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

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 2950403002: [Mac] Add system share menu
Patch Set: CL comments Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "chrome/browser/ui/chrome_pages.h" 64 #include "chrome/browser/ui/chrome_pages.h"
65 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h" 65 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h"
66 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h" 66 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h"
67 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" 67 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h"
68 #import "chrome/browser/ui/cocoa/confirm_quit.h" 68 #import "chrome/browser/ui/cocoa/confirm_quit.h"
69 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" 69 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h"
70 #include "chrome/browser/ui/cocoa/handoff_active_url_observer_bridge.h" 70 #include "chrome/browser/ui/cocoa/handoff_active_url_observer_bridge.h"
71 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" 71 #import "chrome/browser/ui/cocoa/history_menu_bridge.h"
72 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" 72 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
73 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" 73 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h"
74 #import "chrome/browser/ui/cocoa/share_menu_controller.h"
74 #include "chrome/browser/ui/extensions/application_launch.h" 75 #include "chrome/browser/ui/extensions/application_launch.h"
75 #include "chrome/browser/ui/startup/startup_browser_creator.h" 76 #include "chrome/browser/ui/startup/startup_browser_creator.h"
76 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" 77 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
77 #include "chrome/browser/ui/tabs/tab_strip_model.h" 78 #include "chrome/browser/ui/tabs/tab_strip_model.h"
78 #include "chrome/browser/ui/user_manager.h" 79 #include "chrome/browser/ui/user_manager.h"
79 #include "chrome/browser/web_applications/web_app_mac.h" 80 #include "chrome/browser/web_applications/web_app_mac.h"
80 #include "chrome/common/chrome_paths_internal.h" 81 #include "chrome/common/chrome_paths_internal.h"
81 #include "chrome/common/chrome_switches.h" 82 #include "chrome/common/chrome_switches.h"
82 #include "chrome/common/cloud_print/cloud_print_class_mac.h" 83 #include "chrome/common/cloud_print/cloud_print_class_mac.h"
83 #include "chrome/common/extensions/extension_constants.h" 84 #include "chrome/common/extensions/extension_constants.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 selector:@selector(willPowerOff:) 343 selector:@selector(willPowerOff:)
343 name:NSWorkspaceWillPowerOffNotification 344 name:NSWorkspaceWillPowerOffNotification
344 object:nil]; 345 object:nil];
345 346
346 // Set up the command updater for when there are no windows open 347 // Set up the command updater for when there are no windows open
347 [self initMenuState]; 348 [self initMenuState];
348 349
349 // Initialize the Profile menu. 350 // Initialize the Profile menu.
350 [self initProfileMenu]; 351 [self initProfileMenu];
351 352
353 // Initialize the share menu.
354 [self initShareMenu];
355
352 // If the OSX version supports this method, the system will automatically 356 // If the OSX version supports this method, the system will automatically
353 // hide the item if there's no touch bar. However, for unsupported versions, 357 // hide the item if there's no touch bar. However, for unsupported versions,
354 // we'll have to manually remove the item from the menu. 358 // we'll have to manually remove the item from the menu.
355 if (![NSApp 359 if (![NSApp
356 respondsToSelector:@selector(toggleTouchBarCustomizationPalette:)]) { 360 respondsToSelector:@selector(toggleTouchBarCustomizationPalette:)]) {
357 NSMenu* mainMenu = [NSApp mainMenu]; 361 NSMenu* mainMenu = [NSApp mainMenu];
358 NSMenu* viewMenu = [[mainMenu itemWithTag:IDC_VIEW_MENU] submenu]; 362 NSMenu* viewMenu = [[mainMenu itemWithTag:IDC_VIEW_MENU] submenu];
359 NSMenuItem* customizeItem = [viewMenu itemWithTag:IDC_CUSTOMIZE_TOUCH_BAR]; 363 NSMenuItem* customizeItem = [viewMenu itemWithTag:IDC_CUSTOMIZE_TOUCH_BAR];
360 if (customizeItem) 364 if (customizeItem)
361 [viewMenu removeItem:customizeItem]; 365 [viewMenu removeItem:customizeItem];
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 return; 1219 return;
1216 } 1220 }
1217 1221
1218 // The controller will unhide the menu if necessary. 1222 // The controller will unhide the menu if necessary.
1219 [profileMenu setHidden:YES]; 1223 [profileMenu setHidden:YES];
1220 1224
1221 profileMenuController_.reset( 1225 profileMenuController_.reset(
1222 [[ProfileMenuController alloc] initWithMainMenuItem:profileMenu]); 1226 [[ProfileMenuController alloc] initWithMainMenuItem:profileMenu]);
1223 } 1227 }
1224 1228
1229 - (void)initShareMenu {
1230 shareMenuController_.reset([[ShareMenuController alloc] init]);
1231 NSMenu* mainMenu = [NSApp mainMenu];
1232 NSMenu* fileMenu = [[mainMenu itemWithTag:IDC_FILE_MENU] submenu];
1233 NSMenuItem* shareMenuItem =
1234 [fileMenu itemWithTitle:l10n_util::GetNSString(IDS_SHARE_MAC)];
Robert Sesek 2017/06/30 21:09:34 Maybe DCHECK(shareMenuItem) ?
1235 [[shareMenuItem submenu] setDelegate:shareMenuController_.get()];
1236 }
1237
1225 // The Confirm to Quit preference is atypical in that the preference lives in 1238 // The Confirm to Quit preference is atypical in that the preference lives in
1226 // the app menu right above the Quit menu item. This method will refresh the 1239 // the app menu right above the Quit menu item. This method will refresh the
1227 // display of that item depending on the preference state. 1240 // display of that item depending on the preference state.
1228 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item { 1241 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item {
1229 // Format the string so that the correct key equivalent is displayed. 1242 // Format the string so that the correct key equivalent is displayed.
1230 NSString* acceleratorString = [ConfirmQuitPanelController keyCommandString]; 1243 NSString* acceleratorString = [ConfirmQuitPanelController keyCommandString];
1231 NSString* title = l10n_util::GetNSStringF(IDS_CONFIRM_TO_QUIT_OPTION, 1244 NSString* title = l10n_util::GetNSStringF(IDS_CONFIRM_TO_QUIT_OPTION,
1232 base::SysNSStringToUTF16(acceleratorString)); 1245 base::SysNSStringToUTF16(acceleratorString));
1233 [item setTitle:title]; 1246 [item setTitle:title];
1234 1247
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 1656
1644 //--------------------------------------------------------------------------- 1657 //---------------------------------------------------------------------------
1645 1658
1646 namespace app_controller_mac { 1659 namespace app_controller_mac {
1647 1660
1648 bool IsOpeningNewWindow() { 1661 bool IsOpeningNewWindow() {
1649 return g_is_opening_new_window; 1662 return g_is_opening_new_window;
1650 } 1663 }
1651 1664
1652 } // namespace app_controller_mac 1665 } // namespace app_controller_mac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698