diff --git a/atom/app/atom_main_delegate.cc b/atom/app/atom_main_delegate.cc index 8109291dc581..668501a7c49b 100644 --- a/atom/app/atom_main_delegate.cc +++ b/atom/app/atom_main_delegate.cc @@ -35,6 +35,10 @@ #include "atom/common/common_message_generator.h" #endif +#if defined(OS_MACOSX) +#include "atom/app/atom_main_delegate_mac.h" +#endif + namespace atom { namespace { @@ -158,6 +162,12 @@ void AtomMainDelegate::PreSandboxStartup() { #endif } +void AtomMainDelegate::PreContentInitialization() { +#if defined(OS_MACOSX) + RegisterAtomCrApp(); +#endif +} + content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() { browser_client_.reset(new AtomBrowserClient); return browser_client_.get(); diff --git a/atom/app/atom_main_delegate.h b/atom/app/atom_main_delegate.h index eb0a36ea8d0b..83d2c6e2ae52 100644 --- a/atom/app/atom_main_delegate.h +++ b/atom/app/atom_main_delegate.h @@ -22,6 +22,7 @@ class AtomMainDelegate : public brightray::MainDelegate { // content::ContentMainDelegate: bool BasicStartupComplete(int* exit_code) override; void PreSandboxStartup() override; + void PreContentInitialization() override; content::ContentBrowserClient* CreateContentBrowserClient() override; content::ContentRendererClient* CreateContentRendererClient() override; content::ContentUtilityClient* CreateContentUtilityClient() override; diff --git a/atom/app/atom_main_delegate_mac.h b/atom/app/atom_main_delegate_mac.h new file mode 100644 index 000000000000..18b65da6ee19 --- /dev/null +++ b/atom/app/atom_main_delegate_mac.h @@ -0,0 +1,15 @@ +// Copyright 2013 Slack Technologies, Inc. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ATOM_APP_ATOM_MAIN_DELEGATE_MAC_H_ +#define ATOM_APP_ATOM_MAIN_DELEGATE_MAC_H_ + +namespace atom { + +// Initializes NSApplication. +void RegisterAtomCrApp(); + +} // namespace atom + +#endif // ATOM_APP_ATOM_MAIN_DELEGATE_MAC_H_ diff --git a/atom/app/atom_main_delegate_mac.mm b/atom/app/atom_main_delegate_mac.mm index 24717ca001f0..21104ae23e74 100644 --- a/atom/app/atom_main_delegate_mac.mm +++ b/atom/app/atom_main_delegate_mac.mm @@ -4,6 +4,7 @@ #include "atom/app/atom_main_delegate.h" +#include "atom/browser/mac/atom_application.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/mac/bundle_locations.h" @@ -63,4 +64,9 @@ void AtomMainDelegate::SetUpBundleOverrides() { base::mac::SetBaseBundleID(base_bundle_id.c_str()); } +void RegisterAtomCrApp() { + // Force the NSApplication subclass to be used. + [AtomApplication sharedApplication]; +} + } // namespace atom diff --git a/atom/browser/atom_browser_main_parts_mac.mm b/atom/browser/atom_browser_main_parts_mac.mm index 17a5681a16a9..92af70cf3830 100644 --- a/atom/browser/atom_browser_main_parts_mac.mm +++ b/atom/browser/atom_browser_main_parts_mac.mm @@ -4,7 +4,6 @@ #include "atom/browser/atom_browser_main_parts.h" -#include "atom/browser/mac/atom_application.h" #include "atom/browser/mac/atom_application_delegate.h" #include "base/mac/bundle_locations.h" #include "base/mac/foundation_util.h" @@ -13,9 +12,6 @@ namespace atom { void AtomBrowserMainParts::PreMainMessageLoopStart() { - // Force the NSApplication subclass to be used. - [AtomApplication sharedApplication]; - // Set our own application delegate. AtomApplicationDelegate* delegate = [[AtomApplicationDelegate alloc] init]; [NSApp setDelegate:delegate]; diff --git a/filenames.gni b/filenames.gni index 6f188e033625..3797aa8ad28e 100644 --- a/filenames.gni +++ b/filenames.gni @@ -112,6 +112,7 @@ filenames = { "atom/app/atom_content_client.h", "atom/app/atom_main_delegate.cc", "atom/app/atom_main_delegate.h", + "atom/app/atom_main_delegate_mac.h", "atom/app/atom_main_delegate_mac.mm", "atom/app/command_line_args.cc", "atom/app/command_line_args.h",