Browse Source

Avoid duplicate code in main delegate.

Cheng Zhao 10 years ago
parent
commit
fcf55df874

+ 2 - 23
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();

+ 2 - 4
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:

+ 3 - 14
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"));

+ 1 - 1
vendor/brightray

@@ -1 +1 @@
-Subproject commit 842b674b6afa26ffc9d3d97f2ff96f0bb8498d74
+Subproject commit c1c4cfcaad43ca4a802e15328a39f574a97fa272