Browse Source

load all pak files on macOS

Cheng Zhao 6 years ago
parent
commit
18dde0a0bd
3 changed files with 10 additions and 20 deletions
  1. 5 4
      brightray/common/main_delegate.cc
  2. 0 15
      brightray/common/main_delegate_mac.mm
  3. 5 1
      electron.gyp

+ 5 - 4
brightray/common/main_delegate.cc

@@ -7,6 +7,7 @@
 #include <memory>
 
 #include "base/command_line.h"
+#include "base/mac/bundle_locations.h"
 #include "base/path_service.h"
 #include "brightray/browser/browser_client.h"
 #include "brightray/common/content_client.h"
@@ -53,12 +54,13 @@ void LoadResourceBundle(const std::string& locale) {
   ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
   bundle.ReloadLocaleResources(locale);
 
-// Load other resource files.
+  // Load other resource files.
+  base::FilePath pak_dir;
 #if defined(OS_MACOSX)
-  LoadCommonResources();
+  pak_dir = base::mac::FrameworkBundlePath().Append("Resources");
 #else
-  base::FilePath pak_dir;
   PathService::Get(base::DIR_MODULE, &pak_dir);
+#endif
   bundle.AddDataPackFromPath(
       pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")),
       ui::GetSupportedScaleFactors()[0]);
@@ -79,7 +81,6 @@ void LoadResourceBundle(const std::string& locale) {
   bundle.AddDataPackFromPath(
       pak_dir.Append(FILE_PATH_LITERAL("views_resources_200_percent.pak")),
       ui::SCALE_FACTOR_200P);
-#endif
 }
 
 MainDelegate::MainDelegate() {}

+ 0 - 15
brightray/common/main_delegate_mac.mm

@@ -25,23 +25,8 @@ base::FilePath GetFrameworksPath() {
   return MainApplicationBundlePath().Append("Contents").Append("Frameworks");
 }
 
-base::FilePath GetResourcesPakFilePath(NSString* name) {
-  auto path = [base::mac::FrameworkBundle() pathForResource:name ofType:@"pak"];
-  return base::mac::NSStringToFilePath(path);
-}
-
 }  // namespace
 
-void LoadCommonResources() {
-  ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
-  bundle.AddDataPackFromPath(GetResourcesPakFilePath(@"content_shell"),
-                             ui::GetSupportedScaleFactors()[0]);
-#if defined(ENABLE_PDF_VIEWER)
-  bundle.AddDataPackFromPath(GetResourcesPakFilePath(@"pdf_viewer_resources"),
-                             ui::GetSupportedScaleFactors()[0]);
-#endif  // defined(ENABLE_PDF_VIEWER)
-}
-
 void MainDelegate::OverrideFrameworkBundlePath() {
   base::FilePath helper_path =
       GetFrameworksPath().Append(GetApplicationName() + " Framework.framework");

+ 5 - 1
electron.gyp

@@ -638,8 +638,12 @@
           'mac_bundle': 1,
           'mac_bundle_resources': [
             'atom/common/resources/mac/MainMenu.xib',
-            '<(libchromiumcontent_dir)/content_shell.pak',
             '<(libchromiumcontent_dir)/icudtl.dat',
+            '<(libchromiumcontent_dir)/blink_image_resources_200_percent.pak',
+            '<(libchromiumcontent_dir)/content_resources_200_percent.pak',
+            '<(libchromiumcontent_dir)/content_shell.pak',
+            '<(libchromiumcontent_dir)/ui_resources_200_percent.pak',
+            '<(libchromiumcontent_dir)/views_resources_200_percent.pak',
             '<(libchromiumcontent_dir)/natives_blob.bin',
             '<(libchromiumcontent_dir)/snapshot_blob.bin',
           ],