diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-26 00:01:39 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-26 00:01:39 +0000 |
commit | 67f734f7c3162395a1a06a7dd1610c441b6c7bf3 (patch) | |
tree | 7280670688d328947d511c930d9bc3e75b208375 | |
parent | 9828cfdad1e9fc53128d31854aa10ead800ba5fd (diff) | |
download | chromium_src-67f734f7c3162395a1a06a7dd1610c441b6c7bf3.zip chromium_src-67f734f7c3162395a1a06a7dd1610c441b6c7bf3.tar.gz chromium_src-67f734f7c3162395a1a06a7dd1610c441b6c7bf3.tar.bz2 |
[Mac] Convert ServiceApplication to not need a custom NSApp class.
BUG=none
Review URL: https://chromiumcodereview.appspot.com/14225011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196545 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/service/chrome_service_application_mac.h | 19 | ||||
-rw-r--r-- | chrome/service/chrome_service_application_mac.mm | 34 | ||||
-rw-r--r-- | chrome/service/service_main.cc | 2 |
3 files changed, 17 insertions, 38 deletions
diff --git a/chrome/service/chrome_service_application_mac.h b/chrome/service/chrome_service_application_mac.h index ba60d5d..f9d3582 100644 --- a/chrome/service/chrome_service_application_mac.h +++ b/chrome/service/chrome_service_application_mac.h @@ -5,22 +5,11 @@ #ifndef CHROME_SERVICE_CHROME_SERVICE_APPLICATION_MAC_H_ #define CHROME_SERVICE_CHROME_SERVICE_APPLICATION_MAC_H_ -#ifdef __OBJC__ +namespace chrome_service_mac { -#import <AppKit/AppKit.h> +// To be used to instantiate kAECloudPrintClass event handler from C++ code. +void RegisterServiceEventHandler(); -// Top level Mac Application for the service process. -@interface ServiceApplication : NSApplication - -@end - -#endif // __OBJC__ - -namespace chrome_service_application_mac { - -// To be used to instantiate ServiceApplication from C++ code. -void RegisterServiceApp(); - -} // namespace chrome_service_application_mac +} // namespace chrome_service_mac #endif // CHROME_SERVICE_CHROME_SERVICE_APPLICATION_MAC_H_ diff --git a/chrome/service/chrome_service_application_mac.mm b/chrome/service/chrome_service_application_mac.mm index 1b94686..c60fa06 100644 --- a/chrome/service/chrome_service_application_mac.mm +++ b/chrome/service/chrome_service_application_mac.mm @@ -10,24 +10,15 @@ #import "chrome/common/cloud_print/cloud_print_class_mac.h" #include "chrome/common/chrome_switches.h" -@interface ServiceApplication () -- (void)setCloudPrintHandler; -- (void)submitPrint:(NSAppleEventDescriptor*)event; +@interface ServiceEventHandler : NSObject ++ (void)submitPrint:(NSAppleEventDescriptor*)event; @end -@implementation ServiceApplication - -- (void)setCloudPrintHandler { - NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; - [em setEventHandler:self - andSelector:@selector(submitPrint:) - forEventClass:cloud_print::kAECloudPrintClass - andEventID:cloud_print::kAECloudPrintClass]; -} +@implementation ServiceEventHandler // Event handler for Cloud Print Event. Forwards print job received to Chrome, // launching Chrome if necessary. Used to beat CUPS sandboxing. -- (void)submitPrint:(NSAppleEventDescriptor*)event { ++ (void)submitPrint:(NSAppleEventDescriptor*)event { std::string silent = std::string("--") + switches::kNoStartupWindow; // Set up flag so that it can be passed along with the Apple Event. base::mac::ScopedCFTypeRef<CFStringRef> silentLaunchFlag( @@ -79,17 +70,16 @@ } } - @end +namespace chrome_service_mac { -namespace chrome_service_application_mac { - -void RegisterServiceApp() { - ServiceApplication* var = - base::mac::ObjCCastStrict<ServiceApplication>( - [ServiceApplication sharedApplication]); - [var setCloudPrintHandler]; +void RegisterServiceEventHandler() { + NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; + [em setEventHandler:[ServiceEventHandler class] + andSelector:@selector(submitPrint:) + forEventClass:cloud_print::kAECloudPrintClass + andEventID:cloud_print::kAECloudPrintClass]; } -} // namespace chrome_service_application_mac +} // namespace chrome_service_mac diff --git a/chrome/service/service_main.cc b/chrome/service/service_main.cc index 27060a6..ca9f370 100644 --- a/chrome/service/service_main.cc +++ b/chrome/service/service_main.cc @@ -24,7 +24,7 @@ int ServiceProcessMain(const content::MainFunctionParams& parameters) { net::URLRequest::SetDefaultCookiePolicyToBlock(); #if defined(OS_MACOSX) - chrome_service_application_mac::RegisterServiceApp(); + chrome_service_mac::RegisterServiceEventHandler(); #endif MessageLoopForUI main_message_loop; |