Add the ability to (issue #236):

1. Disable pack file loading via CefSettings.pack_loading_disabled.
2. Customize pack file load paths via CefSettings.pack_file_path and CefSettings.locales_dir_path.
3. Provide custom resource bundle handling via CefResourceBundleHandler.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@501 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-02-16 17:11:49 +00:00
parent def9fdb540
commit 1a092a0c1a
34 changed files with 795 additions and 236 deletions

View File

@ -810,7 +810,6 @@
'sources': [
'<@(includes_mac)',
'libcef/browser_impl_mac.mm',
'libcef/browser_webkit_glue_mac.mm',
'libcef/browser_webview_delegate_mac.mm',
'libcef/browser_webview_mac.h',
'libcef/browser_webview_mac.mm',
@ -839,7 +838,6 @@
'sources': [
'<@(includes_linux)',
'libcef/browser_impl_gtk.cc',
'libcef/browser_webkit_glue_gtk.cc',
'libcef/browser_webview_delegate_gtk.cc',
'libcef/cef_process_ui_thread_gtk.cc',
'libcef/external_protocol_handler_gtk.cc',

View File

@ -38,6 +38,7 @@
'include/cef_render_handler.h',
'include/cef_request.h',
'include/cef_request_handler.h',
'include/cef_resource_bundle_handler.h',
'include/cef_response.h',
'include/cef_scheme.h',
'include/cef_storage.h',
@ -77,6 +78,7 @@
'include/capi/cef_render_handler_capi.h',
'include/capi/cef_request_capi.h',
'include/capi/cef_request_handler_capi.h',
'include/capi/cef_resource_bundle_handler_capi.h',
'include/capi/cef_response_capi.h',
'include/capi/cef_scheme_capi.h',
'include/capi/cef_storage_capi.h',
@ -154,6 +156,8 @@
'libcef_dll/cpptoc/request_cpptoc.h',
'libcef_dll/ctocpp/request_handler_ctocpp.cc',
'libcef_dll/ctocpp/request_handler_ctocpp.h',
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.cc',
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h',
'libcef_dll/cpptoc/response_cpptoc.cc',
'libcef_dll/cpptoc/response_cpptoc.h',
'libcef_dll/ctocpp/scheme_handler_ctocpp.cc',
@ -258,6 +262,8 @@
'libcef_dll/ctocpp/request_ctocpp.h',
'libcef_dll/cpptoc/request_handler_cpptoc.cc',
'libcef_dll/cpptoc/request_handler_cpptoc.h',
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.cc',
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h',
'libcef_dll/ctocpp/response_ctocpp.cc',
'libcef_dll/ctocpp/response_ctocpp.h',
'libcef_dll/cpptoc/scheme_handler_cpptoc.cc',

View File

@ -88,7 +88,8 @@ CEF_EXPORT void cef_run_message_loop();
CEF_EXPORT void cef_quit_message_loop();
///
// Implement this structure to provide handler implementations.
// Implement this structure to provide handler implementations. Methods will be
// called on the thread indicated.
///
typedef struct _cef_app_t {
///
@ -96,9 +97,18 @@ typedef struct _cef_app_t {
///
cef_base_t base;
///
// Return the handler for resource bundle events. If
// CefSettings.pack_loading_disabled is true (1) a handler must be returned.
// If no handler is returned resources will be loaded from pack files. This
// function is called on multiple threads.
///
struct _cef_resource_bundle_handler_t* (
CEF_CALLBACK *get_resource_bundle_handler)(struct _cef_app_t* self);
///
// Return the handler for proxy events. If not handler is returned the default
// system handler will be used.
// system handler will be used. This function is called on the IO thread.
///
struct _cef_proxy_handler_t* (CEF_CALLBACK *get_proxy_handler)(
struct _cef_app_t* self);

View File

@ -0,0 +1,95 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_HANDLER_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_HANDLER_CAPI_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "include/capi/cef_base_capi.h"
///
// Structure used to implement a custom resource bundle structure. The functions
// of this structure may be called on multiple threads.
///
typedef struct _cef_resource_bundle_handler_t {
///
// Base structure.
///
cef_base_t base;
///
// Called to retrieve a localized translation for the string specified by
// |message_id|. To provide the translation set |string| to the translation
// string and return true (1). To use the default translation return false
// (0).
//
// WARNING: Be cautious when implementing this function. ID values are auto-
// generated when CEF is built and may change between versions. Existing ID
// values can be discovered by searching for *_strings.h in the
// "obj/global_intermediate" build output directory.
///
int (CEF_CALLBACK *get_localized_string)(
struct _cef_resource_bundle_handler_t* self, int message_id,
cef_string_t* string);
///
// Called to retrieve data for the resource specified by |resource_id|. To
// provide the resource data set |data| and |data_size| to the data pointer
// and size respectively and return true (1). To use the default resource data
// return false (0). The resource data will not be copied and must remain
// resident in memory.
//
// WARNING: Be cautious when implementing this function. ID values are auto-
// generated when CEF is built and may change between versions. Existing ID
// values can be discovered by searching for *_resources.h in the
// "obj/global_intermediate" build output directory.
///
int (CEF_CALLBACK *get_data_resource)(
struct _cef_resource_bundle_handler_t* self, int resource_id, void** data,
size_t* data_size);
} cef_resource_bundle_handler_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_RESOURCE_BUNDLE_HANDLER_CAPI_H_

View File

@ -41,6 +41,7 @@
#include "include/cef_base.h"
#include "include/cef_proxy_handler.h"
#include "include/cef_resource_bundle_handler.h"
class CefApp;
@ -92,17 +93,31 @@ void CefQuitMessageLoop();
///
// Implement this interface to provide handler implementations.
// Implement this interface to provide handler implementations. Methods will be
// called on the thread indicated.
///
/*--cef(source=client,no_debugct_check)--*/
class CefApp : public virtual CefBase {
public:
///
// Return the handler for proxy events. If not handler is returned the default
// system handler will be used.
// Return the handler for resource bundle events. If
// CefSettings.pack_loading_disabled is true a handler must be returned. If no
// handler is returned resources will be loaded from pack files. This method
// is called on multiple threads.
///
/*--cef()--*/
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() { return NULL; }
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() {
return NULL;
}
///
// Return the handler for proxy events. If not handler is returned the default
// system handler will be used. This method is called on the IO thread.
///
/*--cef()--*/
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() {
return NULL;
}
};
#endif // CEF_INCLUDE_CEF_APP_H_

View File

@ -0,0 +1,85 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_RESOURCE_BUNDLE_HANDLER_H_
#define CEF_INCLUDE_CEF_RESOURCE_BUNDLE_HANDLER_H_
#pragma once
#include "include/cef_base.h"
class CefBrowser;
class CefStreamReader;
///
// Class used to implement a custom resource bundle interface. The methods of
// this class may be called on multiple threads.
///
/*--cef(source=client)--*/
class CefResourceBundleHandler : public virtual CefBase {
public:
///
// Called to retrieve a localized translation for the string specified by
// |message_id|. To provide the translation set |string| to the translation
// string and return true. To use the default translation return false.
//
// WARNING: Be cautious when implementing this method. ID values are auto-
// generated when CEF is built and may change between versions. Existing ID
// values can be discovered by searching for *_strings.h in the
// "obj/global_intermediate" build output directory.
///
/*--cef()--*/
virtual bool GetLocalizedString(int message_id,
CefString& string) =0;
///
// Called to retrieve data for the resource specified by |resource_id|. To
// provide the resource data set |data| and |data_size| to the data pointer
// and size respectively and return true. To use the default resource data
// return false. The resource data will not be copied and must remain resident
// in memory.
//
// WARNING: Be cautious when implementing this method. ID values are auto-
// generated when CEF is built and may change between versions. Existing ID
// values can be discovered by searching for *_resources.h in the
// "obj/global_intermediate" build output directory.
///
/*--cef()--*/
virtual bool GetDataResource(int resource_id,
void*& data,
size_t& data_size) =0;
};
#endif // CEF_INCLUDE_CEF_RESOURCE_BUNDLE_HANDLER_H_

View File

@ -117,7 +117,9 @@ typedef struct _cef_settings_t {
///
// The locale string that will be passed to WebKit. If empty the default
// locale of "en-US" will be used.
// locale of "en-US" will be used. This value is ignored on Linux where locale
// is determined using environment variable parsing with the precedence order:
// LANGUAGE, LC_ALL, LC_MESSAGES and LANG.
///
cef_string_t locale;
@ -170,6 +172,30 @@ typedef struct _cef_settings_t {
///
bool auto_detect_proxy_settings_enabled;
#endif
///
// The fully qualified path for the cef.pak file. If this value is empty
// the cef.pak file must be located in the module directory. This value is
// ignored on Mac OS X where pack files are always loaded from the app bundle
// resource directory.
///
cef_string_t pack_file_path;
///
// The fully qualified path for the locales directory. If this value is empty
// the locales directory must be located in the module directory. This value
// is ignored on Mac OS X where pack files are always loaded from the app
// bundle resource directory.
///
cef_string_t locales_dir_path;
///
// Set to true (1) to disable loading of pack files for resources and locales.
// A resource bundle handler must be provided for the browser and renderer
// processes via CefApp::GetResourceBundleHandler() if loading of pack files
// is disabled.
///
bool pack_loading_disabled;
} cef_settings_t;
///

View File

@ -259,6 +259,8 @@ struct CefSettingsTraits {
cef_string_list_free(s->extra_plugin_paths);
cef_string_clear(&s->log_file);
cef_string_clear(&s->javascript_flags);
cef_string_clear(&s->pack_file_path);
cef_string_clear(&s->locales_dir_path);
}
static inline void set(const struct_type* src, struct_type* target,
@ -291,6 +293,12 @@ struct CefSettingsTraits {
target->auto_detect_proxy_settings_enabled =
src->auto_detect_proxy_settings_enabled;
#endif
cef_string_set(src->pack_file_path.str, src->pack_file_path.length,
&target->pack_file_path, copy);
cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
&target->locales_dir_path, copy);
target->pack_loading_disabled = src->pack_loading_disabled;
}
};

View File

@ -13,6 +13,7 @@
#include "include/cef_stream.h"
#include "include/cef_url.h"
#include "libcef/browser_webkit_glue.h"
#include "libcef/cef_context.h"
#include "base/file_util.h"
#include "base/string_util.h"
@ -105,7 +106,7 @@ class DevToolsSchemeHandlerFactory : public CefSchemeHandlerFactory {
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);
_Context->GetDataResource(kDevtoolsResources[i].value);
if (!piece.empty()) {
size = piece.size();
return CefStreamReader::CreateForData(const_cast<char*>(piece.data()),

View File

@ -16,18 +16,11 @@ MSVC_PUSH_WARNING_LEVEL(0);
MSVC_POP_WARNING();
#undef LOG
#include "libcef/cef_context.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/string16.h"
#include "net/base/mime_util.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/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"
@ -39,33 +32,6 @@ using WebKit::WebFrameImpl;
namespace webkit_glue {
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
}
void CleanupResourceBundle() {
ResourceBundle::CleanupSharedInstance();
}
string16 GetLocalizedString(int message_id) {
return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id);
}
bool IsMediaPlayerAvailable() {
return true;
}

View File

@ -9,7 +9,6 @@
#include <string>
#include "base/compiler_specific.h"
#include "base/string_piece.h"
#include "v8/include/v8.h"
#if defined(OS_WIN)
@ -24,10 +23,6 @@ namespace webkit {
struct WebPluginInfo;
}
#if defined(OS_MACOSX)
class FilePath;
#endif
namespace webkit_glue {
#if defined(OS_WIN)
@ -39,16 +34,6 @@ void CaptureWebViewBitmap(HWND mainWnd, WebKit::WebView* webview,
BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits);
#endif
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);
// Text encoding objects must be initialized on the main thread.
void InitializeTextEncoding();

View File

@ -1,23 +0,0 @@
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 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.
#include "libcef/browser_webkit_glue.h"
#include "libcef/cef_context.h"
#include "ui/base/resource/resource_bundle.h"
namespace webkit_glue {
base::StringPiece GetDataResource(int resource_id) {
base::StringPiece piece;
// 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;
}
} // namespace webkit_glue

View File

@ -1,90 +0,0 @@
// Copyright (c) 2010 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2006-2008 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.
#include "libcef/browser_webkit_glue.h"
#include "base/compiler_specific.h"
#include "third_party/WebKit/Source/WebCore/config.h"
#undef LOG
#include "base/file_util.h"
#include "base/logging.h"
#include "base/mac/mac_util.h"
#include "base/path_service.h"
#include "base/utf_string_conversions.h"
#include "grit/webkit_resources.h"
#include "ui/base/resource/resource_bundle.h"
#include "webkit/glue/webkit_glue.h"
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");
}
}
base::StringPiece GetDataResource(int resource_id) {
switch (resource_id) {
case IDR_BROKENIMAGE: {
// Use webkit's broken image icon (16x16)
static std::string broken_image_data;
if (broken_image_data.empty()) {
FilePath path = GetResourcesFilePath();
// In order to match WebKit's colors for the missing image, we have to
// use a PNG. The GIF doesn't have the color range needed to correctly
// match the TIFF they use in Safari.
path = path.AppendASCII("missingImage.png");
bool success = file_util::ReadFileToString(path, &broken_image_data);
if (!success) {
LOG(FATAL) << "Failed reading: " << path.value();
}
}
return broken_image_data;
}
case IDR_TEXTAREA_RESIZER: {
// Use webkit's text area resizer image.
static std::string resize_corner_data;
if (resize_corner_data.empty()) {
FilePath path = GetResourcesFilePath();
path = path.AppendASCII("textAreaResizeCorner.png");
bool success = file_util::ReadFileToString(path, &resize_corner_data);
if (!success) {
LOG(FATAL) << "Failed reading: " << path.value();
}
}
return resize_corner_data;
}
default:
break;
}
base::StringPiece piece =
ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id);
DCHECK(!piece.empty());
return piece;
}
void DidLoadPlugin(const std::string& filename) {
}
void DidUnloadPlugin(const std::string& filename) {
}
} // namespace webkit_glue

View File

@ -16,13 +16,10 @@ MSVC_POP_WARNING();
#undef LOG
#include "base/logging.h"
#include "base/path_service.h"
#include "base/win/resource_util.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/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,37 +29,6 @@ using WebKit::WebView;
namespace webkit_glue {
base::StringPiece GetRawDataResource(HMODULE module, int resource_id) {
void* data_ptr;
size_t data_size;
return base::win::GetDataResourceFromModule(module, resource_id, &data_ptr,
&data_size)
? base::StringPiece(static_cast<char*>(data_ptr), data_size)
: base::StringPiece();
}
base::StringPiece GetDataResource(int resource_id) {
base::StringPiece piece;
FilePath file_path;
HMODULE hModule = NULL;
// Try to load the resource from the DLL.
if (PathService::Get(base::FILE_MODULE, &file_path))
hModule = ::GetModuleHandle(file_path.value().c_str());
if (!hModule)
hModule = ::GetModuleHandle(NULL);
piece = GetRawDataResource(hModule, 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) {
return true;
}

View File

@ -274,11 +274,11 @@ void BrowserWebKitInit::GetPlugins(
}
string16 BrowserWebKitInit::GetLocalizedString(int message_id) {
return webkit_glue::GetLocalizedString(message_id);
return _Context->GetLocalizedString(message_id);
}
base::StringPiece BrowserWebKitInit::GetDataResource(int resource_id) {
return webkit_glue::GetDataResource(resource_id);
return _Context->GetDataResource(resource_id);
}
webkit_glue::ResourceLoaderBridge* BrowserWebKitInit::CreateResourceLoader(

View File

@ -96,7 +96,7 @@ void SelectionClipboardGetContents(GtkClipboard* clipboard,
} // namespace
// WebViewClient ----------------------------------s----------------------------
// WebViewClient ---------------------------------------------------------------
WebKit::WebExternalPopupMenu* BrowserWebViewDelegate::createExternalPopupMenu(
const WebKit::WebPopupMenuInfo& info,

View File

@ -9,12 +9,24 @@
#include "base/bind.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/synchronization/waitable_event.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#if defined(OS_MACOSX) || defined(OS_WIN)
#include "crypto/nss_util.h"
#endif
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
#include "grit/webkit_resources.h"
#endif
#if defined(OS_WIN)
#include "base/win/resource_util.h"
#endif
// Both the CefContext constuctor and the CefContext::RemoveBrowser method need
// to initialize or reset to the same value.
const int kNextBrowserIdReset = 1;
@ -38,6 +50,20 @@ class DestructionObserver : public MessageLoop::DestructionObserver {
base::WaitableEvent *event_;
};
#if defined(OS_WIN)
// Helper method for retrieving a resource from a module.
base::StringPiece GetRawDataResource(HMODULE module, int resource_id) {
void* data_ptr;
size_t data_size;
return base::win::GetDataResourceFromModule(module, resource_id, &data_ptr,
&data_size)
? base::StringPiece(static_cast<char*>(data_ptr), data_size)
: base::StringPiece();
}
#endif // defined(OS_MACOSX)
} // namespace
bool CefInitialize(const CefSettings& settings, CefRefPtr<CefApp> application) {
@ -266,6 +292,166 @@ CefRefPtr<CefBrowserImpl> CefContext::GetBrowserByID(int id) {
return NULL;
}
void CefContext::InitializeResourceBundle() {
if (settings_.pack_loading_disabled)
return;
FilePath pak_file, locales_dir;
if (settings_.pack_file_path.length > 0)
pak_file = FilePath(CefString(&settings_.pack_file_path));
if (pak_file.empty()) {
FilePath pak_dir;
PathService::Get(base::DIR_MODULE, &pak_dir);
pak_file = pak_dir.Append(FILE_PATH_LITERAL("chrome.pak"));
}
if (!pak_file.empty())
PathService::Override(ui::FILE_RESOURCES_PAK, pak_file);
if (settings_.locales_dir_path.length > 0)
locales_dir = FilePath(CefString(&settings_.locales_dir_path));
if (!locales_dir.empty())
PathService::Override(ui::DIR_LOCALES, locales_dir);
std::string locale_str = locale();
const std::string loaded_locale =
ui::ResourceBundle::InitSharedInstance(locale_str);
CHECK(!loaded_locale.empty()) << "Locale could not be found for " <<
locale_str;
#if defined(OS_WIN)
// Explicitly load chrome.pak on Windows.
if (file_util::PathExists(pak_file))
ResourceBundle::AddDataPackToSharedInstance(pak_file);
else
NOTREACHED() << "Could not load chrome.pak";
#endif
}
void CefContext::CleanupResourceBundle() {
if (!settings_.pack_loading_disabled)
ResourceBundle::CleanupSharedInstance();
}
string16 CefContext::GetLocalizedString(int message_id) const {
string16 value;
if (application_.get()) {
CefRefPtr<CefResourceBundleHandler> handler =
application_->GetResourceBundleHandler();
if (handler.get()) {
CefString cef_str;
if (handler->GetLocalizedString(message_id, cef_str))
value = cef_str;
}
}
if (value.empty() && !settings_.pack_loading_disabled)
value = ResourceBundle::GetSharedInstance().GetLocalizedString(message_id);
if (value.empty())
LOG(ERROR) << "No localized string available for id " << message_id;
return value;
}
base::StringPiece CefContext::GetDataResource(int resource_id) const {
base::StringPiece value;
if (application_.get()) {
CefRefPtr<CefResourceBundleHandler> handler =
application_->GetResourceBundleHandler();
if (handler.get()) {
void* data = NULL;
size_t data_size = 0;
if (handler->GetDataResource(resource_id, data, data_size))
value = base::StringPiece(static_cast<char*>(data), data_size);
}
}
#if defined(OS_WIN)
if (value.empty()) {
FilePath file_path;
HMODULE hModule = NULL;
// Try to load the resource from the DLL.
if (PathService::Get(base::FILE_MODULE, &file_path))
hModule = ::GetModuleHandle(file_path.value().c_str());
if (!hModule)
hModule = ::GetModuleHandle(NULL);
value = GetRawDataResource(hModule, resource_id);
}
#elif defined(OS_MACOSX)
if (value.empty()) {
switch (resource_id) {
case IDR_BROKENIMAGE: {
// Use webkit's broken image icon (16x16)
static std::string broken_image_data;
if (broken_image_data.empty()) {
FilePath path = GetResourcesFilePath();
// In order to match WebKit's colors for the missing image, we have to
// use a PNG. The GIF doesn't have the color range needed to correctly
// match the TIFF they use in Safari.
path = path.AppendASCII("missingImage.png");
bool success = file_util::ReadFileToString(path, &broken_image_data);
if (!success) {
LOG(FATAL) << "Failed reading: " << path.value();
}
}
value = broken_image_data;
}
case IDR_TEXTAREA_RESIZER: {
// Use webkit's text area resizer image.
static std::string resize_corner_data;
if (resize_corner_data.empty()) {
FilePath path = GetResourcesFilePath();
path = path.AppendASCII("textAreaResizeCorner.png");
bool success = file_util::ReadFileToString(path, &resize_corner_data);
if (!success) {
LOG(FATAL) << "Failed reading: " << path.value();
}
}
value = resize_corner_data;
}
default:
break;
}
}
#endif // defined(OS_MACOSX)
if (value.empty() && !settings_.pack_loading_disabled)
value = ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id);
if (value.empty())
LOG(ERROR) << "No data resource available for id " << resource_id;
return value;
}
#if defined(OS_MACOSX)
FilePath CefContext::GetResourcesFilePath() const {
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");
}
}
#endif // defined(OS_MACOSX)
std::string CefContext::locale() const {
std::string localeStr = CefString(&settings_.locale);
if (!localeStr.empty())

View File

@ -52,6 +52,16 @@ class CefContext : public CefBase {
CefRefPtr<CefBrowserImpl> GetBrowserByID(int id);
BrowserList* GetBrowserList() { return &browserlist_; }
void InitializeResourceBundle();
void CleanupResourceBundle();
string16 GetLocalizedString(int message_id) const;
base::StringPiece GetDataResource(int resource_id) const;
#if defined(OS_MACOSX)
FilePath GetResourcesFilePath() const;
#endif
// Retrieve the path at which cache data will be stored on disk. If empty,
// cache data will be stored in-memory.
const FilePath& cache_path() const { return cache_path_; }

View File

@ -34,10 +34,18 @@
#include <Objbase.h> // NOLINT(build/include_order)
#endif
namespace {
static const char* kStatsFilePrefix = "libcef_";
static int kStatsFileThreads = 20;
static int kStatsFileCounters = 200;
base::StringPiece ResourceProvider(int resource_id) {
return _Context->GetDataResource(resource_id);
}
} // namespace
CefProcessUIThread::CefProcessUIThread()
: CefThread(CefThread::UI), statstable_(NULL), webkit_init_(NULL) {}
@ -88,7 +96,7 @@ void CefProcessUIThread::Init() {
// Provides path resolution required for locating locale pack files.
ui::RegisterPathProvider();
webkit_glue::InitializeResourceBundle(_Context->locale());
_Context->InitializeResourceBundle();
PlatformInit();
@ -99,7 +107,7 @@ void CefProcessUIThread::Init() {
webkit_glue::InitializeTextEncoding();
// Config the network module so it has access to a limited set of resources.
net::NetModule::SetResourceProvider(webkit_glue::GetDataResource);
net::NetModule::SetResourceProvider(ResourceProvider);
// Load and initialize the stats table. Attempt to construct a somewhat
// unique name to isolate separate instances from each other.
@ -202,7 +210,7 @@ void CefProcessUIThread::CleanUp() {
PlatformCleanUp();
webkit_glue::CleanupResourceBundle();
_Context->CleanupResourceBundle();
}
AudioManager* CefProcessUIThread::audio_manager() {

View File

@ -6,8 +6,8 @@
#include <sys/param.h>
#include "libcef/browser_impl.h"
#include "libcef/browser_webkit_glue.h"
#import "libcef/browser_webview_mac.h"
#include "libcef/cef_context.h"
#include "libcef/drag_download_util.h"
#include "libcef/download_util.h"
#import "libcef/web_drag_source_mac.h"
@ -143,7 +143,7 @@ void PromiseWriterTask::Run() {
if (image == nil) {
// No drag image was provided so create one.
FilePath path = webkit_glue::GetResourcesFilePath();
FilePath path = _Context->GetResourcesFilePath();
path = path.AppendASCII("urlIcon.png");
image = [[NSImage alloc]
initWithContentsOfFile:SysUTF8ToNSString(path.value())];

View File

@ -12,10 +12,27 @@
#include "libcef_dll/cpptoc/app_cpptoc.h"
#include "libcef_dll/cpptoc/proxy_handler_cpptoc.h"
#include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
struct _cef_resource_bundle_handler_t* CEF_CALLBACK app_get_resource_bundle_handler(
struct _cef_app_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefResourceBundleHandler> _retval = CefAppCppToC::Get(
self)->GetResourceBundleHandler();
// Return type: refptr_same
return CefResourceBundleHandlerCppToC::Wrap(_retval);
}
struct _cef_proxy_handler_t* CEF_CALLBACK app_get_proxy_handler(
struct _cef_app_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -37,6 +54,7 @@ struct _cef_proxy_handler_t* CEF_CALLBACK app_get_proxy_handler(
CefAppCppToC::CefAppCppToC(CefApp* cls)
: CefCppToC<CefAppCppToC, CefApp, cef_app_t>(cls) {
struct_.struct_.get_resource_bundle_handler = app_get_resource_bundle_handler;
struct_.struct_.get_proxy_handler = app_get_proxy_handler;
}

View File

@ -0,0 +1,98 @@
// Copyright (c) 2012 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK resource_bundle_handler_get_localized_string(
struct _cef_resource_bundle_handler_t* self, int message_id,
cef_string_t* string) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: string; type: string_byref
DCHECK(string);
if (!string)
return 0;
// Translate param: string; type: string_byref
CefString stringStr(string);
// Execute
bool _retval = CefResourceBundleHandlerCppToC::Get(self)->GetLocalizedString(
message_id,
stringStr);
// Return type: bool
return _retval;
}
int CEF_CALLBACK resource_bundle_handler_get_data_resource(
struct _cef_resource_bundle_handler_t* self, int resource_id, void** data,
size_t* data_size) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: data; type: simple_byref
DCHECK(data);
if (!data)
return 0;
// Verify param: data_size; type: simple_byref
DCHECK(data_size);
if (!data_size)
return 0;
// Translate param: data; type: simple_byref
void* dataVal = data?*data:NULL;
// Translate param: data_size; type: simple_byref
size_t data_sizeVal = data_size?*data_size:0;
// Execute
bool _retval = CefResourceBundleHandlerCppToC::Get(self)->GetDataResource(
resource_id,
dataVal,
data_sizeVal);
// Restore param: data; type: simple_byref
if (data)
*data = dataVal;
// Restore param: data_size; type: simple_byref
if (data_size)
*data_size = data_sizeVal;
// Return type: bool
return _retval;
}
// CONSTRUCTOR - Do not edit by hand.
CefResourceBundleHandlerCppToC::CefResourceBundleHandlerCppToC(
CefResourceBundleHandler* cls)
: CefCppToC<CefResourceBundleHandlerCppToC, CefResourceBundleHandler,
cef_resource_bundle_handler_t>(cls) {
struct_.struct_.get_localized_string =
resource_bundle_handler_get_localized_string;
struct_.struct_.get_data_resource = resource_bundle_handler_get_data_resource;
}
#ifndef NDEBUG
template<> long CefCppToC<CefResourceBundleHandlerCppToC,
CefResourceBundleHandler, cef_resource_bundle_handler_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,41 @@
// Copyright (c) 2012 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_RESOURCE_BUNDLE_HANDLER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_RESOURCE_BUNDLE_HANDLER_CPPTOC_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_resource_bundle_handler.h"
#include "include/capi/cef_resource_bundle_handler_capi.h"
#include "include/cef_browser.h"
#include "include/capi/cef_browser_capi.h"
#include "include/cef_stream.h"
#include "include/capi/cef_stream_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefResourceBundleHandlerCppToC
: public CefCppToC<CefResourceBundleHandlerCppToC, CefResourceBundleHandler,
cef_resource_bundle_handler_t> {
public:
explicit CefResourceBundleHandlerCppToC(CefResourceBundleHandler* cls);
virtual ~CefResourceBundleHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_RESOURCE_BUNDLE_HANDLER_CPPTOC_H_

View File

@ -12,10 +12,25 @@
#include "libcef_dll/ctocpp/app_ctocpp.h"
#include "libcef_dll/ctocpp/proxy_handler_ctocpp.h"
#include "libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
CefRefPtr<CefResourceBundleHandler> CefAppCToCpp::GetResourceBundleHandler() {
if (CEF_MEMBER_MISSING(struct_, get_resource_bundle_handler))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_resource_bundle_handler_t* _retval = struct_->get_resource_bundle_handler(
struct_);
// Return type: refptr_same
return CefResourceBundleHandlerCToCpp::Wrap(_retval);
}
CefRefPtr<CefProxyHandler> CefAppCToCpp::GetProxyHandler() {
if (CEF_MEMBER_MISSING(struct_, get_proxy_handler))
return NULL;

View File

@ -32,6 +32,8 @@ class CefAppCToCpp
virtual ~CefAppCToCpp() {}
// CefApp methods
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler(
) OVERRIDE;
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE;
};

View File

@ -0,0 +1,56 @@
// Copyright (c) 2012 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
bool CefResourceBundleHandlerCToCpp::GetLocalizedString(int message_id,
CefString& string) {
if (CEF_MEMBER_MISSING(struct_, get_localized_string))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_localized_string(struct_,
message_id,
string.GetWritableStruct());
// Return type: bool
return _retval?true:false;
}
bool CefResourceBundleHandlerCToCpp::GetDataResource(int resource_id,
void*& data, size_t& data_size) {
if (CEF_MEMBER_MISSING(struct_, get_data_resource))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
int _retval = struct_->get_data_resource(struct_,
resource_id,
&data,
&data_size);
// Return type: bool
return _retval?true:false;
}
#ifndef NDEBUG
template<> long CefCToCpp<CefResourceBundleHandlerCToCpp,
CefResourceBundleHandler, cef_resource_bundle_handler_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,48 @@
// Copyright (c) 2012 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.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_RESOURCE_BUNDLE_HANDLER_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_RESOURCE_BUNDLE_HANDLER_CTOCPP_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_resource_bundle_handler.h"
#include "include/capi/cef_resource_bundle_handler_capi.h"
#include "include/cef_browser.h"
#include "include/capi/cef_browser_capi.h"
#include "include/cef_stream.h"
#include "include/capi/cef_stream_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed DLL-side only.
class CefResourceBundleHandlerCToCpp
: public CefCToCpp<CefResourceBundleHandlerCToCpp, CefResourceBundleHandler,
cef_resource_bundle_handler_t> {
public:
explicit CefResourceBundleHandlerCToCpp(cef_resource_bundle_handler_t* str)
: CefCToCpp<CefResourceBundleHandlerCToCpp, CefResourceBundleHandler,
cef_resource_bundle_handler_t>(str) {}
virtual ~CefResourceBundleHandlerCToCpp() {}
// CefResourceBundleHandler methods
virtual bool GetLocalizedString(int message_id, CefString& string) OVERRIDE;
virtual bool GetDataResource(int resource_id, void*& data,
size_t& data_size) OVERRIDE;
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_RESOURCE_BUNDLE_HANDLER_CTOCPP_H_

View File

@ -66,6 +66,7 @@
#include "libcef_dll/ctocpp/read_handler_ctocpp.h"
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
#include "libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h"
#include "libcef_dll/ctocpp/scheme_handler_ctocpp.h"
#include "libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h"
#include "libcef_dll/ctocpp/storage_visitor_ctocpp.h"
@ -140,6 +141,7 @@ CEF_EXPORT void cef_shutdown() {
DCHECK_EQ(CefRenderHandlerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefRequestCppToC::DebugObjCt, 0);
DCHECK_EQ(CefRequestHandlerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefResourceBundleHandlerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefResponseCppToC::DebugObjCt, 0);
DCHECK_EQ(CefSchemeHandlerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefSchemeHandlerCallbackCppToC::DebugObjCt, 0);

View File

@ -48,6 +48,7 @@
#include "libcef_dll/cpptoc/read_handler_cpptoc.h"
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
#include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h"
#include "libcef_dll/cpptoc/scheme_handler_cpptoc.h"
#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h"
#include "libcef_dll/cpptoc/storage_visitor_cpptoc.h"
@ -142,6 +143,7 @@ CEF_GLOBAL void CefShutdown() {
DCHECK_EQ(CefRenderHandlerCppToC::DebugObjCt, 0);
DCHECK_EQ(CefRequestCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefRequestHandlerCppToC::DebugObjCt, 0);
DCHECK_EQ(CefResourceBundleHandlerCppToC::DebugObjCt, 0);
DCHECK_EQ(CefResponseCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefSchemeHandlerCallbackCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefSchemeHandlerCppToC::DebugObjCt, 0);

View File

@ -209,6 +209,14 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<CefApp>& app) {
CefString(&settings.javascript_flags) =
g_command_line->GetSwitchValue(cefclient::kJavascriptFlags);
CefString(&settings.pack_file_path) =
g_command_line->GetSwitchValue(cefclient::kPackFilePath);
CefString(&settings.locales_dir_path) =
g_command_line->GetSwitchValue(cefclient::kLocalesDirPath);
settings.pack_loading_disabled =
g_command_line->HasSwitch(cefclient::kPackLoadingDisabled);
// Retrieve command-line proxy configuration, if any.
bool has_proxy = false;
cef_proxy_type_t proxy_type = PROXY_TYPE_DIRECT;

View File

@ -30,6 +30,9 @@ const char kGraphicsImpl_DesktopCmdBuffer[] = "desktop-command-buffer";
const char kLocalStorageQuota[] = "local-storage-quota";
const char kSessionStorageQuota[] = "session-storage-quota";
const char kJavascriptFlags[] = "javascript-flags";
const char kPackFilePath[] = "pack-file-path";
const char kLocalesDirPath[] = "locales-dir-path";
const char kPackLoadingDisabled[] = "pack-loading-disabled";
// CefBrowserSettings attributes.
const char kDragDropDisabled[] = "drag-drop-disabled";

View File

@ -32,6 +32,9 @@ extern const char kGraphicsImpl_DesktopCmdBuffer[];
extern const char kLocalStorageQuota[];
extern const char kSessionStorageQuota[];
extern const char kJavascriptFlags[];
extern const char kPackFilePath[];
extern const char kLocalesDirPath[];
extern const char kPackLoadingDisabled[];
// CefBrowserSettings attributes.
extern const char kDragDropDisabled[];

View File

@ -116,6 +116,14 @@ void CefTestSuite::GetSettings(CefSettings& settings) {
if (!other_javascript_flags.empty())
javascript_flags += " " + other_javascript_flags;
CefString(&settings.javascript_flags) = javascript_flags;
CefString(&settings.pack_file_path) =
commandline_->GetSwitchValueASCII(cefclient::kPackFilePath);
CefString(&settings.locales_dir_path) =
commandline_->GetSwitchValueASCII(cefclient::kLocalesDirPath);
settings.pack_loading_disabled =
commandline_->HasSwitch(cefclient::kPackLoadingDisabled);
}
// static

View File

@ -353,6 +353,28 @@ _cre_vfmod = '([A-Za-z0-9_]{0,})'
# regex for matching arbitrary whitespace
_cre_space = '[\s]{1,}'
# Simple translation types. Format is:
# 'cpp_type' : ['capi_type', 'capi_default_value']
_simpletypes = {
'void' : ['void', ''],
'void*' : ['void*', 'NULL'],
'int' : ['int', '0'],
'int64' : ['int64', '0'],
'uint64' : ['uint64', '0'],
'double' : ['double', '0'],
'long' : ['long', '0'],
'unsigned long' : ['unsigned long', '0'],
'long long' : ['long long', '0'],
'size_t' : ['size_t', '0'],
'time_t' : ['time_t', '0'],
'bool' : ['int', '0'],
'char* const': ['char* const', 'NULL'],
'CefCursorHandle' : ['cef_cursor_handle_t', 'NULL'],
'CefWindowHandle' : ['cef_window_handle_t', 'NULL'],
'CefRect' : ['cef_rect_t', 'CefRect()'],
'CefThreadId' : ['cef_thread_id_t', 'TID_UI'],
'CefTime' : ['cef_time_t', 'CefTime()'],
}
def get_function_impls(content, ident):
""" Retrieve the function parts from the specified contents as a set of
@ -1478,30 +1500,11 @@ class obj_analysis:
}
# check for simple direct translations
simpletypes = {
'void' : ['void', ''],
'int' : ['int', '0'],
'int64' : ['int64', '0'],
'uint64' : ['uint64', '0'],
'double' : ['double', '0'],
'long' : ['long', '0'],
'unsigned long' : ['unsigned long', '0'],
'long long' : ['long long', '0'],
'size_t' : ['size_t', '0'],
'time_t' : ['time_t', '0'],
'bool' : ['int', '0'],
'char* const': ['char* const', 'NULL'],
'CefCursorHandle' : ['cef_cursor_handle_t', 'NULL'],
'CefWindowHandle' : ['cef_window_handle_t', 'NULL'],
'CefRect' : ['cef_rect_t', 'CefRect()'],
'CefThreadId' : ['cef_thread_id_t', 'TID_UI'],
'CefTime' : ['cef_time_t', 'CefTime()'],
}
if value in simpletypes.keys():
if value in _simpletypes.keys():
return {
'result_type' : 'simple',
'result_value' : simpletypes[value][0],
'result_default' : simpletypes[value][1],
'result_value' : _simpletypes[value][0],
'result_default' : _simpletypes[value][1],
}
# check if already a C API structure