Index: chrome/browser/app_controller_mac.mm |
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm |
index b1e69241a059ef89a2bbc2758b5c40aac4a3cc82..ab0753f42843cb33adb85bd0e241065f5159fc7f 100644 |
--- a/chrome/browser/app_controller_mac.mm |
+++ b/chrome/browser/app_controller_mac.mm |
@@ -20,8 +20,11 @@ |
#include "chrome/browser/download/download_manager.h" |
#include "chrome/browser/instant/instant_confirm_dialog.h" |
#include "chrome/browser/prefs/pref_service.h" |
+#include "chrome/browser/printing/print_dialog_cloud.h" |
#include "chrome/browser/printing/print_job_manager.h" |
+#include "chrome/browser/printing/cloud_print/virtual_driver_install_helper.h" |
#include "chrome/browser/profiles/profile_manager.h" |
+#include "chrome/browser/service/service_process_control.h" |
#include "chrome/browser/sessions/session_service.h" |
#include "chrome/browser/sessions/session_service_factory.h" |
#include "chrome/browser/sessions/tab_restore_service.h" |
@@ -50,10 +53,12 @@ |
#include "chrome/common/chrome_paths_internal.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/pref_names.h" |
+#include "chrome/common/service_messages.h" |
#include "chrome/common/url_constants.h" |
#include "content/browser/browser_thread.h" |
#include "content/browser/tab_contents/tab_contents.h" |
#include "content/browser/user_metrics.h" |
+#include "content/common/cloud_print_class_mac.h" |
#include "content/common/content_notification_types.h" |
#include "content/common/notification_service.h" |
#include "grit/chromium_strings.h" |
@@ -153,6 +158,10 @@ void RecordLastRunAppBundlePath() { |
} // anonymous namespace |
+const AEEventClass cloudPrintInstallClass = 'GCPi'; |
+const AEEventClass cloudPrintUninstallClass = 'GCPu'; |
+ |
+ |
@interface AppController (Private) |
- (void)initMenuState; |
- (void)initProfileMenu; |
@@ -161,6 +170,8 @@ void RecordLastRunAppBundlePath() { |
- (void)openUrls:(const std::vector<GURL>&)urls; |
- (void)getUrl:(NSAppleEventDescriptor*)event |
withReply:(NSAppleEventDescriptor*)reply; |
+- (void)submitPrint:(NSAppleEventDescriptor*)event; |
+- (void)installCloudPrint:(NSAppleEventDescriptor*)event; |
- (void)windowLayeringDidChange:(NSNotification*)inNotification; |
- (void)windowChangedToProfile:(Profile*)profile; |
- (void)checkForAnyKeyWindows; |
@@ -173,6 +184,37 @@ void RecordLastRunAppBundlePath() { |
@synthesize startupComplete = startupComplete_; |
+// Apple Event handler that receives print event from service |
+// process, gets the required data and launches Print dialog |
Nico
2011/07/22 16:53:55
trailing .
|
+- (void)submitPrint:(NSAppleEventDescriptor*)event { |
+ // Pull parameter list out of Apple Event. |
+ NSAppleEventDescriptor *paramList = |
+ [event paramDescriptorForKeyword:cloudPrintClass]; |
Nico
2011/07/22 16:53:55
Indent 2 more
|
+ |
+ if (paramList != NULL) { |
+ // Pull required fields out of parameter list. |
+ NSString* mime = [[paramList descriptorAtIndex:1] stringValue]; |
+ NSString* inputPath = [[paramList descriptorAtIndex:2] stringValue]; |
+ NSString* printTitle = [[paramList descriptorAtIndex:3] stringValue]; |
+ // Convert the title to UTF 16 as required. |
+ string16 title16 = UTF8ToUTF16([printTitle UTF8String]); |
Nico
2011/07/22 16:53:55
Use SysNSStringToUTF16() from base/sys_string_conv
|
+ print_dialog_cloud::CreatePrintDialogForFile( |
+ FilePath([inputPath UTF8String]),title16, [mime UTF8String], false); |
+ } |
+} |
+ |
+// Calls the helper class to install the virtual driver to the |
+// service process. |
+- (void)installCloudPrint:(NSAppleEventDescriptor*)event { |
+ cloud_print::VirtualDriverInstallHelper::SetUpInstall(); |
+} |
+ |
+// Calls the helper class to uninstall the virtual driver to the |
+// service process. |
+- (void)uninstallCloudPrint:(NSAppleEventDescriptor*)event { |
+ cloud_print::VirtualDriverInstallHelper::SetUpUninstall(); |
+} |
+ |
// This method is called very early in application startup (ie, before |
// the profile is loaded or any preferences have been registered). Defer any |
// user-data initialization until -applicationDidFinishLaunching:. |
@@ -184,6 +226,19 @@ void RecordLastRunAppBundlePath() { |
forEventClass:kInternetEventClass |
andEventID:kAEGetURL]; |
[em setEventHandler:self |
+ andSelector:@selector(submitPrint:) |
+ forEventClass:cloudPrintClass |
+ andEventID:cloudPrintClass]; // Event handler for cloud print. |
+ // Install and uninstall handlers for virtual drivers. |
+ [em setEventHandler:self |
+ andSelector:@selector(installCloudPrint:) |
+ forEventClass:cloudPrintInstallClass |
+ andEventID:cloudPrintInstallClass]; |
+ [em setEventHandler:self |
+ andSelector:@selector(uninstallCloudPrint:) |
+ forEventClass:cloudPrintUninstallClass |
+ andEventID:cloudPrintUninstallClass]; |
+ [em setEventHandler:self |
andSelector:@selector(getUrl:withReply:) |
forEventClass:'WWW!' // A particularly ancient AppleEvent that dates |
andEventID:'OURL']; // back to the Spyglass days. |