summaryrefslogtreecommitdiffstats
path: root/chrome/browser/app_controller_mac.mm
diff options
context:
space:
mode:
authorabeera@google.com <abeera@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-15 20:56:17 +0000
committerabeera@google.com <abeera@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-15 20:56:17 +0000
commita529af57f7b475e18cb878712c42c95c7c82e56b (patch)
treeea36e92433fecae3a8febb0635b4c8112a5a2ca3 /chrome/browser/app_controller_mac.mm
parent3ef7fb0d42affe262ab8cc3637a9982c65a59335 (diff)
downloadchromium_src-a529af57f7b475e18cb878712c42c95c7c82e56b.zip
chromium_src-a529af57f7b475e18cb878712c42c95c7c82e56b.tar.gz
chromium_src-a529af57f7b475e18cb878712c42c95c7c82e56b.tar.bz2
Virtual Cloud Print Driver for Mac.
Includes code for the driver itself. Also modifies the browser process as well as service process to register Apple Event handlers. Also changes the service process to allow registration of driver. BUG= TEST= Review URL: http://codereview.chromium.org/7485011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96825 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/app_controller_mac.mm')
-rw-r--r--chrome/browser/app_controller_mac.mm56
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 032f72d..f4d8f22 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -21,8 +21,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/cloud_print/virtual_driver_install_helper.h"
+#include "chrome/browser/printing/print_dialog_cloud.h"
#include "chrome/browser/printing/print_job_manager.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"
@@ -51,10 +54,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"
@@ -154,6 +159,9 @@ void RecordLastRunAppBundlePath() {
} // anonymous namespace
+const AEEventClass kAECloudPrintInstallClass = 'GCPi';
+const AEEventClass kAECloudPrintUninstallClass = 'GCPu';
+
@interface AppController (Private)
- (void)initMenuState;
- (void)initProfileMenu;
@@ -162,6 +170,9 @@ void RecordLastRunAppBundlePath() {
- (void)openUrls:(const std::vector<GURL>&)urls;
- (void)getUrl:(NSAppleEventDescriptor*)event
withReply:(NSAppleEventDescriptor*)reply;
+- (void)submitCloudPrintJob:(NSAppleEventDescriptor*)event;
+- (void)installCloudPrint:(NSAppleEventDescriptor*)event;
+- (void)uninstallCloudPrint:(NSAppleEventDescriptor*)event;
- (void)windowLayeringDidChange:(NSNotification*)inNotification;
- (void)windowChangedToProfile:(Profile*)profile;
- (void)checkForAnyKeyWindows;
@@ -185,6 +196,19 @@ void RecordLastRunAppBundlePath() {
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
[em setEventHandler:self
+ andSelector:@selector(submitCloudPrintJob:)
+ forEventClass:content::kAECloudPrintClass
+ andEventID:content::kAECloudPrintClass];
+ // Install and uninstall handlers for virtual drivers.
+ [em setEventHandler:self
+ andSelector:@selector(installCloudPrint:)
+ forEventClass:kAECloudPrintInstallClass
+ andEventID:kAECloudPrintInstallClass];
+ [em setEventHandler:self
+ andSelector:@selector(uninstallCloudPrint:)
+ forEventClass:kAECloudPrintUninstallClass
+ andEventID:kAECloudPrintUninstallClass];
+ [em setEventHandler:self
andSelector:@selector(getUrl:withReply:)
forEventClass:'WWW!' // A particularly ancient AppleEvent that dates
andEventID:'OURL']; // back to the Spyglass days.
@@ -1071,6 +1095,38 @@ void RecordLastRunAppBundlePath() {
[self openUrls:gurlVector];
}
+// Apple Event handler that receives print event from service
+// process, gets the required data and launches Print dialog.
+- (void)submitCloudPrintJob:(NSAppleEventDescriptor*)event {
+ // Pull parameter list out of Apple Event.
+ NSAppleEventDescriptor *paramList =
+ [event paramDescriptorForKeyword:content::kAECloudPrintClass];
+
+ if (paramList != nil) {
+ // 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 = base::SysNSStringToUTF16(printTitle);
+ print_dialog_cloud::CreatePrintDialogForFile(
+ FilePath([inputPath UTF8String]), title16,
+ [mime UTF8String], /*modal=*/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();
+}
+
- (void)application:(NSApplication*)sender
openFiles:(NSArray*)filenames {
std::vector<GURL> gurlVector;