diff --git a/cef.gyp b/cef.gyp index e3a9488ca..de478ebbc 100644 --- a/cef.gyp +++ b/cef.gyp @@ -46,6 +46,7 @@ ], 'mac_bundle_resources': [ '<@(cefclient_bundle_resources_mac)', + '<(grit_out_dir)/devtools_resources.pak', ], 'mac_bundle_resources!': [ # TODO(mark): Come up with a fancier way to do this (mac_info_plist?) @@ -84,24 +85,6 @@ '<@(locales)', ], }, - { - # On Windows chrome.pak will contain only the inspector resources. - # Other resources are built into libcef.dll. - 'action_name': 'repack_resources', - 'variables': { - 'pak_inputs': [ - '<(grit_out_dir)/devtools_resources.pak', - ], - }, - 'inputs': [ - '<(repack_path)', - '<@(pak_inputs)', - ], - 'outputs': [ - '<(INTERMEDIATE_DIR)/repack/chrome.pak', - ], - 'action': ['python', '<(repack_path)', '<@(_outputs)', '<@(pak_inputs)'], - }, ], 'copies': [ { @@ -113,7 +96,7 @@ { 'destination': '<(PRODUCT_DIR)', 'files': [ - '<(INTERMEDIATE_DIR)/repack/chrome.pak' + '<(grit_out_dir)/devtools_resources.pak' ], }, ], @@ -172,7 +155,6 @@ 'process_outputs_as_mac_bundle_resources': 1, 'variables': { 'pak_inputs': [ - '<(grit_out_dir)/devtools_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak', @@ -252,7 +234,6 @@ 'action_name': 'repack_resources', 'variables': { 'pak_inputs': [ - '<(grit_out_dir)/devtools_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak', @@ -279,7 +260,8 @@ { 'destination': '<(PRODUCT_DIR)', 'files': [ - '<(INTERMEDIATE_DIR)/repack/chrome.pak' + '<(INTERMEDIATE_DIR)/repack/chrome.pak', + '<(grit_out_dir)/devtools_resources.pak', ], }, { diff --git a/libcef/browser_webkit_glue.cc b/libcef/browser_webkit_glue.cc index c78bdbfa1..cacf43679 100644 --- a/libcef/browser_webkit_glue.cc +++ b/libcef/browser_webkit_glue.cc @@ -40,23 +40,25 @@ using WebKit::WebFrameImpl; namespace webkit_glue { +#if !defined(OS_MACOSX) +FilePath GetResourcesFilePath() { + FilePath pak_dir; + PathService::Get(base::DIR_MODULE, &pak_dir); + return pak_dir; +} +#endif // !defined(OS_MACOSX) + void InitializeResourceBundle(const std::string& locale) { // Load chrome.pak (on Mac) and the appropiate locale pack. const std::string loaded_locale = ResourceBundle::InitSharedInstance(locale); CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; -#if defined(OS_WIN) - // Explicitly load chrome.pak on Windows. Use the module (libcef.dll) - // directory to match the location of the locale folder. - FilePath chrome_pack_path; - PathService::Get(base::DIR_MODULE, &chrome_pack_path); - chrome_pack_path = chrome_pack_path.AppendASCII("chrome.pak"); - if (file_util::PathExists(chrome_pack_path)) - ResourceBundle::AddDataPackToSharedInstance(chrome_pack_path); - else - NOTREACHED() << "Could not load chrome.pak"; -#endif + // Load devtools_resources.pak if it exists. + FilePath pack_path = + GetResourcesFilePath().AppendASCII("devtools_resources.pak"); + if (file_util::PathExists(pack_path)) + ResourceBundle::AddDataPackToSharedInstance(pack_path); } void CleanupResourceBundle() { diff --git a/libcef/browser_webkit_glue.h b/libcef/browser_webkit_glue.h index 776e8aafb..91d61ca5f 100644 --- a/libcef/browser_webkit_glue.h +++ b/libcef/browser_webkit_glue.h @@ -20,9 +20,7 @@ namespace webkit { struct WebPluginInfo; } -#if defined(OS_MACOSX) class FilePath; -#endif namespace webkit_glue { @@ -34,14 +32,11 @@ void CaptureWebViewBitmap(HWND mainWnd, WebKit::WebView* webview, // Save a bitmap image to file, providing optional alternative data in |lpBits| BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits); #endif - + +FilePath GetResourcesFilePath(); void InitializeResourceBundle(const std::string& locale); void CleanupResourceBundle(); -#if defined(OS_MACOSX) -FilePath GetResourcesFilePath(); -#endif - string16 GetLocalizedString(int message_id); base::StringPiece GetDataResource(int resource_id); diff --git a/libcef/browser_webkit_glue_mac.mm b/libcef/browser_webkit_glue_mac.mm index a81b50a14..31777bf94 100644 --- a/libcef/browser_webkit_glue_mac.mm +++ b/libcef/browser_webkit_glue_mac.mm @@ -12,6 +12,7 @@ #undef LOG #include "base/file_util.h" #include "base/logging.h" +#include "base/mac/foundation_util.h" #include "base/mac/mac_util.h" #include "base/path_service.h" #include "base/utf_string_conversions.h" @@ -21,24 +22,17 @@ namespace webkit_glue { - -// Helper method for getting the path to the CEF resources directory. + FilePath GetResourcesFilePath() { - FilePath path; - // We need to know if we're bundled or not to know which path to use. - if (base::mac::AmIBundled()) { - PathService::Get(base::DIR_EXE, &path); - path = path.Append(FilePath::kParentDirectory); - return path.AppendASCII("Resources"); - } else { - // TODO(port): Allow the embedder to customize the resource path. - PathService::Get(base::DIR_SOURCE_ROOT, &path); - path = path.AppendASCII("src"); - path = path.AppendASCII("cef"); - path = path.AppendASCII("tests"); - path = path.AppendASCII("cefclient"); - return path.AppendASCII("res"); - } + // Start out with the path to the running executable. + FilePath execPath; + PathService::Get(base::FILE_EXE, &execPath); + + // Get the main bundle path. + FilePath bundlePath = base::mac::GetAppBundlePath(execPath); + + return bundlePath.Append(FILE_PATH_LITERAL("Contents")) + .Append(FILE_PATH_LITERAL("Resources")); } base::StringPiece GetDataResource(int resource_id) { diff --git a/tools/distrib/linux/README.txt b/tools/distrib/linux/README.txt index 0bac8a2cc..b6f1031aa 100644 --- a/tools/distrib/linux/README.txt +++ b/tools/distrib/linux/README.txt @@ -70,7 +70,8 @@ Required components: * Other resources chrome.pak - Note: The chrome.pak file must exist in the same directory as the executable. + devtools_resources.pak + Note: The pak files must exist in the same directory as libcef.so. LICENSING diff --git a/tools/distrib/mac/README.txt b/tools/distrib/mac/README.txt index f225b6035..6edd1c23c 100644 --- a/tools/distrib/mac/README.txt +++ b/tools/distrib/mac/README.txt @@ -74,6 +74,7 @@ Required components: * Other resources Resources/chrome.pak + Resources/devtools_resources.pak Resources/*.png Resources/*.tiff diff --git a/tools/distrib/win/README.txt b/tools/distrib/win/README.txt index dcadeb134..09cf3a464 100644 --- a/tools/distrib/win/README.txt +++ b/tools/distrib/win/README.txt @@ -80,8 +80,8 @@ Required components: locales folder must exist in the same directory as libcef.dll. * Other resources - chrome.pak - Note: The chrome.pak file must exist in the same directory as libcef.dll. + devtools_resources.pak + Note: The pak file must exist in the same directory as libcef.dll. Optional components: diff --git a/tools/make_distrib.py b/tools/make_distrib.py index af74fb186..317120c91 100644 --- a/tools/make_distrib.py +++ b/tools/make_distrib.py @@ -259,7 +259,7 @@ if platform == 'windows': copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet) copy_files(os.path.join(cef_dir, 'Debug/*.dll'), dst_dir, options.quiet) copy_file(os.path.join(cef_dir, 'Debug/cefclient.exe'), dst_dir, options.quiet) - copy_file(os.path.join(cef_dir, 'Debug/chrome.pak'), dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, 'Debug/devtools_resources.pak'), dst_dir, options.quiet) copy_dir(os.path.join(cef_dir, 'Debug/locales'), os.path.join(dst_dir, 'locales'), \ options.quiet) @@ -277,7 +277,7 @@ if platform == 'windows': copy_files(os.path.join(script_dir, 'distrib/win/*.dll'), dst_dir, options.quiet) copy_files(os.path.join(cef_dir, 'Release/*.dll'), dst_dir, options.quiet) copy_file(os.path.join(cef_dir, 'Release/cefclient.exe'), dst_dir, options.quiet) - copy_file(os.path.join(cef_dir, 'Release/chrome.pak'), dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, 'Release/devtools_resources.pak'), dst_dir, options.quiet) copy_dir(os.path.join(cef_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), \ options.quiet) @@ -352,6 +352,7 @@ elif platform == 'macosx': make_dir(dst_dir, options.quiet) copy_files(os.path.join(cef_dir, '../third_party/WebKit/Source/WebCore/Resources/*.*'), dst_dir, options.quiet) copy_file(os.path.join(cef_dir, '../xcodebuild/Release/cefclient.app/Contents/Resources/chrome.pak'), dst_dir, options.quiet) + copy_file(os.path.join(cef_dir, '../xcodebuild/Release/cefclient.app/Contents/Resources/devtools_resources.pak'), dst_dir, options.quiet) copy_files(os.path.join(cef_dir, '../xcodebuild/Release/cefclient.app/Contents/Resources/*.lproj'), dst_dir, options.quiet) remove_dir(os.path.join(dst_dir, 'English.lproj')) @@ -385,6 +386,7 @@ elif platform == 'linux': copy_dir(os.path.join(linux_build_dir, 'Debug/lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) copy_file(os.path.join(linux_build_dir, 'Debug/cefclient'), dst_dir, options.quiet) copy_file(os.path.join(linux_build_dir, 'Debug/chrome.pak'), dst_dir, options.quiet) + copy_file(os.path.join(linux_build_dir, 'Debug/devtools_resources.pak'), dst_dir, options.quiet) copy_dir(os.path.join(linux_build_dir, 'Debug/locales'), os.path.join(dst_dir, 'locales'), options.quiet) else: @@ -397,6 +399,7 @@ elif platform == 'linux': copy_dir(os.path.join(linux_build_dir, 'Release/lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) copy_file(os.path.join(linux_build_dir, 'Release/cefclient'), dst_dir, options.quiet) copy_file(os.path.join(linux_build_dir, 'Release/chrome.pak'), dst_dir, options.quiet) + copy_file(os.path.join(linux_build_dir, 'Release/devtools_resources.pak'), dst_dir, options.quiet) copy_dir(os.path.join(linux_build_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), options.quiet) else: