- Add support for loading localized strings from locale .pak files (issue #357).

- Add support for loading DevTools resources from chrome.pak via the chrome-devtools scheme (issue #358).
- Add tools_gyp.patch to fix a bug in GYP.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@295 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-09-30 09:22:54 +00:00
parent ebc4feb095
commit 9842abc0ab
16 changed files with 575 additions and 135 deletions

151
cef.gyp
View File

@ -5,6 +5,8 @@
{
'variables': {
'chromium_code': 1,
'repack_locales_cmd': ['python', 'tools/repack_locales.py'],
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/cef',
},
'includes': [
# Bring in the source file lists for cefclient.
@ -55,6 +57,65 @@
},
'conditions': [
['OS=="win"', {
'variables': {
'repack_path': '../tools/grit/grit/format/repack.py',
},
'actions': [
{
'action_name': 'repack_locales',
'inputs': [
'tools/repack_locales.py',
# NOTE: Ideally the common command args would be shared
# amongst inputs/outputs/action, but the args include shell
# variables which need to be passed intact, and command
# expansion wants to expand the shell variables. Adding the
# explicit quoting here was the only way it seemed to work.
'>!@(<(repack_locales_cmd) -i -g \"<(grit_out_dir)\" -s \"<(SHARED_INTERMEDIATE_DIR)\" -x \"<(INTERMEDIATE_DIR)\" <(locales))',
],
'outputs': [
'>!@(<(repack_locales_cmd) -o -g \"<(grit_out_dir)\" -s \"<(SHARED_INTERMEDIATE_DIR)\" -x \"<(INTERMEDIATE_DIR)\" <(locales))',
],
'action': [
'<@(repack_locales_cmd)',
'-g', '<(grit_out_dir)',
'-s', '<(SHARED_INTERMEDIATE_DIR)',
'-x', '<(INTERMEDIATE_DIR)',
'<@(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': [
{
'destination': '<(PRODUCT_DIR)/locales',
'files': [
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(INTERMEDIATE_DIR) <(locales))'
],
},
{
'destination': '<(PRODUCT_DIR)',
'files': [
'<(INTERMEDIATE_DIR)/repack/chrome.pak'
],
},
],
'msvs_settings': {
'VCLinkerTool': {
# Set /SUBSYSTEM:WINDOWS.
@ -83,15 +144,37 @@
},
'actions': [
{
# TODO(mark): Make this work with more languages than the
# hardcoded en-US.
'action_name': 'repack_locale',
'action_name': 'repack_locales',
'process_outputs_as_mac_bundle_resources': 1,
'inputs': [
'tools/repack_locales.py',
# NOTE: Ideally the common command args would be shared
# amongst inputs/outputs/action, but the args include shell
# variables which need to be passed intact, and command
# expansion wants to expand the shell variables. Adding the
# explicit quoting here was the only way it seemed to work.
'>!@(<(repack_locales_cmd) -i -g \'<(grit_out_dir)\' -s \'<(SHARED_INTERMEDIATE_DIR)\' -x \'<(INTERMEDIATE_DIR)\' <(locales))',
],
'outputs': [
'>!@(<(repack_locales_cmd) -o -g \'<(grit_out_dir)\' -s \'<(SHARED_INTERMEDIATE_DIR)\' -x \'<(INTERMEDIATE_DIR)\' <(locales))',
],
'action': [
'<@(repack_locales_cmd)',
'-g', '<(grit_out_dir)',
'-s', '<(SHARED_INTERMEDIATE_DIR)',
'-x', '<(INTERMEDIATE_DIR)',
'<@(locales)',
],
},
{
'action_name': 'repack_resources',
'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',
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_en-US.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak',
],
},
@ -100,20 +183,18 @@
'<@(pak_inputs)',
],
'outputs': [
'<(INTERMEDIATE_DIR)/repack/cefclient.pak',
'<(INTERMEDIATE_DIR)/repack/chrome.pak',
],
'action': ['python', '<(repack_path)', '<@(_outputs)', '<@(pak_inputs)'],
'process_outputs_as_mac_bundle_resources': 1,
},
],
'copies': [
{
# Add library dependencies and inspector resources to the bundle.
# Add library dependencies to the bundle.
'destination': '<(PRODUCT_DIR)/cefclient.app/Contents/MacOS/',
'files': [
'<(PRODUCT_DIR)/libcef.dylib',
'<(PRODUCT_DIR)/ffmpegsumo.so',
'<(PRODUCT_DIR)/resources/',
],
},
{
@ -203,10 +284,6 @@
'../third_party/libxslt/libxslt.gyp:libxslt',
'../third_party/modp_b64/modp_b64.gyp:modp_b64',
'../third_party/WebKit/Source/WebCore/WebCore.gyp/WebCore.gyp:webcore',
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:concatenated_devtools_css',
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:concatenated_devtools_js',
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:devtools_html',
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:inspector_resources',
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit',
'../third_party/zlib/zlib.gyp:zlib',
'../ui/ui.gyp:gfx_resources',
@ -356,7 +433,6 @@
'<@(includes_win)',
'$(OutDir)/obj/global_intermediate/webkit/webkit_chromium_resources.rc',
'$(OutDir)/obj/global_intermediate/webkit/webkit_resources.rc',
'$(OutDir)/obj/global_intermediate/webkit/webkit_strings_en-US.rc',
'libcef_dll/libcef_dll.rc',
],
'link_settings': {
@ -364,7 +440,7 @@
'-lcomctl32.lib',
],
},
}]
}],
],
},
{
@ -387,6 +463,45 @@
'<@(libcef_dll_wrapper_sources_common)',
],
},
{
'target_name': 'cef_extra_resources',
'type': 'none',
'dependencies': [
'../third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:generate_devtools_grd',
],
# These resources end up in chrome.pak because they are resources
# used by internal pages. Putting them in a spearate pak file makes
# it easier for us to reference them internally.
'actions': [
{
'action_name': 'devtools_resources',
# This can't use ../build/grit_action.gypi because the grd file
# is generated a build time, so the trick of using grit_info to get
# the real inputs/outputs at GYP time isn't possible.
'variables': {
'grit_cmd': ['python', '../tools/grit/grit.py'],
'grit_grd_file': '<(SHARED_INTERMEDIATE_DIR)/devtools/devtools_resources.grd',
},
'inputs': [
'<(grit_grd_file)',
'<!@pymod_do_main(grit_info --inputs)',
],
'outputs': [
'<(grit_out_dir)/grit/devtools_resources.h',
'<(grit_out_dir)/devtools_resources.pak',
'<(grit_out_dir)/grit/devtools_resources_map.cc',
'<(grit_out_dir)/grit/devtools_resources_map.h',
],
'action': ['<@(grit_cmd)',
'-i', '<(grit_grd_file)', 'build',
'-o', '<(grit_out_dir)',
'-D', 'SHARED_INTERMEDIATE_DIR=<(SHARED_INTERMEDIATE_DIR)',
'<@(grit_defines)' ],
'message': 'Generating resources from <(grit_grd_file)',
},
],
'includes': [ '../build/grit_target.gypi' ],
},
{
'target_name': 'libcef_static',
'type': 'static_library',
@ -397,9 +512,11 @@
'include_dirs': [
'.',
'..',
'../third_party/WebKit/Source/WebKit/chromium/public'
'../third_party/WebKit/Source/WebKit/chromium/public',
'<(grit_out_dir)',
],
'dependencies': [
'cef_extra_resources',
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../build/temp_gyp/googleurl.gyp:googleurl',
@ -447,6 +564,8 @@
'libcef/browser_devtools_callargs.h',
'libcef/browser_devtools_client.cc',
'libcef/browser_devtools_client.h',
'libcef/browser_devtools_scheme_handler.cc',
'libcef/browser_devtools_scheme_handler.h',
'libcef/browser_file_system.cc',
'libcef/browser_file_system.h',
'libcef/browser_file_writer.cc',
@ -545,6 +664,8 @@
'libcef/xml_reader_impl.h',
'libcef/zip_reader_impl.cc',
'libcef/zip_reader_impl.h',
# DevTools resource IDs generated by grit
'<(grit_out_dir)/grit/devtools_resources_map.cc',
],
'conditions': [
['OS=="win"', {

View File

@ -0,0 +1,125 @@
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#include "browser_devtools_scheme_handler.h"
#include "include/cef.h"
#include <string>
#include "base/file_util.h"
#include "base/string_util.h"
#include "grit/devtools_resources_map.h"
#include "net/base/mime_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "webkit/glue/webkit_glue.h"
const char kChromeDevToolsScheme[] = "chrome-devtools";
const char kChromeDevToolsHost[] = "devtools";
const char kChromeDevToolsURL[] = "chrome-devtools://devtools/";
namespace {
class DevToolsSchemeHandler : public CefSchemeHandler
{
public:
DevToolsSchemeHandler(const std::string& path,
CefRefPtr<CefStreamReader> reader,
int size)
: path_(path), reader_(reader), size_(size)
{
}
virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
CefString& redirectUrl,
CefRefPtr<CefSchemeHandlerCallback> callback)
OVERRIDE
{
callback->HeadersAvailable();
return true;
}
virtual void GetResponseHeaders(CefRefPtr<CefResponse> response,
int64& response_length) OVERRIDE
{
response_length = size_;
std::string mime_type = "text/plain";
if(net::GetMimeTypeFromFile(FilePath(CefString(path_)), &mime_type))
response->SetMimeType(mime_type);
response->SetStatus(200);
}
virtual bool ReadResponse(void* data_out,
int bytes_to_read,
int& bytes_read,
CefRefPtr<CefSchemeHandlerCallback> callback)
OVERRIDE
{
bytes_read = reader_->Read(data_out, 1, bytes_to_read);
return (bytes_read > 0);
}
virtual void Cancel() OVERRIDE
{
}
private:
std::string path_;
CefRefPtr<CefStreamReader> reader_;
int size_;
IMPLEMENT_REFCOUNTING(DevToolSSchemeHandler);
};
class DevToolsSchemeHandlerFactory : public CefSchemeHandlerFactory
{
public:
DevToolsSchemeHandlerFactory() {}
virtual CefRefPtr<CefSchemeHandler> Create(const CefString& scheme_name,
CefRefPtr<CefRequest> request)
OVERRIDE
{
std::string url = request->GetURL();
const char* path = &url.c_str()[strlen(kChromeDevToolsURL)];
int size = -1;
CefRefPtr<CefStreamReader> reader = GetStreamReader(path, size);
if (!reader.get())
return NULL;
return new DevToolsSchemeHandler(path, reader, size);
}
CefRefPtr<CefStreamReader> GetStreamReader(const char* path, int& size)
{
// Create a stream for the grit resource.
for(size_t i = 0; i < kDevtoolsResourcesSize; ++i) {
if (base::strcasecmp(kDevtoolsResources[i].name, path) == 0) {
base::StringPiece piece =
webkit_glue::GetDataResource(kDevtoolsResources[i].value);
if (!piece.empty()) {
size = piece.size();
return CefStreamReader::CreateForData(const_cast<char*>(piece.data()),
size);
}
}
}
NOTREACHED() << "Missing DevTools resource: "<<path;
return NULL;
}
IMPLEMENT_REFCOUNTING(DevToolSSchemeHandlerFactory);
};
} // namespace
// Register the DevTools scheme handler.
void RegisterDevToolsSchemeHandler()
{
CefRegisterCustomScheme(kChromeDevToolsScheme, true, false, true);
CefRegisterSchemeHandlerFactory(kChromeDevToolsScheme, kChromeDevToolsHost,
new DevToolsSchemeHandlerFactory());
}

View File

@ -0,0 +1,15 @@
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifndef _CEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H
#define _CEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H
extern const char kChromeDevToolsScheme[];
extern const char kChromeDevToolsHost[];
extern const char kChromeDevToolsURL[];
// Register the DevTools scheme handler.
void RegisterDevToolsSchemeHandler();
#endif // _CEF_BROWSER_DEVTOOLS_SCHEME_HANDLER_H

View File

@ -3,10 +3,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cef_context.h"
#include "browser_devtools_scheme_handler.h"
#include "browser_impl.h"
#include "browser_webkit_glue.h"
#include "browser_zoom_map.h"
#include "cef_context.h"
#include "dom_document_impl.h"
#include "request_impl.h"
#include "stream_impl.h"
@ -1412,14 +1413,7 @@ void CefBrowserImpl::UIT_ShowDevTools()
BrowserDevToolsClient* client = dev_tools_agent_->client();
if (!client) {
// Create the inspector window.
FilePath dir_exe;
PathService::Get(base::DIR_EXE, &dir_exe);
FilePath devtools_path =
dir_exe.AppendASCII("resources/inspector/devtools.html");
// Mac requires that the URL have a file:// prefix.
CefString path = devtools_path.value();
CefString url(base::StringPrintf("file://%s", path.ToString().c_str()));
CefString url(base::StringPrintf("%sdevtools.html", kChromeDevToolsURL));
CefPopupFeatures features;
CefRefPtr<CefBrowserImpl> browser = UIT_CreatePopupWindow(url, features);

View File

@ -19,6 +19,7 @@ MSVC_POP_WARNING();
#include "browser_webkit_glue.h"
#include "cef_context.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
@ -27,6 +28,7 @@ MSVC_POP_WARNING();
#include "net/base/mime_util.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "ui/base/resource/resource_bundle.h"
#include "webkit/glue/user_agent.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/plugins/npapi/plugin_list.h"
@ -38,6 +40,28 @@ using WebKit::WebFrameImpl;
namespace webkit_glue {
void InitializeDataPak(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.
FilePath chrome_pack_path;
PathService::Get(base::DIR_EXE, &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
}
string16 GetLocalizedString(int message_id) {
return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id);
}
bool IsMediaPlayerAvailable() {
return true;
}

View File

@ -2,6 +2,8 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/cef.h"
#if defined(OS_WIN)
#include <windows.h>
#endif
@ -33,17 +35,15 @@ void CaptureWebViewBitmap(HWND mainWnd, WebKit::WebView* webview,
BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits);
#endif
void InitializeDataPak(const std::string& locale);
#if defined(OS_MACOSX)
void InitializeDataPak();
FilePath GetResourcesFilePath();
#endif
// Text encoding objects must be initialized on the main thread.
void InitializeTextEncoding();
// This is called indirectly by the network layer to access resources.
base::StringPiece NetResourceProvider(int key);
// Retrieve the V8 context associated with the frame.
v8::Handle<v8::Context> GetV8Context(WebKit::WebFrame* frame);

View File

@ -16,25 +16,12 @@
#include "base/path_service.h"
#include "base/utf_string_conversions.h"
#include "grit/webkit_resources.h"
#include "ui/base/resource/data_pack.h"
#include "ui/base/resource/resource_bundle.h"
#include "webkit/glue/webkit_glue.h"
namespace webkit_glue {
// Data pack resource. This is a pointer to the mmapped resources file.
static ui::DataPack* g_resource_data_pack = NULL;
void InitializeDataPak() {
// mmap the data pack which holds strings used by WebCore.
// TODO(port): Allow the embedder to customize the pak name.
g_resource_data_pack = new ui::DataPack;
NSString *resource_path =
[base::mac::MainAppBundle() pathForResource:@"cefclient" ofType:@"pak"];
FilePath resources_pak_path([resource_path fileSystemRepresentation]);
if (!g_resource_data_pack->Load(resources_pak_path))
LOG(FATAL) << "failed to load cefclient.pak";
}
// Helper method for getting the path to the CEF resources directory.
FilePath GetResourcesFilePath() {
FilePath path;
@ -53,37 +40,6 @@ FilePath GetResourcesFilePath() {
return path.AppendASCII("res");
}
}
string16 GetLocalizedString(int message_id) {
base::StringPiece res;
if (!g_resource_data_pack->GetStringPiece(message_id, &res)) {
LOG(FATAL) << "failed to load webkit string with id " << message_id;
}
// Data packs hold strings as either UTF8 or UTF16.
string16 msg;
switch (g_resource_data_pack->GetTextEncodingType()) {
case ui::DataPack::UTF8:
msg = UTF8ToUTF16(res);
break;
case ui::DataPack::UTF16:
msg = string16(reinterpret_cast<const char16*>(res.data()),
res.length() / 2);
break;
case ui::DataPack::BINARY:
default:
break;
}
return msg;
}
base::StringPiece NetResourceProvider(int key) {
base::StringPiece res;
g_resource_data_pack->GetStringPiece(key, &res);
return res;
}
base::StringPiece GetDataResource(int resource_id) {
switch (resource_id) {
@ -116,29 +72,15 @@ base::StringPiece GetDataResource(int resource_id) {
}
return resize_corner_data;
}
case IDR_SEARCH_CANCEL:
case IDR_SEARCH_CANCEL_PRESSED:
case IDR_SEARCH_MAGNIFIER:
case IDR_SEARCH_MAGNIFIER_RESULTS:
case IDR_MEDIA_PAUSE_BUTTON:
case IDR_MEDIA_PLAY_BUTTON:
case IDR_MEDIA_PLAY_BUTTON_DISABLED:
case IDR_MEDIA_SOUND_FULL_BUTTON:
case IDR_MEDIA_SOUND_NONE_BUTTON:
case IDR_MEDIA_SOUND_DISABLED:
case IDR_MEDIA_SLIDER_THUMB:
case IDR_MEDIA_VOLUME_SLIDER_THUMB:
case IDR_INPUT_SPEECH:
case IDR_INPUT_SPEECH_RECORDING:
case IDR_INPUT_SPEECH_WAITING:
return NetResourceProvider(resource_id);
default:
break;
}
return base::StringPiece();
base::StringPiece piece =
ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id);
DCHECK(!piece.empty());
return piece;
}
void DidLoadPlugin(const std::string& filename) {

View File

@ -23,6 +23,7 @@ MSVC_POP_WARNING();
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/gdi_util.h"
#include "webkit/glue/webkit_glue.h"
@ -32,19 +33,6 @@ using WebKit::WebView;
namespace webkit_glue {
string16 GetLocalizedString(int message_id) {
// Localized resources are provided via webkit_resources.rc and
// webkit_strings_en-US.rc.
const ATLSTRINGRESOURCEIMAGE* image =
AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(),
message_id);
if (!image) {
NOTREACHED();
return L"No string for this identifier!";
}
return string16(image->achString, image->nLength);
}
base::StringPiece GetRawDataResource(HMODULE module, int resource_id) {
void* data_ptr;
size_t data_size;
@ -54,15 +42,21 @@ base::StringPiece GetRawDataResource(HMODULE module, int resource_id) {
: base::StringPiece();
}
base::StringPiece NetResourceProvider(int key) {
base::StringPiece GetDataResource(int resource_id) {
base::StringPiece piece;
// Try to load the resource from the DLL.
HMODULE hModule = ::GetModuleHandle(L"libcef.dll");
if(!hModule)
hModule = ::GetModuleHandle(NULL);
return GetRawDataResource(hModule, key);
}
piece = GetRawDataResource(hModule, resource_id);
base::StringPiece GetDataResource(int resource_id) {
return NetResourceProvider(resource_id);
// Try to load the resource from the resource pack.
if (piece.empty())
piece = ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id);
DCHECK(!piece.empty()) << "Resource "<<resource_id<<" could not be loaded";
return piece;
}
bool EnsureFontLoaded(HFONT font) {

View File

@ -8,15 +8,18 @@
#include "browser_webkit_init.h"
#include "cef_context.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/i18n/icu_util.h"
#include "base/metrics/stats_table.h"
#include "base/rand_util.h"
#include "base/string_number_conversions.h"
#include "browser_devtools_scheme_handler.h"
#include "build/build_config.h"
#include "net/base/net_module.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifier.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h"
#include "ui/base/ui_base_paths.h"
#include "ui/gfx/gl/gl_implementation.h"
#include "webkit/extensions/v8/gc_extension.h"
#include "webkit/glue/webkit_glue.h"
@ -45,8 +48,6 @@ CefProcessUIThread::~CefProcessUIThread() {
}
void CefProcessUIThread::Init() {
PlatformInit();
// Initialize the global CommandLine object.
CommandLine::Init(0, NULL);
@ -70,24 +71,34 @@ void CefProcessUIThread::Init() {
logging::DONT_LOCK_LOG_FILE, logging::APPEND_TO_OLD_LOG_FILE,
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
// Load ICU data tables.
bool ret = icu_util::Initialize();
if(!ret) {
#if defined(OS_WIN)
MessageBox(NULL, L"Failed to load the required icudt library",
L"CEF Initialization Error", MB_ICONERROR | MB_OK);
#endif
return;
}
// Provides path resolution required for locating locale pack files.
ui::RegisterPathProvider();
std::string localeStr = CefString(&settings.locale);
if (localeStr.empty())
localeStr = "en-US";
webkit_glue::InitializeDataPak(localeStr);
PlatformInit();
// Initialize WebKit.
webkit_init_ = new BrowserWebKitInit();
// Initialize WebKit encodings
webkit_glue::InitializeTextEncoding();
// Load ICU data tables.
bool ret = icu_util::Initialize();
if(!ret) {
#if defined(OS_WIN)
MessageBox(NULL, L"Failed to load the required icudt38 library",
L"CEF Initialization Error", MB_ICONERROR | MB_OK);
#endif
return;
}
// Config the network module so it has access to a limited set of resources.
net::NetModule::SetResourceProvider(webkit_glue::NetResourceProvider);
net::NetModule::SetResourceProvider(webkit_glue::GetDataResource);
// Load and initialize the stats table. Attempt to construct a somewhat
// unique name to isolate separate instances from each other.
@ -145,6 +156,10 @@ void CefProcessUIThread::Init() {
// Initialize WebKit with the current state.
WebKit::WebNetworkStateNotifier::setOnLine(
!net::NetworkChangeNotifier::IsOffline());
// Perform DevTools scheme registration when CEF initialization is complete.
CefThread::PostTask(CefThread::UI, FROM_HERE,
base::Bind(&RegisterDevToolsSchemeHandler));
}
void CefProcessUIThread::CleanUp() {

View File

@ -9,6 +9,7 @@
#import "include/cef_application_mac.h"
#include "cef_process_ui_thread.h"
#include "browser_webkit_glue.h"
#include "cef_context.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
@ -19,8 +20,6 @@ void CefProcessUIThread::PlatformInit() {
InitWebCoreSystemInterface();
webkit_glue::InitializeDataPak();
// On Mac, the select popup menus are rendered by the browser.
WebKit::WebView::setUseExternalPopupMenus(true);
}

View File

@ -6,4 +6,6 @@ patches = {
'build' : '../build/',
# http://codereview.chromium.org/6730028/
'base' : '../base/',
# http://code.google.com/p/gyp/issues/detail?id=223
'tools_gyp' : '../tools/gyp/',
}

View File

@ -0,0 +1,14 @@
Index: pylib/gyp/input.py
===================================================================
--- pylib/gyp/input.py (revision 1051)
+++ pylib/gyp/input.py (working copy)
@@ -668,7 +668,8 @@
# that don't load quickly, this can be faster than
# <!(python modulename param eters). Do this in |build_file_dir|.
oldwd = os.getcwd() # Python doesn't like os.open('.'): no fchdir.
- os.chdir(build_file_dir)
+ if not build_file_dir is None:
+ os.chdir(build_file_dir)
parsed_contents = shlex.split(contents)
py_module = __import__(parsed_contents[0])

View File

@ -535,6 +535,10 @@ int main(int argc, char* argv[])
// Initialize CEF.
CefSettings settings;
// Use the Chinese language locale.
// CefString(&settings.locale).FromASCII("zh-cn");
CefInitialize(settings);
// Initialize tests.

View File

@ -68,6 +68,9 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
// Specify a cache path value.
//CefString(&settings.cache_path).FromASCII("c:\\temp\\cache");
// Use the Chinese language locale.
// CefString(&settings.locale).FromASCII("zh-cn");
#ifdef NDEBUG
// Only log error messages and higher in release build.
settings.log_severity = LOGSEVERITY_ERROR;

View File

@ -169,42 +169,50 @@ if sys.platform == 'win32':
# transfer cefclient files
transfer_gypi_files(cef_dir, cef_paths['cefclient_sources_win'], \
'tests/cefclient/', cefclient_dir, options.quiet)
# transfer build/Debug files
dst_dir = os.path.join(output_dir, 'Debug')
make_dir(dst_dir, options.quiet)
copy_files(os.path.join(cef_dir, 'Debug/*.dll'), dst_dir, options.quiet)
copy_files(os.path.join(script_dir, 'distrib/win/*.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_dir(os.path.join(cef_dir, 'Debug/locales'), os.path.join(dst_dir, 'locales'), \
options.quiet)
# transfer build/Release files
dst_dir = os.path.join(output_dir, 'Release')
make_dir(dst_dir, options.quiet)
copy_files(os.path.join(cef_dir, 'Release/*.dll'), dst_dir, options.quiet)
copy_files(os.path.join(script_dir, 'distrib/win/*.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_dir(os.path.join(cef_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), \
options.quiet)
# transfer lib/Debug files
dst_dir = os.path.join(output_dir, 'lib/Debug')
make_dir(dst_dir, options.quiet)
copy_file(os.path.join(cef_dir, 'Debug/lib/libcef.lib'), dst_dir, options.quiet)
# transfer lib/Release files
dst_dir = os.path.join(output_dir, 'lib/Release')
make_dir(dst_dir, options.quiet)
copy_file(os.path.join(cef_dir, 'Release/lib/libcef.lib'), dst_dir, options.quiet)
# generate doc files
os.popen('make_cppdocs.bat '+cef_rev)
# transfer docs files
dst_dir = os.path.join(output_dir, 'docs')
src_dir = os.path.join(cef_dir, 'docs')
if path_exists(dst_dir):
copy_dir(src_dir, dst_dir, options.quiet)
# transfer additional files, if any
transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/win/transfer.cfg'), \
output_dir, options.quiet)
# generate the project files
generate_msvs_projects('2005');
generate_msvs_projects('2008');

180
tools/repack_locales.py Normal file
View File

@ -0,0 +1,180 @@
#!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Helper script to repack paks for a list of locales.
Gyp doesn't have any built-in looping capability, so this just provides a way to
loop over a list of locales when repacking pak files, thus avoiding a
proliferation of mostly duplicate, cut-n-paste gyp actions.
"""
import getopt
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..',
'tools', 'grit'))
from grit.format import data_pack
# Some build paths defined by gyp.
GRIT_DIR = None
SHARE_INT_DIR = None
INT_DIR = None
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def calc_output(locale):
"""Determine the file that will be generated for the given locale."""
#e.g. '<(INTERMEDIATE_DIR)/repack/da.pak',
# For Fake Bidi, generate it at a fixed path so that tests can safely
# reference it.
if locale == 'fake-bidi':
return '%s/%s.pak' % (INT_DIR, locale)
if sys.platform in ('darwin',):
# For Cocoa to find the locale at runtime, it needs to use '_' instead
# of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
# simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
if locale == 'en-US':
locale = 'en'
return '%s/repack/%s.lproj/locale.pak' % (INT_DIR, locale.replace('-', '_'))
else:
return os.path.join(INT_DIR, 'repack', locale + '.pak')
def calc_inputs(locale):
"""Determine the files that need processing for the given locale."""
inputs = []
#e.g. '<(grit_out_dir)/generated_resources_da.pak'
#inputs.append(os.path.join(GRIT_DIR, 'generated_resources_%s.pak' % locale))
#e.g. '<(grit_out_dir)/locale_settings_da.pak'
#inputs.append(os.path.join(GRIT_DIR, 'locale_settings_%s.pak' % locale))
#e.g. '<(grit_out_dir)/platform_locale_settings_da.pak'
#inputs.append(os.path.join(GRIT_DIR,
# 'platform_locale_settings_%s.pak' % locale))
#e.g. '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_da.pak'
inputs.append(os.path.join(SHARE_INT_DIR, 'webkit',
'webkit_strings_%s.pak' % locale))
#e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/ui_strings_da.pak',
inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'ui_strings',
'ui_strings_%s.pak' % locale))
#e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings_da.pak',
inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'app_locale_settings',
'app_locale_settings_%s.pak' % locale))
return inputs
def list_outputs(locales):
"""Returns the names of files that will be generated for the given locales.
This is to provide gyp the list of output files, so build targets can
properly track what needs to be built.
"""
outputs = []
for locale in locales:
outputs.append(calc_output(locale))
# Quote each element so filename spaces don't mess up gyp's attempt to parse
# it into a list.
return " ".join(['"%s"' % x for x in outputs])
def list_inputs(locales):
"""Returns the names of files that will be processed for the given locales.
This is to provide gyp the list of input files, so build targets can properly
track their prerequisites.
"""
inputs = []
for locale in locales:
inputs += calc_inputs(locale)
# Quote each element so filename spaces don't mess up gyp's attempt to parse
# it into a list.
return " ".join(['"%s"' % x for x in inputs])
def repack_locales(locales):
""" Loop over and repack the given locales."""
for locale in locales:
inputs = []
inputs += calc_inputs(locale)
output = calc_output(locale)
data_pack.DataPack.RePack(output, inputs)
def DoMain(argv):
global GRIT_DIR
global SHARE_INT_DIR
global INT_DIR
short_options = 'iog:s:x:b:h'
long_options = 'help'
print_inputs = False
print_outputs = False
usage_msg = ''
helpstr = """\
Usage: %s [-h] [-i | -o] -g <DIR> -x <DIR> -s <DIR> <locale> [...]
-h, --help Print this help, then exit.
-i Print the expected input file list, then exit.
-o Print the expected output file list, then exit.
-g DIR GRIT build files output directory.
-x DIR Intermediate build files output directory.
-s DIR Shared intermediate build files output directory.
locale [...] One or more locales to repack.""" % (
os.path.basename(__file__))
try:
opts, locales = getopt.getopt(argv, short_options, long_options)
except getopt.GetoptError, msg:
raise Usage(str(msg))
if not locales:
usage_msg = 'Please specificy at least one locale to process.\n'
for o, a in opts:
if o in ('-i'):
print_inputs = True
elif o in ('-o'):
print_outputs = True
elif o in ('-g'):
GRIT_DIR = a
elif o in ('-s'):
SHARE_INT_DIR = a
elif o in ('-x'):
INT_DIR = a
elif o in ('-h', '--help'):
raise Usage(helpstr)
if not (GRIT_DIR and INT_DIR and SHARE_INT_DIR):
usage_msg += 'Please specify all of "-g" and "-x" and "-s".\n'
if print_inputs and print_outputs:
usage_msg += 'Please specify only one of "-i" or "-o".\n'
if usage_msg:
raise Usage(usage_msg)
if print_inputs:
return list_inputs(locales)
if print_outputs:
return list_outputs(locales)
return repack_locales(locales)
if __name__ == '__main__':
results = DoMain(sys.argv[1:])
if results:
print results