OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/cocoa/share_menu/share_menu_manager.h" |
| 6 |
| 7 #import "chrome/browser/ui/cocoa/share_menu/share_menu_controller.h" |
| 8 #import <AppKit/AppKit.h> |
| 9 |
| 10 static NSString* kSharePrefPane = |
| 11 @"/System/Library/PreferencePanes/Extensions.prefPane"; |
| 12 |
| 13 @interface ShareMenuManager() |
| 14 + (void)displayShareOptionsManagerDialog; |
| 15 @end |
| 16 |
| 17 @implementation ShareMenuManager |
| 18 |
| 19 + (void)displayShareOptionsManagerDialog { |
| 20 [[NSWorkspace sharedWorkspace] openFile:kSharePrefPane]; |
| 21 } |
| 22 |
| 23 + (void)dispatchSharingServiceEventsFor:(NSSharingService*)service |
| 24 AndPageInfo:(NSDictionary*)info { |
| 25 base::scoped_nsobject<NSArray> shareItems; |
| 26 NSArray* items = [info allValues]; |
| 27 if ([service canPerformWithItems:items]) { |
| 28 if ([service isEqualTo:[NSSharingService sharingServiceNamed |
| 29 : NSSharingServiceNameComposeEmail]]) { |
| 30 shareItems.reset([[NSArray alloc] |
| 31 initWithObjects:[info objectForKey:kPageUrl], |
| 32 [info objectForKey:kPageHtml], nil]); |
| 33 |
| 34 } else { |
| 35 shareItems.reset([[NSArray alloc] |
| 36 initWithObjects:[info objectForKey:kPageUrl], |
| 37 [info objectForKey:kPageScreenShot], nil]); |
| 38 } |
| 39 [service performWithItems:shareItems]; |
| 40 |
| 41 } else { |
| 42 NSLog(@"custom service %@", service); |
| 43 if ([service.title isEqualToString:@"More"]) { |
| 44 NSLog(@"opens a printer dialog here"); |
| 45 [ShareMenuManager displayShareOptionsManagerDialog]; |
| 46 } |
| 47 } |
| 48 } |
| 49 |
| 50 @end |
OLD | NEW |