From fcf55df8744560829bf2ddeca2002504e173ff20 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 9 Jul 2014 17:15:28 +0800 Subject: [PATCH] Avoid duplicate code in main delegate. --- atom/app/atom_main_delegate.cc | 25 ++----------------------- atom/app/atom_main_delegate.h | 6 ++---- atom/app/atom_main_delegate_mac.mm | 17 +++-------------- vendor/brightray | 2 +- 4 files changed, 8 insertions(+), 42 deletions(-) diff --git a/atom/app/atom_main_delegate.cc b/atom/app/atom_main_delegate.cc index fae7d8143..705ea4aaa 100644 --- a/atom/app/atom_main_delegate.cc +++ b/atom/app/atom_main_delegate.cc @@ -11,9 +11,7 @@ #include "base/command_line.h" #include "base/debug/stack_trace.h" #include "base/logging.h" -#include "base/path_service.h" #include "content/public/common/content_switches.h" -#include "ui/base/resource/resource_bundle.h" namespace atom { @@ -48,17 +46,11 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) { base::debug::EnableInProcessStackDumping(); #endif -#if defined(OS_MACOSX) - OverrideChildProcessPath(); - OverrideFrameworkBundlePath(); -#endif - - SetContentClient(&content_client_); - return false; + return brightray::MainDelegate::BasicStartupComplete(exit_code); } void AtomMainDelegate::PreSandboxStartup() { - InitializeResourceBundle(); + brightray::MainDelegate::PreSandboxStartup(); CommandLine* command_line = CommandLine::ForCurrentProcess(); std::string process_type = command_line->GetSwitchValueASCII( @@ -78,19 +70,6 @@ void AtomMainDelegate::PreSandboxStartup() { command_line->AppendSwitch("atom-shell-switches-end"); } -void AtomMainDelegate::InitializeResourceBundle() { - base::FilePath path; -#if defined(OS_MACOSX) - path = GetResourcesPakFilePath(); -#else - base::FilePath pak_dir; - PathService::Get(base::DIR_MODULE, &pak_dir); - path = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")); -#endif - - ui::ResourceBundle::InitSharedInstanceWithPakPath(path); -} - 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 650e9f3c7..0837df721 100644 --- a/atom/app/atom_main_delegate.h +++ b/atom/app/atom_main_delegate.h @@ -18,12 +18,10 @@ class AtomMainDelegate : public brightray::MainDelegate { protected: virtual bool BasicStartupComplete(int* exit_code) OVERRIDE; virtual void PreSandboxStartup() OVERRIDE; - virtual void InitializeResourceBundle(); #if defined(OS_MACOSX) - virtual base::FilePath GetResourcesPakFilePath(); - virtual void OverrideChildProcessPath(); - virtual void OverrideFrameworkBundlePath(); + virtual void OverrideChildProcessPath() OVERRIDE; + virtual void OverrideFrameworkBundlePath() OVERRIDE; #endif private: diff --git a/atom/app/atom_main_delegate_mac.mm b/atom/app/atom_main_delegate_mac.mm index e8a45585e..0e3e50203 100644 --- a/atom/app/atom_main_delegate_mac.mm +++ b/atom/app/atom_main_delegate_mac.mm @@ -4,16 +4,11 @@ #include "atom/app/atom_main_delegate.h" -#import "base/mac/bundle_locations.h" -#import "base/mac/foundation_util.h" -#import "base/mac/mac_util.h" -#include "base/command_line.h" +#include "base/mac/bundle_locations.h" +#include "base/files/file_path.h" #include "base/path_service.h" -#include "base/strings/sys_string_conversions.h" +#include "brightray/common/mac/main_application_bundle.h" #include "content/public/common/content_paths.h" -#include "content/public/common/content_switches.h" -#include "vendor/brightray/common/application_info.h" -#include "vendor/brightray/common/mac/main_application_bundle.h" namespace atom { @@ -26,12 +21,6 @@ base::FilePath GetFrameworksPath() { } // namespace -base::FilePath AtomMainDelegate::GetResourcesPakFilePath() { - NSString* path = [base::mac::FrameworkBundle() - pathForResource:@"content_shell" ofType:@"pak"]; - return base::mac::NSStringToFilePath(path); -} - void AtomMainDelegate::OverrideFrameworkBundlePath() { base::mac::SetOverrideFrameworkBundlePath( GetFrameworksPath().Append("Atom Framework.framework")); diff --git a/vendor/brightray b/vendor/brightray index 842b674b6..c1c4cfcaa 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 842b674b6afa26ffc9d3d97f2ff96f0bb8498d74 +Subproject commit c1c4cfcaad43ca4a802e15328a39f574a97fa272