diff options
-rw-r--r-- | base/base.gyp | 2 | ||||
-rw-r--r-- | base/chrome_application_mac.h | 40 | ||||
-rw-r--r-- | base/chrome_application_mac.mm | 49 | ||||
-rw-r--r-- | base/message_pump_mac.mm | 91 | ||||
-rw-r--r-- | chrome/app/app-Info.plist | 2 | ||||
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 1 | ||||
-rw-r--r-- | chrome/browser/browser_list.cc | 4 | ||||
-rw-r--r-- | chrome/browser/browser_main_mac.mm | 13 | ||||
-rw-r--r-- | chrome/browser/chrome_application_mac.h | 42 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_application_mac.h | 39 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_application_mac.mm (renamed from chrome/browser/chrome_application_mac.mm) | 27 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_application_mac_unittest.mm (renamed from chrome/browser/chrome_application_mac_unittest.mm) | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/cocoa_test_helper.h | 12 | ||||
-rw-r--r-- | chrome/browser/cocoa/cocoa_test_helper.mm | 3 | ||||
-rwxr-xr-x | chrome/chrome.gyp | 6 | ||||
-rw-r--r-- | chrome/renderer/renderer_main_platform_delegate_mac.mm | 15 |
16 files changed, 242 insertions, 110 deletions
diff --git a/base/base.gyp b/base/base.gyp index 47d2438..71ff640 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -85,6 +85,8 @@ 'base_switches.h', 'basictypes.h', 'bzip2_error_handler.cc', + 'chrome_application_mac.h', + 'chrome_application_mac.mm', 'cocoa_protocols_mac.h', 'command_line.cc', 'command_line.h', diff --git a/base/chrome_application_mac.h b/base/chrome_application_mac.h new file mode 100644 index 0000000..39ef8b3 --- /dev/null +++ b/base/chrome_application_mac.h @@ -0,0 +1,40 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_CHROME_APPLICATION_MAC_H_ +#define BASE_CHROME_APPLICATION_MAC_H_ + +#import <AppKit/AppKit.h> + +#include "base/basictypes.h" + +@interface CrApplication : NSApplication { + @private + BOOL handlingSendEvent_; +} +@property(readonly, + getter=isHandlingSendEvent, + nonatomic) BOOL handlingSendEvent; + ++ (NSApplication*)sharedApplication; +@end + +namespace chrome_application_mac { + +// Controls the state of |handlingSendEvent_| in the event loop so that it is +// reset properly. +class ScopedSendingEvent { + public: + explicit ScopedSendingEvent(CrApplication* app); + ~ScopedSendingEvent(); + + private: + CrApplication* app_; + BOOL handling_; + DISALLOW_COPY_AND_ASSIGN(ScopedSendingEvent); +}; + +} // chrome_application_mac + +#endif // BASE_CHROME_APPLICATION_MAC_H_ diff --git a/base/chrome_application_mac.mm b/base/chrome_application_mac.mm new file mode 100644 index 0000000..d2d8f9f --- /dev/null +++ b/base/chrome_application_mac.mm @@ -0,0 +1,49 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "chrome_application_mac.h" + +#include "base/logging.h" + +@interface CrApplication () +@property(readwrite, + getter=isHandlingSendEvent, + nonatomic) BOOL handlingSendEvent; +@end + +@implementation CrApplication +@synthesize handlingSendEvent = handlingSendEvent_; + +// Initialize NSApplication using the custom subclass. Check whether NSApp +// was already initialized using another class, because that would break +// some things. ++ (NSApplication*)sharedApplication { + NSApplication* app = [super sharedApplication]; + if (![NSApp isKindOfClass:self]) { + LOG(ERROR) << "NSApp should be of type " << [[self className] UTF8String] + << ", not " << [[NSApp className] UTF8String]; + DCHECK(false) << "NSApp is of wrong type"; + } + return app; +} + +- (void)sendEvent:(NSEvent*)event { + chrome_application_mac::ScopedSendingEvent sendingEventScoper(self); + [super sendEvent:event]; +} + +@end + +namespace chrome_application_mac { + +ScopedSendingEvent::ScopedSendingEvent(CrApplication* app) : app_(app) { + handling_ = [app_ isHandlingSendEvent]; + [app_ setHandlingSendEvent:YES]; +} + +ScopedSendingEvent::~ScopedSendingEvent() { + [app_ setHandlingSendEvent:handling_]; +} + +} // namespace chrome_application_mac diff --git a/base/message_pump_mac.mm b/base/message_pump_mac.mm index b08bdad..16a9a59 100644 --- a/base/message_pump_mac.mm +++ b/base/message_pump_mac.mm @@ -11,7 +11,8 @@ #include <limits> -#include "base/scoped_nsautorelease_pool.h" +#import "base/chrome_application_mac.h" +#include "base/logging.h" #include "base/time.h" namespace { @@ -26,6 +27,23 @@ const CFTimeInterval kCFTimeIntervalMax = namespace base { +// A scoper for autorelease pools created from message pump run loops. +// Avoids dirtying up the ScopedNSAutoreleasePool interface for the rare +// case where an autorelease pool needs to be passed in. +class MessagePumpScopedAutoreleasePool { + public: + explicit MessagePumpScopedAutoreleasePool(MessagePumpCFRunLoopBase* pump) : + pool_(pump->CreateAutoreleasePool()) { + } + ~MessagePumpScopedAutoreleasePool() { + [pool_ drain]; + } + + private: + NSAutoreleasePool* pool_; + DISALLOW_COPY_AND_ASSIGN(MessagePumpScopedAutoreleasePool); +}; + // Must be called on the run loop thread. MessagePumpCFRunLoopBase::MessagePumpCFRunLoopBase() : delegate_(NULL), @@ -264,9 +282,9 @@ bool MessagePumpCFRunLoopBase::RunWork() { // The NSApplication-based run loop only drains the autorelease pool at each // UI event (NSEvent). The autorelease pool is not drained for each // CFRunLoopSource target that's run. Use a local pool for any autoreleased - // objects to ensure they're released promptly even in the absence of UI - // events. - ScopedNSAutoreleasePool autorelease_pool; + // objects if the app is not currently handling a UI event to ensure they're + // released promptly even in the absence of UI events. + MessagePumpScopedAutoreleasePool autorelease_pool(this); // Call DoWork once, and if something was done, arrange to come back here // again as long as the loop is still running. @@ -298,9 +316,9 @@ bool MessagePumpCFRunLoopBase::RunDelayedWork() { // The NSApplication-based run loop only drains the autorelease pool at each // UI event (NSEvent). The autorelease pool is not drained for each // CFRunLoopSource target that's run. Use a local pool for any autoreleased - // objects to ensure they're released promptly even in the absence of UI - // events. - ScopedNSAutoreleasePool autorelease_pool; + // objects if the app is not currently handling a UI event to ensure they're + // released promptly even in the absence of UI events. + MessagePumpScopedAutoreleasePool autorelease_pool(this); Time next_time; delegate_->DoDelayedWork(&next_time); @@ -342,9 +360,9 @@ bool MessagePumpCFRunLoopBase::RunIdleWork() { // The NSApplication-based run loop only drains the autorelease pool at each // UI event (NSEvent). The autorelease pool is not drained for each // CFRunLoopSource target that's run. Use a local pool for any autoreleased - // objects to ensure they're released promptly even in the absence of UI - // events. - ScopedNSAutoreleasePool autorelease_pool; + // objects if the app is not currently handling a UI event to ensure they're + // released promptly even in the absence of UI events. + MessagePumpScopedAutoreleasePool autorelease_pool(this); // Call DoIdleWork once, and if something was done, arrange to come back here // again as long as the loop is still running. @@ -555,6 +573,11 @@ void MessagePumpCFRunLoopBase::PowerStateNotification(void* info, void MessagePumpCFRunLoopBase::EnterExitRunLoop(CFRunLoopActivity activity) { } +// Base version returns a standard NSAutoreleasePool. +NSAutoreleasePool* MessagePumpCFRunLoopBase::CreateAutoreleasePool() { + return [[NSAutoreleasePool alloc] init]; +} + MessagePumpCFRunLoop::MessagePumpCFRunLoop() : quit_pending_(false) { } @@ -568,7 +591,7 @@ void MessagePumpCFRunLoop::DoRun(Delegate* delegate) { // pool management is introduced. int result; do { - ScopedNSAutoreleasePool autorelease_pool; + MessagePumpScopedAutoreleasePool autorelease_pool(this); result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, kCFTimeIntervalMax, false); @@ -644,7 +667,9 @@ MessagePumpNSApplication::MessagePumpNSApplication() void MessagePumpNSApplication::DoRun(Delegate* delegate) { bool last_running_own_loop_ = running_own_loop_; - [NSApplication sharedApplication]; + // TODO(dmaclach): Get rid of this gratuitous sharedApplication. + // Tests should be setting up their applications on their own. + [CrApplication sharedApplication]; if (![NSApp isRunning]) { running_own_loop_ = false; @@ -654,7 +679,7 @@ void MessagePumpNSApplication::DoRun(Delegate* delegate) { running_own_loop_ = true; NSDate* distant_future = [NSDate distantFuture]; while (keep_running_) { - ScopedNSAutoreleasePool autorelease_pool; + MessagePumpScopedAutoreleasePool autorelease_pool(this); NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:distant_future inMode:NSDefaultRunLoopMode @@ -689,6 +714,46 @@ void MessagePumpNSApplication::Quit() { atStart:NO]; } +// Prevents an autorelease pool from being created if the app is in the midst of +// handling a UI event because various parts of AppKit depend on objects that +// are created while handling a UI event to be autoreleased in the event loop. +// An example of this is NSWindowController. When a window with a window +// controller is closed it goes through a stack like this: +// (Several stack frames elided for clarity) +// +// #0 [NSWindowController autorelease] +// #1 DoAClose +// #2 MessagePumpCFRunLoopBase::DoWork() +// #3 [NSRunLoop run] +// #4 [NSButton performClick:] +// #5 [NSWindow sendEvent:] +// #6 [NSApp sendEvent:] +// #7 [NSApp run] +// +// -performClick: spins a nested run loop. If the pool created in DoWork was a +// standard NSAutoreleasePool, it would release the objects that were +// autoreleased into it once DoWork released it. This would cause the window +// controller, which autoreleased itself in frame #0, to release itself, and +// possibly free itself. Unfortunately this window controller controls the +// window in frame #5. When the stack is unwound to frame #5, the window would +// no longer exists and crashes may occur. Apple gets around this by never +// releasing the pool it creates in frame #4, and letting frame #7 clean it up +// when it cleans up the pool that wraps frame #7. When an autorelease pool is +// released it releases all other pools that were created after it on the +// autorelease pool stack. +// +// CrApplication is responsible for setting handlingSendEvent to true just +// before it sends the event throught the event handling mechanism, and +// returning it to its previous value once the event has been sent. +NSAutoreleasePool* MessagePumpNSApplication::CreateAutoreleasePool() { + NSAutoreleasePool* pool = nil; + DCHECK([NSApp isKindOfClass:[CrApplication class]]); + if (![static_cast<CrApplication*>(NSApp) isHandlingSendEvent]) { + pool = MessagePumpCFRunLoopBase::CreateAutoreleasePool(); + } + return pool; +} + // static MessagePump* MessagePumpMac::Create() { if ([NSThread isMainThread]) { diff --git a/chrome/app/app-Info.plist b/chrome/app/app-Info.plist index f3f53b6..334f3f1 100644 --- a/chrome/app/app-Info.plist +++ b/chrome/app/app-Info.plist @@ -186,8 +186,6 @@ <string>1</string> <key>LSMinimumSystemVersion</key> <string>10.5.0</string> - <key>NSPrincipalClass</key> - <string>CrApplication</string> <key>UTExportedTypeDeclarations</key> <array> <dict> diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 50973f6..d24cd7a 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -16,7 +16,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/browser_window.h" -#import "chrome/browser/chrome_application_mac.h" #import "chrome/browser/cocoa/about_window_controller.h" #import "chrome/browser/cocoa/bookmark_menu_bridge.h" #import "chrome/browser/cocoa/browser_window_cocoa.h" diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc index dd7b9dc..f32ffdd 100644 --- a/chrome/browser/browser_list.cc +++ b/chrome/browser/browser_list.cc @@ -19,7 +19,7 @@ #include "chrome/common/result_codes.h" #if defined(OS_MACOSX) -#include "chrome/browser/chrome_application_mac.h" +#include "chrome/browser/chrome_browser_application_mac.h" #endif namespace { @@ -238,7 +238,7 @@ void BrowserList::CloseAllBrowsersAndExit() { // On the Mac, the application continues to run once all windows are closed. // Terminate will result in a CloseAllBrowsers(true) call, and additionally, // will cause the application to exit cleanly. - CrApplicationCC::Terminate(); + chrome_browser_application_mac::Terminate(); #endif } diff --git a/chrome/browser/browser_main_mac.mm b/chrome/browser/browser_main_mac.mm index ce5893b..65b6970 100644 --- a/chrome/browser/browser_main_mac.mm +++ b/chrome/browser/browser_main_mac.mm @@ -13,7 +13,7 @@ #import "chrome/app/keystone_glue.h" #import "chrome/browser/app_controller_mac.h" #include "chrome/browser/browser_main_win.h" -#import "chrome/browser/chrome_application_mac.h" +#import "chrome/browser/chrome_browser_application_mac.h" #include "chrome/browser/metrics/metrics_service.h" #include "chrome/common/main_function_params.h" #include "chrome/common/result_codes.h" @@ -28,15 +28,8 @@ namespace Platform { // MessageLoop API, which works out ok for us because it's a wrapper around // CFRunLoop. void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) { - // Initialize NSApplication using the custom subclass. Check whether NSApp - // was already initialized using another class, because that would break - // some things. - [CrApplication sharedApplication]; - if (![NSApp isKindOfClass:[CrApplication class]]) { - LOG(ERROR) << "NSApp should be of type CrApplication, not " - << [[NSApp className] UTF8String]; - DCHECK(false) << "NSApp is of wrong type"; - } + // Initialize NSApplication using the custom subclass. + [BrowserCrApplication sharedApplication]; // Before we load the nib, we need to start up the resource bundle so we have // the strings avaiable for localization. diff --git a/chrome/browser/chrome_application_mac.h b/chrome/browser/chrome_application_mac.h deleted file mode 100644 index 60b6438..0000000 --- a/chrome/browser/chrome_application_mac.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROME_APPLICATION_MAC_H_ -#define CHROME_BROWSER_CHROME_APPLICATION_MAC_H_ - -#ifdef __OBJC__ - -#import <AppKit/AppKit.h> - -@interface CrApplication : NSApplication -@end - -// Namespace for exception-reporting helper functions. Exposed for -// testing purposes. -namespace CrApplicationNSException { - -// Bin for unknown exceptions. -extern const size_t kUnknownNSException; - -// Returns the histogram bin for |exception| if it is one we track -// specifically, or |kUnknownNSException| if unknown. -size_t BinForException(NSException* exception); - -// Use UMA to track exception occurance. -void RecordExceptionWithUma(NSException* exception); - -} // CrApplicationNSException - -#endif // __OBJC__ - -// CrApplicationCC provides access to CrApplication Objective-C selectors from -// C++ code. -namespace CrApplicationCC { - -// Calls -[NSApp terminate:]. -void Terminate(); - -} // namespace CrApplicationCC - -#endif // CHROME_BROWSER_CHROME_APPLICATION_MAC_H_ diff --git a/chrome/browser/chrome_browser_application_mac.h b/chrome/browser/chrome_browser_application_mac.h new file mode 100644 index 0000000..9a1ab9e --- /dev/null +++ b/chrome/browser/chrome_browser_application_mac.h @@ -0,0 +1,39 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ +#define CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ + +#ifdef __OBJC__ + +#import "base/chrome_application_mac.h" + +@interface BrowserCrApplication : CrApplication +@end + +namespace chrome_browser_application_mac { + +// Bin for unknown exceptions. Exposed for testing purposes. +extern const size_t kUnknownNSException; + +// Returns the histogram bin for |exception| if it is one we track +// specifically, or |kUnknownNSException| if unknown. Exposed for testing +// purposes. +size_t BinForException(NSException* exception); + +// Use UMA to track exception occurance. Exposed for testing purposes. +void RecordExceptionWithUma(NSException* exception); + +} // namespace chrome_browser_application_mac + +#endif // __OBJC__ + +namespace chrome_browser_application_mac { + +// Calls -[NSApp terminate:]. +void Terminate(); + +} // namespace chrome_browser_application_mac + +#endif // CHROME_BROWSER_CHROME_BROWSER_APPLICATION_MAC_H_ diff --git a/chrome/browser/chrome_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm index 94c975b..57c6fab 100644 --- a/chrome/browser/chrome_application_mac.mm +++ b/chrome/browser/chrome_browser_application_mac.mm @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "chrome/browser/chrome_application_mac.h" +#import "chrome/browser/chrome_browser_application_mac.h" #import "base/histogram.h" #import "base/logging.h" @@ -11,7 +11,6 @@ #import "chrome/app/breakpad_mac.h" #import "chrome/browser/cocoa/chrome_event_processing_window.h" #import "chrome/browser/cocoa/objc_method_swizzle.h" -#import "chrome/browser/renderer_host/render_widget_host_view_mac.h" // The implementation of NSExceptions break various assumptions in the // Chrome code. This category defines a replacement for @@ -49,7 +48,7 @@ static IMP gOriginalInitIMP = NULL; } @end -namespace CrApplicationNSException { +namespace chrome_browser_application_mac { // Maximum number of known named exceptions we'll support. There is // no central registration, but I only find about 75 possibilities in @@ -99,7 +98,11 @@ void RecordExceptionWithUma(NSException* exception) { histogram.Add(BinForException(exception)); } -} // CrApplicationNSException +void Terminate() { + [NSApp terminate:nil]; +} + +} // namespace chrome_browser_application_mac namespace { @@ -133,12 +136,9 @@ BOOL SwizzleNSExceptionInit() { } // namespace -@implementation CrApplication +@implementation BrowserCrApplication - init { - // TODO(shess): Push this somewhere where it can apply to the plugin - // and renderer processes, and where it can intercept uncaught - // exceptions. DCHECK(SwizzleNSExceptionInit()); return [super init]; } @@ -244,6 +244,7 @@ BOOL SwizzleNSExceptionInit() { } - (void)sendEvent:(NSEvent*)event { + chrome_application_mac::ScopedSendingEvent scoper(self); // The superclass's |sendEvent:| sends keyboard events to the menu and the key // view loop before dispatching them to |keyDown:|. Since we want to send keys // to the renderer before sending them to the menu, and we never want them to @@ -269,7 +270,7 @@ BOOL SwizzleNSExceptionInit() { DCHECK(!reportingException); if (!reportingException) { reportingException = YES; - CrApplicationNSException::RecordExceptionWithUma(anException); + chrome_browser_application_mac::RecordExceptionWithUma(anException); // Store some human-readable information in breakpad keys in case // there is a crash. Since breakpad does not provide infinite @@ -306,11 +307,3 @@ BOOL SwizzleNSExceptionInit() { } @end - -namespace CrApplicationCC { - -void Terminate() { - [NSApp terminate:nil]; -} - -} // namespace CrApplicationCC diff --git a/chrome/browser/chrome_application_mac_unittest.mm b/chrome/browser/chrome_browser_application_mac_unittest.mm index dbc1d90..7fc134e 100644 --- a/chrome/browser/chrome_application_mac_unittest.mm +++ b/chrome/browser/chrome_browser_application_mac_unittest.mm @@ -5,10 +5,10 @@ #import <Cocoa/Cocoa.h> #include "base/histogram.h" -#import "chrome/browser/chrome_application_mac.h" +#import "chrome/browser/chrome_browser_application_mac.h" #include "testing/gtest/include/gtest/gtest.h" -namespace CrApplicationNSException { +namespace chrome_browser_application_mac { // Generate an NSException with the given name. NSException* ExceptionNamed(NSString* name) { @@ -78,4 +78,4 @@ TEST(ChromeApplicationMacTest, RecordException) { EXPECT_EQ(4, sample.counts(kUnknownNSException)); } -} // CrApplicationNSException +} // chrome_browser_application_mac diff --git a/chrome/browser/cocoa/cocoa_test_helper.h b/chrome/browser/cocoa/cocoa_test_helper.h index 5b05505..5f51c54 100644 --- a/chrome/browser/cocoa/cocoa_test_helper.h +++ b/chrome/browser/cocoa/cocoa_test_helper.h @@ -8,6 +8,7 @@ #import <Cocoa/Cocoa.h> #include <vector> +#import "base/chrome_application_mac.h" #include "base/debug_util.h" #include "base/file_path.h" #include "base/mac_util.h" @@ -138,14 +139,7 @@ class CocoaTest : public PlatformTest { class CocoaNoWindowTestHelper { public: CocoaNoWindowTestHelper() { - // Look in the framework bundle for resources. - FilePath path; - PathService::Get(base::DIR_EXE, &path); - path = path.Append(chrome::kFrameworkName); - mac_util::SetOverrideAppBundlePath(path); - - // Bootstrap Cocoa. It's very unhappy without this. - [NSApplication sharedApplication]; + CocoaTest::BootstrapCocoa(); // Set the duration of AppKit-evaluated animations (such as frame changes) // to zero for testing purposes. That way they take effect immediately. @@ -155,7 +149,7 @@ class CocoaNoWindowTestHelper { // DEPRECATED // TODO(dmaclach): remove as soon as I can get my other CLs in that get rid -// of any dependencies on this. 10/30/09 at the latest. +// of any dependencies on this. 11/30/09 at the latest. class CocoaTestHelper : public CocoaNoWindowTestHelper { public: CocoaTestHelper() { diff --git a/chrome/browser/cocoa/cocoa_test_helper.mm b/chrome/browser/cocoa/cocoa_test_helper.mm index 462b10a..17bba55 100644 --- a/chrome/browser/cocoa/cocoa_test_helper.mm +++ b/chrome/browser/cocoa/cocoa_test_helper.mm @@ -3,6 +3,7 @@ // found in the LICENSE file. #import "chrome/browser/cocoa/cocoa_test_helper.h" +#import "chrome/browser/chrome_browser_application_mac.h" #import "base/logging.h" @implementation CocoaTestHelperWindow @@ -68,7 +69,7 @@ void CocoaTest::BootstrapCocoa() { mac_util::SetOverrideAppBundlePath(path); // Bootstrap Cocoa. It's very unhappy without this. - [NSApplication sharedApplication]; + [CrApplication sharedApplication]; } void CocoaTest::TearDown() { diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 7860605..d6e44a1 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -966,8 +966,8 @@ 'browser/character_encoding.h', 'browser/child_process_security_policy.cc', 'browser/child_process_security_policy.h', - 'browser/chrome_application_mac.h', - 'browser/chrome_application_mac.mm', + 'browser/chrome_browser_application_mac.h', + 'browser/chrome_browser_application_mac.mm', 'browser/chrome_plugin_browsing_context.cc', 'browser/chrome_plugin_browsing_context.h', 'browser/chrome_plugin_host.cc', @@ -4468,7 +4468,7 @@ 'browser/browser_commands_unittest.cc', 'browser/browser_theme_provider_unittest.cc', 'browser/browser_unittest.cc', - 'browser/chrome_application_mac_unittest.mm', + 'browser/chrome_browser_application_mac_unittest.mm', 'browser/debugger/devtools_remote_message_unittest.cc', 'browser/debugger/devtools_remote_listen_socket_unittest.cc', 'browser/debugger/devtools_remote_listen_socket_unittest.h', diff --git a/chrome/renderer/renderer_main_platform_delegate_mac.mm b/chrome/renderer/renderer_main_platform_delegate_mac.mm index 014a7d2..eb790aa 100644 --- a/chrome/renderer/renderer_main_platform_delegate_mac.mm +++ b/chrome/renderer/renderer_main_platform_delegate_mac.mm @@ -6,6 +6,7 @@ #import <Cocoa/Cocoa.h> +#import "base/chrome_application_mac.h" #include "base/command_line.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/sandbox_mac.h" @@ -19,10 +20,14 @@ RendererMainPlatformDelegate::RendererMainPlatformDelegate( RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { } -// TODO(mac-port): Any code needed to initialize a process for -// purposes of running a renderer needs to also be reflected in -// chrome_dll_main.cc for --single-process support. +// TODO(mac-port): Any code needed to initialize a process for purposes of +// running a renderer needs to also be reflected in chrome_dll_main.cc for +// --single-process support. void RendererMainPlatformDelegate::PlatformInitialize() { + // Initialize NSApplication using the custom subclass. Without this call, + // drawing of native UI elements (e.g. buttons) in WebKit will explode. + [CrApplication sharedApplication]; + // Load WebKit system interfaces. InitWebCoreSystemInterface(); @@ -32,10 +37,6 @@ void RendererMainPlatformDelegate::PlatformInitialize() { toTarget:string withObject:nil]; } - - // Initialize Cocoa. Without this call, drawing of native UI - // elements (e.g. buttons) in WebKit will explode. - [NSApplication sharedApplication]; } void RendererMainPlatformDelegate::PlatformUninitialize() { |