diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-08 06:14:51 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-08 06:14:51 +0000 |
commit | f2d507199e85ca69b1449ef05cc2163f1340b3aa (patch) | |
tree | f86bb6ab3890434441d39d9312b253a607289964 /webkit | |
parent | 70f7efe52831ef7f900c33af139c33d9c95f7dc4 (diff) | |
download | chromium_src-f2d507199e85ca69b1449ef05cc2163f1340b3aa.zip chromium_src-f2d507199e85ca69b1449ef05cc2163f1340b3aa.tar.gz chromium_src-f2d507199e85ca69b1449ef05cc2163f1340b3aa.tar.bz2 |
Create a WebSettings interface that can be used for code outside of WebKit/WebCore to set WebCore::Page settings. Create an implementation that actually does the modifications. Alter glue/webview to create the instance lazily and alter the webPreference code to use it.
In the next CL, we'll pull the WebPreference code out of WebView completely, so this interface will be of more use.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/164087
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/api/public/WebSettings.h | 88 | ||||
-rw-r--r-- | webkit/api/src/WebSettingsImpl.cpp | 233 | ||||
-rw-r--r-- | webkit/api/src/WebSettingsImpl.h | 90 | ||||
-rw-r--r-- | webkit/glue/webview.h | 7 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 79 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 7 | ||||
-rw-r--r-- | webkit/webkit.gyp | 3 |
7 files changed, 458 insertions, 49 deletions
diff --git a/webkit/api/public/WebSettings.h b/webkit/api/public/WebSettings.h new file mode 100644 index 0000000..eaabf43 --- /dev/null +++ b/webkit/api/public/WebSettings.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2009 Google Inc. 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 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. + */ + +#ifndef WebSettings_h +#define WebSettings_h + +#include "WebCommon.h" + +namespace WebKit { + + class WebString; + class WebURL; + + // WebSettings is owned by the WebView and allows code to modify the settings for + // the WebView's page without any knowledge of WebCore itself. For the most part, + // these functions have a 1:1 mapping with the methods in WebCore/page/settings.h. + class WebSettings { + public: + virtual void setStandardFontFamily(const WebString&) = 0; + virtual void setFixedFontFamily(const WebString&) = 0; + virtual void setSerifFontFamily(const WebString&) = 0; + virtual void setSansSerifFontFamily(const WebString&) = 0; + virtual void setCursiveFontFamily(const WebString&) = 0; + virtual void setFantasyFontFamily(const WebString&) = 0; + virtual void setDefaultFontSize(int) = 0; + virtual void setDefaultFixedFontSize(int) = 0; + virtual void setMinimumFontSize(int) = 0; + virtual void setMinimumLogicalFontSize(int) = 0; + virtual void setDefaultTextEncodingName(const WebString&) = 0; + virtual void setJavaScriptEnabled(bool) = 0; + virtual void setWebSecurityEnabled(bool) = 0; + virtual void setJavaScriptCanOpenWindowsAutomatically(bool) = 0; + virtual void setLoadsImagesAutomatically(bool) = 0; + virtual void setPluginsEnabled(bool) = 0; + virtual void setDOMPasteAllowed(bool) = 0; + virtual void setDeveloperExtrasEnabled(bool) = 0; + virtual void setShrinksStandaloneImagesToFit(bool) = 0; + virtual void setUsesEncodingDetector(bool) = 0; + virtual void setTextAreasAreResizable(bool) = 0; + virtual void setJavaEnabled(bool) = 0; + virtual void setAllowScriptsToCloseWindows(bool) = 0; + virtual void setUserStyleSheetLocation(const WebURL&) = 0; + virtual void setUsesPageCache(bool) = 0; + virtual void setDownloadableBinaryFontsEnabled(bool) = 0; + virtual void setXSSAuditorEnabled(bool) = 0; + virtual void setLocalStorageEnabled(bool) = 0; + virtual void setSessionStorageEnabled(bool) = 0; + virtual void setEditableLinkBehaviorNeverLive() = 0; + virtual void setFontRenderingModeNormal() = 0; + virtual void setShouldPaintCustomScrollbars(bool) = 0; + virtual void setDatabasesEnabled(bool) = 0; + virtual void setAllowUniversalAccessFromFileURLs(bool) = 0; + virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded() = 0; + + protected: + virtual ~WebSettings() { } + }; + +} // namespace WebKit + +#endif diff --git a/webkit/api/src/WebSettingsImpl.cpp b/webkit/api/src/WebSettingsImpl.cpp new file mode 100644 index 0000000..b873aff --- /dev/null +++ b/webkit/api/src/WebSettingsImpl.cpp @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2009 Google Inc. 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 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. + */ + +#include "config.h" +#include "WebSettingsImpl.h" + +#include "FontRenderingMode.h" +#include "Settings.h" +#include "WebString.h" +#include "WebURL.h" + +using namespace WebCore; + +namespace WebKit { + +WebSettingsImpl::WebSettingsImpl(Settings* settings) + : m_settings(settings) +{ + ASSERT(settings); +} + +void WebSettingsImpl::setStandardFontFamily(const WebString& font) +{ + m_settings->setStandardFontFamily(font); +} + +void WebSettingsImpl::setFixedFontFamily(const WebString& font) +{ + m_settings->setFixedFontFamily((String)font); +} + +void WebSettingsImpl::setSerifFontFamily(const WebString& font) +{ + m_settings->setSerifFontFamily((String)font); +} + +void WebSettingsImpl::setSansSerifFontFamily(const WebString& font) +{ + m_settings->setSansSerifFontFamily((String)font); +} + +void WebSettingsImpl::setCursiveFontFamily(const WebString& font) +{ + m_settings->setCursiveFontFamily((String)font); +} + +void WebSettingsImpl::setFantasyFontFamily(const WebString& font) +{ + m_settings->setFantasyFontFamily((String)font); +} + +void WebSettingsImpl::setDefaultFontSize(int size) +{ + m_settings->setDefaultFontSize(size); +} + +void WebSettingsImpl::setDefaultFixedFontSize(int size) +{ + m_settings->setDefaultFixedFontSize(size); +} + +void WebSettingsImpl::setMinimumFontSize(int size) +{ + m_settings->setMinimumFontSize(size); +} + +void WebSettingsImpl::setMinimumLogicalFontSize(int size) +{ + m_settings->setMinimumLogicalFontSize(size); +} + +void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding) +{ + m_settings->setDefaultTextEncodingName((String)encoding); +} + +void WebSettingsImpl::setJavaScriptEnabled(bool enabled) +{ + m_settings->setJavaScriptEnabled(enabled); +} + +void WebSettingsImpl::setWebSecurityEnabled(bool enabled) +{ + m_settings->setWebSecurityEnabled(enabled); +} + +void WebSettingsImpl::setJavaScriptCanOpenWindowsAutomatically(bool canOpenWindows) +{ + m_settings->setJavaScriptCanOpenWindowsAutomatically(canOpenWindows); +} + +void WebSettingsImpl::setLoadsImagesAutomatically(bool loadsImagesAutomatically) +{ + m_settings->setLoadsImagesAutomatically(loadsImagesAutomatically); +} + +void WebSettingsImpl::setPluginsEnabled(bool enabled) +{ + m_settings->setPluginsEnabled(enabled); +} + +void WebSettingsImpl::setDOMPasteAllowed(bool enabled) +{ + m_settings->setDOMPasteAllowed(enabled); +} + +void WebSettingsImpl::setDeveloperExtrasEnabled(bool enabled) +{ + m_settings->setDeveloperExtrasEnabled(enabled); +} + +void WebSettingsImpl::setShrinksStandaloneImagesToFit(bool shrinkImages) +{ + m_settings->setShrinksStandaloneImagesToFit(shrinkImages); +} + +void WebSettingsImpl::setUsesEncodingDetector(bool usesDetector) +{ + m_settings->setUsesEncodingDetector(usesDetector); +} + +void WebSettingsImpl::setTextAreasAreResizable(bool areResizable) +{ + m_settings->setTextAreasAreResizable(areResizable); +} + +void WebSettingsImpl::setJavaEnabled(bool enabled) +{ + m_settings->setJavaEnabled(enabled); +} + +void WebSettingsImpl::setAllowScriptsToCloseWindows(bool allow) +{ + m_settings->setAllowScriptsToCloseWindows(allow); +} + +void WebSettingsImpl::setUserStyleSheetLocation(const WebURL& location) +{ + m_settings->setUserStyleSheetLocation(location); +} + +void WebSettingsImpl::setUsesPageCache(bool usesPageCache) +{ + m_settings->setUsesPageCache(usesPageCache); +} + +void WebSettingsImpl::setDownloadableBinaryFontsEnabled(bool enabled) +{ + m_settings->setDownloadableBinaryFontsEnabled(enabled); +} + +void WebSettingsImpl::setXSSAuditorEnabled(bool enabled) +{ + m_settings->setXSSAuditorEnabled(enabled); +} + +void WebSettingsImpl::setLocalStorageEnabled(bool enabled) +{ + m_settings->setLocalStorageEnabled(enabled); +} + +void WebSettingsImpl::setSessionStorageEnabled(bool enabled) +{ + m_settings->setSessionStorageEnabled(enabled); +} + +void WebSettingsImpl::setEditableLinkBehaviorNeverLive() +{ + // FIXME: If you ever need more behaviors than this, then we should probably + // define an enum in WebSettings.h and have a switch statement that + // translates. Until then, this is probably fine, though. + m_settings->setEditableLinkBehavior(WebCore::EditableLinkNeverLive); +} + +void WebSettingsImpl::setFontRenderingModeNormal() +{ + // FIXME: If you ever need more behaviors than this, then we should probably + // define an enum in WebSettings.h and have a switch statement that + // translates. Until then, this is probably fine, though. + m_settings->setFontRenderingMode(WebCore::NormalRenderingMode); +} + +void WebSettingsImpl::setShouldPaintCustomScrollbars(bool enabled) +{ + m_settings->setShouldPaintCustomScrollbars(enabled); +} + +void WebSettingsImpl::setDatabasesEnabled(bool enabled) +{ + m_settings->setDatabasesEnabled(enabled); +} + +void WebSettingsImpl::setAllowUniversalAccessFromFileURLs(bool allow) +{ + m_settings->setAllowUniversalAccessFromFileURLs(allow); +} + +void WebSettingsImpl::setTextDirectionSubmenuInclusionBehaviorNeverIncluded() +{ + // FIXME: If you ever need more behaviors than this, then we should probably + // define an enum in WebSettings.h and have a switch statement that + // translates. Until then, this is probably fine, though. + m_settings->setTextDirectionSubmenuInclusionBehavior(WebCore::TextDirectionSubmenuNeverIncluded); +} + +} // namespace WebKit diff --git a/webkit/api/src/WebSettingsImpl.h b/webkit/api/src/WebSettingsImpl.h new file mode 100644 index 0000000..79882d2 --- /dev/null +++ b/webkit/api/src/WebSettingsImpl.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2009 Google Inc. 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 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. + */ + +#ifndef WebSettingsImpl_h +#define WebSettingsImpl_h + +// TODO(jorlow): Remove this hack once WebView is free of glue. +#include "../public/WebSettings.h" + +namespace WebCore { +class Settings; +} + +namespace WebKit { + + class WebSettingsImpl : public WebSettings { + public: + explicit WebSettingsImpl(WebCore::Settings*); + virtual ~WebSettingsImpl() { } + + virtual void setStandardFontFamily(const WebString&); + virtual void setFixedFontFamily(const WebString&); + virtual void setSerifFontFamily(const WebString&); + virtual void setSansSerifFontFamily(const WebString&); + virtual void setCursiveFontFamily(const WebString&); + virtual void setFantasyFontFamily(const WebString&); + virtual void setDefaultFontSize(int); + virtual void setDefaultFixedFontSize(int); + virtual void setMinimumFontSize(int); + virtual void setMinimumLogicalFontSize(int); + virtual void setDefaultTextEncodingName(const WebString&); + virtual void setJavaScriptEnabled(bool); + virtual void setWebSecurityEnabled(bool); + virtual void setJavaScriptCanOpenWindowsAutomatically(bool); + virtual void setLoadsImagesAutomatically(bool); + virtual void setPluginsEnabled(bool); + virtual void setDOMPasteAllowed(bool); + virtual void setDeveloperExtrasEnabled(bool); + virtual void setShrinksStandaloneImagesToFit(bool); + virtual void setUsesEncodingDetector(bool); + virtual void setTextAreasAreResizable(bool); + virtual void setJavaEnabled(bool); + virtual void setAllowScriptsToCloseWindows(bool); + virtual void setUserStyleSheetLocation(const WebURL&); + virtual void setUsesPageCache(bool); + virtual void setDownloadableBinaryFontsEnabled(bool); + virtual void setXSSAuditorEnabled(bool); + virtual void setLocalStorageEnabled(bool); + virtual void setSessionStorageEnabled(bool); + virtual void setEditableLinkBehaviorNeverLive(); + virtual void setFontRenderingModeNormal(); + virtual void setShouldPaintCustomScrollbars(bool); + virtual void setDatabasesEnabled(bool); + virtual void setAllowUniversalAccessFromFileURLs(bool); + virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); + + private: + WebCore::Settings* m_settings; + }; + +} // namespace WebKit + +#endif diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h index 1ada9cf..08bec75 100644 --- a/webkit/glue/webview.h +++ b/webkit/glue/webview.h @@ -13,6 +13,7 @@ namespace WebKit { class WebDragData; +class WebSettings; struct WebPoint; } @@ -146,9 +147,15 @@ class WebView : public WebKit::WebWidget { virtual bool DownloadImage(int id, const GURL& image_url, int image_size) = 0; // Replace the standard setting for the WebView with |preferences|. + // TODO(jorlow): Remove in favor of the GetWebSettings() interface below. virtual void SetPreferences(const WebPreferences& preferences) = 0; virtual const WebPreferences& GetPreferences() = 0; + // Gets a WebSettings object that can be used to modify the behavior of this + // WebView. The object is deleted by this class on destruction, so you must + // not use it beyond WebView's lifetime. + virtual WebKit::WebSettings* GetSettings() = 0; + // Set the encoding of the current main frame. The value comes from // the encoding menu. WebKit uses the function named // SetCustomTextEncodingName to do override encoding job. diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 5a9b607..f18c6b97 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -1,34 +1,6 @@ -/* -* Copyright 2007 Google Inc. All Rights Reserved. -* -* Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. -* -* ***** BEGIN LICENSE BLOCK ***** -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. 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. -* -* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. -* -* ***** END LICENSE BLOCK ***** -* -*/ +// Copyright (c) 2007-2009 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 "config.h" #include "build/build_config.h" @@ -94,6 +66,8 @@ MSVC_POP_WARNING(); #include "webkit/api/public/WebPoint.h" #include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebString.h" +#include "webkit/api/public/WebURL.h" +#include "webkit/api/src/WebSettingsImpl.h" #include "webkit/glue/chrome_client_impl.h" #include "webkit/glue/context_menu_client_impl.h" #include "webkit/glue/dom_operations.h" @@ -132,12 +106,15 @@ using WebKit::WebMouseEvent; using WebKit::WebMouseWheelEvent; using WebKit::WebPoint; using WebKit::WebRect; +using WebKit::WebSettings; +using WebKit::WebSettingsImpl; using WebKit::WebSize; using WebKit::WebString; using WebKit::WebTextDirection; using WebKit::WebTextDirectionDefault; using WebKit::WebTextDirectionLeftToRight; using WebKit::WebTextDirectionRightToLeft; +using WebKit::WebURL; using webkit_glue::ImageResourceFetcher; @@ -1393,25 +1370,25 @@ void WebViewImpl::SetPreferences(const WebPreferences& preferences) { // Keep a local copy of the preferences struct for GetPreferences. webprefs_ = preferences; - Settings* settings = page_->settings(); + WebSettings* settings = GetSettings(); - settings->setStandardFontFamily(webkit_glue::StdWStringToString( + settings->setStandardFontFamily(WideToUTF16Hack( preferences.standard_font_family)); - settings->setFixedFontFamily(webkit_glue::StdWStringToString( + settings->setFixedFontFamily(WideToUTF16Hack( preferences.fixed_font_family)); - settings->setSerifFontFamily(webkit_glue::StdWStringToString( + settings->setSerifFontFamily(WideToUTF16Hack( preferences.serif_font_family)); - settings->setSansSerifFontFamily(webkit_glue::StdWStringToString( + settings->setSansSerifFontFamily(WideToUTF16Hack( preferences.sans_serif_font_family)); - settings->setCursiveFontFamily(webkit_glue::StdWStringToString( + settings->setCursiveFontFamily(WideToUTF16Hack( preferences.cursive_font_family)); - settings->setFantasyFontFamily(webkit_glue::StdWStringToString( + settings->setFantasyFontFamily(WideToUTF16Hack( preferences.fantasy_font_family)); settings->setDefaultFontSize(preferences.default_font_size); settings->setDefaultFixedFontSize(preferences.default_fixed_font_size); settings->setMinimumFontSize(preferences.minimum_font_size); settings->setMinimumLogicalFontSize(preferences.minimum_logical_font_size); - settings->setDefaultTextEncodingName(webkit_glue::StdWStringToString( + settings->setDefaultTextEncodingName(WideToUTF16Hack( preferences.default_encoding)); settings->setJavaScriptEnabled(preferences.javascript_enabled); settings->setWebSecurityEnabled(preferences.web_security_enabled); @@ -1428,12 +1405,10 @@ void WebViewImpl::SetPreferences(const WebPreferences& preferences) { settings->setTextAreasAreResizable(preferences.text_areas_are_resizable); settings->setAllowScriptsToCloseWindows( preferences.allow_scripts_to_close_windows); - if (preferences.user_style_sheet_enabled) { - settings->setUserStyleSheetLocation(webkit_glue::GURLToKURL( - preferences.user_style_sheet_location)); - } else { - settings->setUserStyleSheetLocation(KURL()); - } + if (preferences.user_style_sheet_enabled) + settings->setUserStyleSheetLocation(preferences.user_style_sheet_location); + else + settings->setUserStyleSheetLocation(WebURL()); settings->setUsesPageCache(preferences.uses_page_cache); settings->setDownloadableBinaryFontsEnabled(preferences.remote_fonts_enabled); settings->setXSSAuditorEnabled(preferences.xss_auditor_enabled); @@ -1444,9 +1419,9 @@ void WebViewImpl::SetPreferences(const WebPreferences& preferences) { // clicking the link should select it rather than navigate to it. // Safari uses the same default. It is unlikley an embedder would want to // change this, since it would break existing rich text editors. - settings->setEditableLinkBehavior(WebCore::EditableLinkNeverLive); + settings->setEditableLinkBehaviorNeverLive(); - settings->setFontRenderingMode(NormalRenderingMode); + settings->setFontRenderingModeNormal(); settings->setJavaEnabled(preferences.java_enabled); // Turn this on to cause WebCore to paint the resize corner for us. @@ -1463,8 +1438,7 @@ void WebViewImpl::SetPreferences(const WebPreferences& preferences) { // We prevent WebKit from checking if it needs to add a "text direction" // submenu to a context menu. it is not only because we don't need the result // but also because it cause a possible crash in Editor::hasBidiSelection(). - settings->setTextDirectionSubmenuInclusionBehavior( - TextDirectionSubmenuNeverIncluded); + settings->setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); #if defined(OS_WIN) // RenderTheme is a singleton that needs to know the default font size to @@ -1478,6 +1452,13 @@ const WebPreferences& WebViewImpl::GetPreferences() { return webprefs_; } +WebSettings* WebViewImpl::GetSettings() { + if (!web_settings_.get()) + web_settings_.reset(new WebSettingsImpl(page_->settings())); + DCHECK(web_settings_.get()); + return web_settings_.get(); +} + // Set the encoding of the current main frame to the one selected by // a user in the encoding menu. void WebViewImpl::SetPageEncoding(const std::wstring& encoding_name) { diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index 6dea768..5d6becb 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -38,6 +38,7 @@ namespace WebKit { class WebKeyboardEvent; class WebMouseEvent; class WebMouseWheelEvent; +class WebSettingsImpl; } class AutocompletePopupMenuClient; @@ -88,6 +89,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { virtual bool DownloadImage(int id, const GURL& image_url, int image_size); virtual void SetPreferences(const WebPreferences& preferences); virtual const WebPreferences& GetPreferences(); + virtual WebKit::WebSettings* GetSettings(); virtual void SetPageEncoding(const std::wstring& encoding_name); virtual std::wstring GetMainFrameEncodingName(); virtual void ZoomIn(bool text_only); @@ -257,6 +259,11 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { // A copy of the WebPreferences object we receive from the browser. WebPreferences webprefs_; + // An object that can be used to manipulate page_->settings() without linking + // against WebCore. This is lazily allocated the first time GetWebSettings() + // is called. + scoped_ptr<WebKit::WebSettingsImpl> web_settings_; + // A copy of the web drop data object we received from the browser. RefPtr<WebCore::ChromiumDataObject> current_drag_data_; diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 033acf8..2adc48d 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -1008,6 +1008,7 @@ 'api/public/WebRect.h', 'api/public/WebScreenInfo.h', 'api/public/WebScriptSource.h', + 'api/public/WebSettings.h', 'api/public/WebSize.h', 'api/public/WebStorageArea.h', 'api/public/WebStorageNamespace.h', @@ -1067,6 +1068,8 @@ 'api/src/WebNode.cpp', 'api/src/WebPluginListBuilderImpl.cpp', 'api/src/WebPluginListBuilderImpl.h', + 'api/src/WebSettingsImpl.cpp', + 'api/src/WebSettingsImpl.h', 'api/src/WebStorageAreaImpl.cpp', 'api/src/WebStorageAreaImpl.h', 'api/src/WebStorageNamespaceImpl.cpp', |