mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Introduce CefString and cef_string_t implementations that support string type conversions and customization of the API string type (issue #146).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@145 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -3,44 +3,43 @@
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#include "../include/cef.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "webkit/glue/webpreferences.h"
|
||||
|
||||
void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
|
||||
{
|
||||
if (cef.standard_font_family)
|
||||
web.standard_font_family = cef.standard_font_family;
|
||||
void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
|
||||
{
|
||||
if (cef.standard_font_family.length > 0)
|
||||
web.standard_font_family = CefString(&cef.standard_font_family);
|
||||
else
|
||||
web.standard_font_family = L"Times";
|
||||
|
||||
if (cef.fixed_font_family)
|
||||
web.fixed_font_family = cef.fixed_font_family;
|
||||
if (cef.fixed_font_family.length > 0)
|
||||
web.fixed_font_family = CefString(&cef.fixed_font_family);
|
||||
else
|
||||
web.fixed_font_family = L"Courier";
|
||||
|
||||
if (cef.serif_font_family)
|
||||
web.serif_font_family = cef.serif_font_family;
|
||||
if (cef.serif_font_family.length > 0)
|
||||
web.serif_font_family = CefString(&cef.serif_font_family);
|
||||
else
|
||||
web.serif_font_family = L"Times";
|
||||
|
||||
if (cef.sans_serif_font_family)
|
||||
web.sans_serif_font_family = cef.sans_serif_font_family;
|
||||
if (cef.sans_serif_font_family.length > 0)
|
||||
web.sans_serif_font_family = CefString(&cef.sans_serif_font_family);
|
||||
else
|
||||
web.sans_serif_font_family = L"Helvetica";
|
||||
|
||||
// These two fonts below are picked from the intersection of
|
||||
// Win XP font list and Vista font list :
|
||||
// http://www.microsoft.com/typography/fonts/winxp.htm
|
||||
// http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx
|
||||
// Some of them are installed only with CJK and complex script
|
||||
// support enabled on Windows XP and are out of consideration here.
|
||||
// (although we enabled both on our buildbots.)
|
||||
// They (especially Impact for fantasy) are not typical cursive
|
||||
// and fantasy fonts, but it should not matter for layout tests
|
||||
// These two fonts below are picked from the intersection of
|
||||
// Win XP font list and Vista font list :
|
||||
// http://www.microsoft.com/typography/fonts/winxp.htm
|
||||
// http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx
|
||||
// Some of them are installed only with CJK and complex script
|
||||
// support enabled on Windows XP and are out of consideration here.
|
||||
// (although we enabled both on our buildbots.)
|
||||
// They (especially Impact for fantasy) are not typical cursive
|
||||
// and fantasy fonts, but it should not matter for layout tests
|
||||
// as long as they're available.
|
||||
|
||||
if (cef.cursive_font_family) {
|
||||
web.cursive_font_family = cef.cursive_font_family;
|
||||
if (cef.cursive_font_family.length > 0) {
|
||||
web.cursive_font_family = CefString(&cef.cursive_font_family);
|
||||
} else {
|
||||
#if defined(OS_MACOSX)
|
||||
web.cursive_font_family = L"Apple Chancery";
|
||||
@ -49,8 +48,8 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (cef.fantasy_font_family) {
|
||||
web.fantasy_font_family = cef.fantasy_font_family;
|
||||
if (cef.fantasy_font_family.length > 0) {
|
||||
web.fantasy_font_family = CefString(&cef.fantasy_font_family);
|
||||
} else {
|
||||
#if defined(OS_MACOSX)
|
||||
web.fantasy_font_family = L"Papyrus";
|
||||
@ -79,8 +78,8 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
|
||||
else
|
||||
web.minimum_logical_font_size = 9;
|
||||
|
||||
if (cef.default_encoding)
|
||||
web.default_encoding = WideToUTF8(cef.default_encoding);
|
||||
if (cef.default_encoding.length > 0)
|
||||
web.default_encoding = CefString(&cef.default_encoding);
|
||||
else
|
||||
web.default_encoding = "ISO-8859-1";
|
||||
|
||||
@ -113,9 +112,9 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
|
||||
|
||||
web.user_style_sheet_enabled = cef.user_style_sheet_enabled;
|
||||
|
||||
if (cef.user_style_sheet_location) {
|
||||
if (cef.user_style_sheet_location.length > 0) {
|
||||
web.user_style_sheet_location =
|
||||
GURL(WideToUTF8(cef.user_style_sheet_location));
|
||||
GURL(std::string(CefString(&cef.user_style_sheet_location)));
|
||||
}
|
||||
|
||||
web.author_and_user_styles_enabled = !cef.author_and_user_styles_disabled;
|
||||
@ -126,89 +125,5 @@ void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web)
|
||||
web.show_composited_layer_borders = false;
|
||||
web.accelerated_compositing_enabled = !cef.accelerated_compositing_disabled;
|
||||
web.accelerated_2d_canvas_enabled = !cef.accelerated_2d_canvas_disabled;
|
||||
web.memory_info_enabled = false;
|
||||
}
|
||||
|
||||
void WebToBrowserSettings(const WebPreferences& web, CefBrowserSettings& cef)
|
||||
{
|
||||
cef.Reset();
|
||||
|
||||
if (!web.standard_font_family.empty()) {
|
||||
cef.standard_font_family =
|
||||
cef_string_alloc(web.standard_font_family.c_str());
|
||||
}
|
||||
|
||||
if (!web.fixed_font_family.empty()) {
|
||||
cef.fixed_font_family =
|
||||
cef_string_alloc(web.fixed_font_family.c_str());
|
||||
}
|
||||
|
||||
if (!web.serif_font_family.empty()) {
|
||||
cef.serif_font_family =
|
||||
cef_string_alloc(web.serif_font_family.c_str());
|
||||
}
|
||||
|
||||
if (!web.cursive_font_family.empty()) {
|
||||
cef.cursive_font_family =
|
||||
cef_string_alloc(web.cursive_font_family.c_str());
|
||||
}
|
||||
|
||||
if (!web.fantasy_font_family.empty()) {
|
||||
cef.fantasy_font_family =
|
||||
cef_string_alloc(web.fantasy_font_family.c_str());
|
||||
}
|
||||
|
||||
cef.default_font_size = web.default_font_size;
|
||||
cef.default_fixed_font_size = web.default_fixed_font_size;
|
||||
cef.minimum_font_size = web.minimum_font_size;
|
||||
cef.minimum_logical_font_size = web.minimum_logical_font_size;
|
||||
cef.remote_fonts_disabled = !web.remote_fonts_enabled;
|
||||
|
||||
if (!web.default_encoding.empty()) {
|
||||
std::wstring wstr;
|
||||
UTF8ToWide(web.default_encoding.c_str(), web.default_encoding.length(),
|
||||
&wstr);
|
||||
cef.default_encoding = cef_string_alloc(wstr.c_str());
|
||||
}
|
||||
|
||||
cef.encoding_detector_enabled = web.uses_universal_detector;
|
||||
cef.javascript_disabled = !web.java_enabled;
|
||||
cef.javascript_open_windows_disallowed =
|
||||
!web.javascript_can_open_windows_automatically;
|
||||
cef.javascript_close_windows_disallowed =
|
||||
!web.allow_scripts_to_close_windows;
|
||||
cef.javascript_access_clipboard_disallowed =
|
||||
!web.javascript_can_access_clipboard;
|
||||
cef.dom_paste_disabled = !web.dom_paste_enabled;
|
||||
cef.caret_browsing_enabled = web.caret_browsing_enabled;
|
||||
cef.java_disabled = !web.java_enabled;
|
||||
cef.plugins_disabled = !web.plugins_enabled;
|
||||
cef.universal_access_from_file_urls_allowed =
|
||||
web.allow_universal_access_from_file_urls;
|
||||
cef.file_access_from_file_urls_allowed = web.allow_file_access_from_file_urls;
|
||||
cef.web_security_disabled = !web.web_security_enabled;
|
||||
cef.xss_auditor_enabled = web.xss_auditor_enabled;
|
||||
cef.image_load_disabled = !web.loads_images_automatically;
|
||||
cef.shrink_standalone_images_to_fit = web.shrinks_standalone_images_to_fit;
|
||||
cef.site_specific_quirks_disabled = !web.site_specific_quirks_enabled;
|
||||
cef.text_area_resize_disabled = !web.text_areas_are_resizable;
|
||||
cef.page_cache_disabled = !web.uses_page_cache;
|
||||
cef.tab_to_links_disabled = !web.tabs_to_links;
|
||||
cef.hyperlink_auditing_disabled = !web.hyperlink_auditing_enabled;
|
||||
cef.user_style_sheet_enabled = web.user_style_sheet_enabled;
|
||||
|
||||
if (!web.user_style_sheet_location.is_empty()) {
|
||||
std::string str = web.user_style_sheet_location.spec();
|
||||
std::wstring wstr;
|
||||
UTF8ToWide(str.c_str(), str.length(), &wstr);
|
||||
cef.user_style_sheet_location = cef_string_alloc(wstr.c_str());
|
||||
}
|
||||
|
||||
cef.author_and_user_styles_disabled = !web.author_and_user_styles_enabled;
|
||||
cef.local_storage_disabled = !web.local_storage_enabled;
|
||||
cef.databases_disabled = !web.databases_enabled;
|
||||
cef.application_cache_disabled = !web.application_cache_enabled;
|
||||
cef.experimental_webgl_enabled = web.experimental_webgl_enabled;
|
||||
cef.accelerated_compositing_disabled = !web.accelerated_compositing_enabled;
|
||||
cef.accelerated_2d_canvas_disabled = !web.accelerated_2d_canvas_enabled;
|
||||
}
|
||||
web.memory_info_enabled = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user