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..8eb2cddb2cbc0ac653f22b889f4edf4f82b73d78 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 cloud_print_install_class = 'GCPi'; |
+const AEEventClass cloud_print_uninstall_class = '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 recieves print event from service |
Nico
2011/07/21 22:22:50
receives
|
+// process, gets the required data and launches Print dialog |
+- (void)submitPrint:(NSAppleEventDescriptor*)event { |
+ //Pull parameter list out of Apple Event. |
Nico
2011/07/21 22:22:50
space after //
|
+ NSAppleEventDescriptor *param_list = |
+ [event paramDescriptorForKeyword:cloud_print_class]; |
Nico
2011/07/21 22:22:50
indent 4
|
+ |
+ if (! (param_list == NULL)) { |
Nico
2011/07/21 22:22:50
!=
|
+ //Pull required fields out of parameter list. |
+ NSString * mime = [[param_list descriptorAtIndex:1] stringValue]; |
Nico
2011/07/21 22:22:50
no space in front of *
|
+ NSString * input_path = [[param_list descriptorAtIndex:2] stringValue]; |
Nico
2011/07/21 22:22:50
objc code uses camelCase
|
+ NSString * print_title = [[param_list descriptorAtIndex:3] stringValue]; |
+ //Conver the title to UTF 16 as required. |
Nico
2011/07/21 22:22:50
space after //
Convert
|
+ string16 title16 = UTF8ToUTF16([print_title UTF8String]); |
+ print_dialog_cloud ::CreatePrintDialogForFile( |
Nico
2011/07/21 22:22:50
no space in front of ::
|
+ FilePath([input_path 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:cloud_print_class |
+ andEventID:cloud_print_class]; //Event handler for cloud print. |
+ //Install and uninstall handlers for virtual drivers. |
+ [em setEventHandler:self |
+ andSelector:@selector(installCloudPrint:) |
+ forEventClass:cloud_print_install_class |
+ andEventID:cloud_print_install_class]; |
+ [em setEventHandler:self |
+ andSelector:@selector(uninstallCloudPrint:) |
+ forEventClass:cloud_print_uninstall_class |
+ andEventID:cloud_print_uninstall_class]; |
+ [em setEventHandler:self |
andSelector:@selector(getUrl:withReply:) |
forEventClass:'WWW!' // A particularly ancient AppleEvent that dates |
andEventID:'OURL']; // back to the Spyglass days. |