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

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 7485011: Virtual Cloud Print Driver for Mac. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Style fixes Created 9 years, 5 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
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..1dda8e1a657eaffd816d442c52cc72154502666b 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,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;
@@ -184,6 +196,19 @@ void RecordLastRunAppBundlePath() {
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
[em setEventHandler:self
+ andSelector:@selector(submitCloudPrintJob:)
+ forEventClass:cloudPrintClass
+ andEventID:cloudPrintClass]; // Event handler for cloud print.
Nico 2011/08/01 21:31:12 Remove comment
abeera 2011/08/02 01:21:02 Done.
+ // 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.
@@ -1060,6 +1085,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:cloudPrintClass];
Nico 2011/08/01 21:31:12 indent 4
abeera 2011/08/02 01:21:02 Done.
+
+ 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 = 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;

Powered by Google App Engine
This is Rietveld 408576698