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

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 1105143005: Issue 465302:System wide share options on Mac Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds an attachment to Mail Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/ui/browser_command_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/app_controller_mac.mm
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 811185b1137ff73a329ac7884da9505f6ba7ae96..d3952c6a8448a113f3a0e2366f40fb5f750f07ac 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -66,6 +66,7 @@
#import "chrome/browser/ui/cocoa/history_menu_bridge.h"
#include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
#import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h"
+#import "chrome/browser/ui/cocoa/share_menu/share_menu_controller.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
@@ -211,6 +212,7 @@ bool IsProfileSignedOut(Profile* profile) {
- (void)initMenuState;
- (void)initProfileMenu;
+- (void)initShareMenu;
- (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item;
- (void)updateDisplayMessageCenterPrefMenuItem:(NSMenuItem*)item;
- (void)registerServicesMenuTypesTo:(NSApplication*)app;
@@ -388,6 +390,10 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
// Initialize the Profile menu.
[self initProfileMenu];
+
+ // Initialize the Share menu. Call this method only for OSX versions >= 10.9.
+ if (base::mac::IsOSMavericksOrLater())
+ [self initShareMenu];
}
- (void)unregisterEventHandlers {
@@ -750,6 +756,11 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
EncodingMenuControllerDelegate::BuildEncodingMenu([self lastProfile],
encodingMenu);
+ // Implement delegate methods to rebuild share menu when the cursor hovers
+ // over the Share Menu Item.
+ NSMenu* fileMenu = [[[NSApp mainMenu] itemWithTag:IDC_FILE_MENU] submenu];
+ [fileMenu setDelegate:self];
+
// Instantiate the ProfileInfoCache observer so that we can get
// notified when a profile is deleted.
profileInfoCacheObserver_.reset(new AppControllerProfileObserver(
@@ -1303,6 +1314,23 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
[[ProfileMenuController alloc] initWithMainMenuItem:profileMenu]);
}
+- (void)initShareMenu {
+ NSMenu* mainMenu = [NSApp mainMenu];
+
+ shareMenuController_.reset(
+ [[ShareMenuController alloc] initWithMainMenu:mainMenu]);
+}
+
+// Rebuild the share menu when the cursor hovers over Share Menu Item.
+// This is to ensure Share menu has updated list of items since it has been
+// changed in System Pref panel.
+- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item {
+ if ([item tag] == IDC_SHARE_MENU) {
+ NSLog(@"menu item highlighted %@ %s", item, __FUNCTION__);
+ [shareMenuController_.get() rebuildShareMenu];
+ }
+}
+
// The Confirm to Quit preference is atypical in that the preference lives in
// the app menu right above the Quit menu item. This method will refresh the
// display of that item depending on the preference state.
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/ui/browser_command_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698