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

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: Fixed copyright Created 9 years, 4 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
« no previous file with comments | « build/all.gyp ('k') | chrome/browser/printing/cloud_print/virtual_driver_install_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/app_controller_mac.mm
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 032f72d35e2cc1d92aea62377c43c8baf54e2f16..f4d8f22592a11237269acc713bdd418f97d81d35 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;
« no previous file with comments | « build/all.gyp ('k') | chrome/browser/printing/cloud_print/virtual_driver_install_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698