summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-17 23:00:59 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-17 23:00:59 +0000
commit2fab253a61e797b461b21671af7942521b749ee3 (patch)
tree6d61d2cbf0dd13956924fd7323a3c7506422dadd /webkit
parent5220e732b9c11a4309c6f5a45a27d4658087b1ed (diff)
downloadchromium_src-2fab253a61e797b461b21671af7942521b749ee3.zip
chromium_src-2fab253a61e797b461b21671af7942521b749ee3.tar.gz
chromium_src-2fab253a61e797b461b21671af7942521b749ee3.tar.bz2
Remove webview's dependency on webpreferences.
TEST=none BUG=none Review URL: http://codereview.chromium.org/165513 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/api/src/WebSettingsImpl.cpp9
-rw-r--r--webkit/glue/inspector_client_impl.cc2
-rw-r--r--webkit/glue/webpreferences.cc76
-rw-r--r--webkit/glue/webpreferences.h6
-rw-r--r--webkit/glue/webview.h24
-rw-r--r--webkit/glue/webview_impl.cc122
-rw-r--r--webkit/glue/webview_impl.h8
-rw-r--r--webkit/glue/webworker_impl.cc5
-rw-r--r--webkit/tools/test_shell/layout_test_controller.cc19
-rw-r--r--webkit/tools/test_shell/mac/webview_host.mm5
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc2
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm2
-rw-r--r--webkit/tools/test_shell/test_shell_win.cc2
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc15
-rw-r--r--webkit/tools/test_shell/webview_host_gtk.cc5
-rw-r--r--webkit/tools/test_shell/webview_host_win.cc5
-rw-r--r--webkit/webkit.gyp1
17 files changed, 160 insertions, 148 deletions
diff --git a/webkit/api/src/WebSettingsImpl.cpp b/webkit/api/src/WebSettingsImpl.cpp
index e66fb98..1edda49 100644
--- a/webkit/api/src/WebSettingsImpl.cpp
+++ b/webkit/api/src/WebSettingsImpl.cpp
@@ -36,6 +36,10 @@
#include "WebString.h"
#include "WebURL.h"
+#if defined(OS_WIN)
+#include "RenderThemeChromiumWin.h"
+#endif
+
using namespace WebCore;
namespace WebKit {
@@ -79,6 +83,11 @@ void WebSettingsImpl::setFantasyFontFamily(const WebString& font)
void WebSettingsImpl::setDefaultFontSize(int size)
{
m_settings->setDefaultFontSize(size);
+#if defined(OS_WIN)
+ // RenderTheme is a singleton that needs to know the default font size to
+ // draw some form controls. We let it know each time the size changes.
+ WebCore::RenderThemeChromiumWin::setDefaultFontSize(size);
+#endif
}
void WebSettingsImpl::setDefaultFixedFontSize(int size)
diff --git a/webkit/glue/inspector_client_impl.cc b/webkit/glue/inspector_client_impl.cc
index 377798a..3d3585e 100644
--- a/webkit/glue/inspector_client_impl.cc
+++ b/webkit/glue/inspector_client_impl.cc
@@ -223,7 +223,7 @@ void WebInspectorClient::LoadSettings() {
settings_.set(new SettingsMap);
String data = webkit_glue::StdWStringToString(
- inspected_web_view_->GetPreferences().inspector_settings);
+ inspected_web_view_->GetInspectorSettings());
if (data.isEmpty())
return;
diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc
new file mode 100644
index 0000000..86a8c7a
--- /dev/null
+++ b/webkit/glue/webpreferences.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 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 "webkit/glue/webpreferences.h"
+
+#include "base/string_util.h"
+#include "webkit/api/public/WebKit.h"
+#include "webkit/api/public/WebSettings.h"
+#include "webkit/api/public/WebString.h"
+#include "webkit/api/public/WebURL.h"
+#include "webkit/glue/webkit_glue.h"
+#include "webkit/glue/webview.h"
+
+using WebKit::WebSettings;
+using WebKit::WebURL;
+
+void WebPreferences::Apply(WebView* web_view) const {
+ WebSettings* settings = web_view->GetSettings();
+ settings->setStandardFontFamily(WideToUTF16Hack(standard_font_family));
+ settings->setFixedFontFamily(WideToUTF16Hack(fixed_font_family));
+ settings->setSerifFontFamily(WideToUTF16Hack(serif_font_family));
+ settings->setSansSerifFontFamily(WideToUTF16Hack(sans_serif_font_family));
+ settings->setCursiveFontFamily(WideToUTF16Hack(cursive_font_family));
+ settings->setFantasyFontFamily(WideToUTF16Hack(fantasy_font_family));
+ settings->setDefaultFontSize(default_font_size);
+ settings->setDefaultFixedFontSize(default_fixed_font_size);
+ settings->setMinimumFontSize(minimum_font_size);
+ settings->setMinimumLogicalFontSize(minimum_logical_font_size);
+ settings->setDefaultTextEncodingName(WideToUTF16Hack(default_encoding));
+ settings->setJavaScriptEnabled(javascript_enabled);
+ settings->setWebSecurityEnabled(web_security_enabled);
+ settings->setJavaScriptCanOpenWindowsAutomatically(
+ javascript_can_open_windows_automatically);
+ settings->setLoadsImagesAutomatically(loads_images_automatically);
+ settings->setPluginsEnabled(plugins_enabled);
+ settings->setDOMPasteAllowed(dom_paste_enabled);
+ settings->setDeveloperExtrasEnabled(developer_extras_enabled);
+ settings->setShrinksStandaloneImagesToFit(shrinks_standalone_images_to_fit);
+ settings->setUsesEncodingDetector(uses_universal_detector);
+ settings->setTextAreasAreResizable(text_areas_are_resizable);
+ settings->setAllowScriptsToCloseWindows(allow_scripts_to_close_windows);
+ if (user_style_sheet_enabled)
+ settings->setUserStyleSheetLocation(user_style_sheet_location);
+ else
+ settings->setUserStyleSheetLocation(WebURL());
+ settings->setUsesPageCache(uses_page_cache);
+ settings->setDownloadableBinaryFontsEnabled(remote_fonts_enabled);
+ settings->setXSSAuditorEnabled(xss_auditor_enabled);
+ settings->setLocalStorageEnabled(local_storage_enabled);
+ settings->setSessionStorageEnabled(session_storage_enabled);
+ settings->setOfflineWebApplicationCacheEnabled(application_cache_enabled);
+
+ // This setting affects the behavior of links in an editable region:
+ // 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->setEditableLinkBehaviorNeverLive();
+
+ settings->setFontRenderingModeNormal();
+ settings->setJavaEnabled(java_enabled);
+
+ // Turn this on to cause WebCore to paint the resize corner for us.
+ settings->setShouldPaintCustomScrollbars(true);
+
+ settings->setDatabasesEnabled(WebKit::databasesEnabled());
+
+ // Mitigate attacks from local HTML files by not granting file:// URLs
+ // universal access.
+ settings->setAllowUniversalAccessFromFileURLs(false);
+
+ // 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->setTextDirectionSubmenuInclusionBehaviorNeverIncluded();
+}
diff --git a/webkit/glue/webpreferences.h b/webkit/glue/webpreferences.h
index cf71900..c48339fa 100644
--- a/webkit/glue/webpreferences.h
+++ b/webkit/glue/webpreferences.h
@@ -5,7 +5,7 @@
// A struct for managing webkit's settings.
//
// Adding new values to this class probably involves updating
-// WebViewImpl::SetPreferences, common/render_messages.h, and
+// WebKit::WebSettings, common/render_messages.h, and
// browser/profile.cc.
#ifndef WEBKIT_GLUE_WEBPREFERENCES_H__
@@ -14,6 +14,8 @@
#include <string>
#include "googleurl/src/gurl.h"
+class WebView;
+
struct WebPreferences {
std::wstring standard_font_family;
std::wstring fixed_font_family;
@@ -87,6 +89,8 @@ struct WebPreferences {
application_cache_enabled(false),
user_style_sheet_enabled(false) {
}
+
+ void Apply(WebView* web_view) const;
};
#endif // WEBKIT_GLUE_WEBPREFERENCES_H__
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h
index c329452..4b9c098 100644
--- a/webkit/glue/webview.h
+++ b/webkit/glue/webview.h
@@ -19,7 +19,6 @@ struct WebPoint;
}
struct MediaPlayerAction;
-struct WebPreferences;
class GURL;
class WebDevToolsAgent;
class WebViewDelegate;
@@ -49,9 +48,13 @@ class WebView : public WebKit::WebWidget {
WebView() {}
virtual ~WebView() {}
- // This method creates a WebView that is initially sized to an empty rect.
- static WebView* Create(WebViewDelegate* delegate,
- const WebPreferences& prefs);
+ // This method creates a WebView that is NOT yet initialized. You will need
+ // to call InitializeMainFrame to finish the initialization.
+ static WebView* Create();
+
+ // After creating a WebView, you should immediately call this function.
+ // You can optionally modify the settings (via GetSettings()) in between.
+ virtual void InitializeMainFrame(WebViewDelegate* delegate) = 0;
// Tells all Page instances of this view to update the visited link state for
// the specified hash.
@@ -62,8 +65,8 @@ class WebView : public WebKit::WebWidget {
static void ResetVisitedLinkState();
// Returns the delegate for this WebView. This is the pointer that was
- // passed to WebView::Create. The caller must check this value before using
- // it, it will be NULL during closing of the view.
+ // passed to WebView::Initialize. The caller must check this value before
+ // using it, it will be NULL during closing of the view.
virtual WebViewDelegate* GetDelegate() = 0;
// Instructs the EditorClient whether to pass editing notifications on to a
@@ -143,16 +146,15 @@ class WebView : public WebKit::WebWidget {
// image doesn't have a frame at the specified size, the first is returned.
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;
+ // Settings used by inspector.
+ virtual const std::wstring& GetInspectorSettings() const = 0;
+ virtual void SetInspectorSettings(const std::wstring& settings) = 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 e94baac..aa19fcc 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -59,14 +59,11 @@ MSVC_POP_WARNING();
#include "base/keyboard_codes.h"
#include "base/logging.h"
#include "base/message_loop.h"
-#include "base/string_util.h"
#include "webkit/api/public/WebDragData.h"
#include "webkit/api/public/WebInputEvent.h"
-#include "webkit/api/public/WebKit.h"
#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/WebInputEventConversion.h"
#include "webkit/api/src/WebSettingsImpl.h"
#include "webkit/glue/chrome_client_impl.h"
@@ -80,10 +77,8 @@ MSVC_POP_WARNING();
#include "webkit/glue/inspector_client_impl.h"
#include "webkit/glue/searchable_form_data.h"
#include "webkit/glue/webdevtoolsagent_impl.h"
-#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webpopupmenu_impl.h"
-#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webdevtoolsagent.h"
#include "webkit/glue/webdevtoolsclient.h"
#include "webkit/glue/webview_delegate.h"
@@ -118,7 +113,6 @@ using WebKit::WebTextDirection;
using WebKit::WebTextDirectionDefault;
using WebKit::WebTextDirectionLeftToRight;
using WebKit::WebTextDirectionRightToLeft;
-using WebKit::WebURL;
using webkit_glue::ImageResourceFetcher;
@@ -319,33 +313,31 @@ static const WebCore::PopupContainerSettings kAutocompletePopupSettings = {
// WebView ----------------------------------------------------------------
/*static*/
-WebView* WebView::Create(WebViewDelegate* delegate,
- const WebPreferences& prefs) {
+WebView* WebView::Create() {
WebViewImpl* instance = new WebViewImpl();
instance->AddRef();
- instance->SetPreferences(prefs);
+ return instance;
+}
+void WebViewImpl::InitializeMainFrame(WebViewDelegate* delegate) {
// NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame
// and releases that reference once the corresponding Frame is destroyed.
scoped_refptr<WebFrameImpl> main_frame = new WebFrameImpl();
// Set the delegate before initializing the frame, so that notifications like
// DidCreateDataSource make their way to the client.
- instance->delegate_ = delegate;
- main_frame->InitMainFrame(instance);
+ delegate_ = delegate;
+ main_frame->InitMainFrame(this);
WebDevToolsAgentDelegate* tools_delegate =
delegate->GetWebDevToolsAgentDelegate();
- if (tools_delegate) {
- instance->devtools_agent_.reset(
- new WebDevToolsAgentImpl(instance, tools_delegate));
- }
+ if (tools_delegate)
+ devtools_agent_.reset(new WebDevToolsAgentImpl(this, tools_delegate));
// Restrict the access to the local file system
// (see WebView.mm WebView::_commonInitializationWithFrameName).
FrameLoader::setLocalLoadPolicy(
FrameLoader::AllowLocalLoadsForLocalOnly);
- return instance;
}
// static
@@ -1382,96 +1374,6 @@ bool WebViewImpl::DownloadImage(int id, const GURL& image_url,
return true;
}
-void WebViewImpl::SetPreferences(const WebPreferences& preferences) {
- if (!page_.get())
- return;
-
- // Keep a local copy of the preferences struct for GetPreferences.
- webprefs_ = preferences;
-
- WebSettings* settings = GetSettings();
-
- settings->setStandardFontFamily(WideToUTF16Hack(
- preferences.standard_font_family));
- settings->setFixedFontFamily(WideToUTF16Hack(
- preferences.fixed_font_family));
- settings->setSerifFontFamily(WideToUTF16Hack(
- preferences.serif_font_family));
- settings->setSansSerifFontFamily(WideToUTF16Hack(
- preferences.sans_serif_font_family));
- settings->setCursiveFontFamily(WideToUTF16Hack(
- preferences.cursive_font_family));
- 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(WideToUTF16Hack(
- preferences.default_encoding));
- settings->setJavaScriptEnabled(preferences.javascript_enabled);
- settings->setWebSecurityEnabled(preferences.web_security_enabled);
- settings->setJavaScriptCanOpenWindowsAutomatically(
- preferences.javascript_can_open_windows_automatically);
- settings->setLoadsImagesAutomatically(
- preferences.loads_images_automatically);
- settings->setPluginsEnabled(preferences.plugins_enabled);
- settings->setDOMPasteAllowed(preferences.dom_paste_enabled);
- settings->setDeveloperExtrasEnabled(preferences.developer_extras_enabled);
- settings->setShrinksStandaloneImagesToFit(
- preferences.shrinks_standalone_images_to_fit);
- settings->setUsesEncodingDetector(preferences.uses_universal_detector);
- settings->setTextAreasAreResizable(preferences.text_areas_are_resizable);
- settings->setAllowScriptsToCloseWindows(
- preferences.allow_scripts_to_close_windows);
- 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);
- settings->setLocalStorageEnabled(preferences.local_storage_enabled);
- settings->setSessionStorageEnabled(preferences.session_storage_enabled);
- settings->setOfflineWebApplicationCacheEnabled(preferences.application_cache_enabled);
-
- // This setting affects the behavior of links in an editable region:
- // 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->setEditableLinkBehaviorNeverLive();
-
- settings->setFontRenderingModeNormal();
- settings->setJavaEnabled(preferences.java_enabled);
-
- // Turn this on to cause WebCore to paint the resize corner for us.
- settings->setShouldPaintCustomScrollbars(true);
-
-#if ENABLE(DATABASE)
- settings->setDatabasesEnabled(WebKit::databasesEnabled());
-#endif
-
- // Mitigate attacks from local HTML files by not granting file:// URLs
- // universal access.
- settings->setAllowUniversalAccessFromFileURLs(false);
-
- // 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->setTextDirectionSubmenuInclusionBehaviorNeverIncluded();
-
-#if defined(OS_WIN)
- // RenderTheme is a singleton that needs to know the default font size to
- // draw some form controls. We let it know each time the size changes.
- WebCore::RenderThemeChromiumWin::setDefaultFontSize(
- preferences.default_font_size);
-#endif
-}
-
-const WebPreferences& WebViewImpl::GetPreferences() {
- return webprefs_;
-}
-
WebSettings* WebViewImpl::GetSettings() {
if (!web_settings_.get())
web_settings_.reset(new WebSettingsImpl(page_->settings()));
@@ -1479,6 +1381,14 @@ WebSettings* WebViewImpl::GetSettings() {
return web_settings_.get();
}
+const std::wstring& WebViewImpl::GetInspectorSettings() const {
+ return inspector_settings_;
+}
+
+void WebViewImpl::SetInspectorSettings(const std::wstring& settings) {
+ inspector_settings_ = settings;
+}
+
// 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 17b139b..91e05b9 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -73,6 +73,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
virtual void setTextDirection(WebKit::WebTextDirection direction);
// WebView methods:
+ virtual void InitializeMainFrame(WebViewDelegate* delegate);
virtual bool ShouldClose();
virtual void ClosePage();
virtual WebViewDelegate* GetDelegate();
@@ -89,9 +90,9 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
virtual void SetBackForwardListSize(int size);
virtual void SetInitialFocus(bool reverse);
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 const std::wstring& GetInspectorSettings() const;
+ virtual void SetInspectorSettings(const std::wstring& settings);
virtual void SetPageEncoding(const std::wstring& encoding_name);
virtual std::wstring GetMainFrameEncodingName();
virtual void ZoomIn(bool text_only);
@@ -362,6 +363,9 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
// Whether the webview is rendering transparently.
bool is_transparent_;
+ // Inspector settings.
+ std::wstring inspector_settings_;
+
// HACK: current_input_event is for ChromeClientImpl::show(), until we can fix
// WebKit to pass enough information up into ChromeClient::show() so we can
// decide if the window.open event was caused by a middle-mouse click
diff --git a/webkit/glue/webworker_impl.cc b/webkit/glue/webworker_impl.cc
index da8a273..3b33614 100644
--- a/webkit/glue/webworker_impl.cc
+++ b/webkit/glue/webworker_impl.cc
@@ -149,8 +149,9 @@ void WebWorkerImpl::startWorkerContext(const WebURL& script_url,
// loading requests from the worker context to the rest of WebKit and Chromium
// infrastructure.
DCHECK(!web_view_);
- web_view_ = WebView::Create(WorkerWebViewDelegate::worker_delegate(),
- WebPreferences());
+ web_view_ = WebView::Create();
+ WebPreferences().Apply(web_view_);
+ web_view_->InitializeMainFrame(WorkerWebViewDelegate::worker_delegate());
WebFrameImpl* web_frame =
static_cast<WebFrameImpl*>(web_view_->GetMainFrame());
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc
index 63e6c63..ffe1e3e 100644
--- a/webkit/tools/test_shell/layout_test_controller.cc
+++ b/webkit/tools/test_shell/layout_test_controller.cc
@@ -16,6 +16,7 @@
#include "base/string_util.h"
#include "webkit/api/public/WebFrame.h"
#include "webkit/api/public/WebScriptSource.h"
+#include "webkit/api/public/WebSettings.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webview.h"
@@ -556,10 +557,8 @@ void LayoutTestController::setPopupBlockingEnabled(
const CppArgumentList& args, CppVariant* result) {
if (args.size() > 0 && args[0].isBool()) {
bool block_popups = args[0].ToBoolean();
- WebPreferences* prefs = shell_->GetWebPreferences();
- prefs->javascript_can_open_windows_automatically = !block_popups;
-
- shell_->webView()->SetPreferences(*prefs);
+ shell_->webView()->GetSettings()->setJavaScriptCanOpenWindowsAutomatically(
+ !block_popups);
}
result->SetNull();
}
@@ -706,10 +705,7 @@ void LayoutTestController::numberOfActiveAnimations(const CppArgumentList& args,
void LayoutTestController::disableImageLoading(const CppArgumentList& args,
CppVariant* result) {
- WebPreferences* prefs = shell_->GetWebPreferences();
- prefs->loads_images_automatically = false;
- shell_->webView()->SetPreferences(*prefs);
-
+ shell_->webView()->GetSettings()->setLoadsImagesAutomatically(false);
result->SetNull();
}
@@ -793,9 +789,8 @@ void LayoutTestController::setPrivateBrowsingEnabled(
void LayoutTestController::setXSSAuditorEnabled(
const CppArgumentList& args, CppVariant* result) {
if (args.size() > 0 && args[0].isBool()) {
- WebPreferences* preferences = shell_->GetWebPreferences();
- preferences->xss_auditor_enabled = args[0].value.boolValue;
- shell_->webView()->SetPreferences(*preferences);
+ bool enabled = args[0].value.boolValue;
+ shell_->webView()->GetSettings()->setXSSAuditorEnabled(enabled);
}
result->SetNull();
}
@@ -911,7 +906,7 @@ void LayoutTestController::overridePreference(
shell_->delegate()->AddMessageToConsole(shell_->webView(),
message, 0, L"");
}
- shell_->webView()->SetPreferences(*preferences);
+ preferences->Apply(shell_->webView());
}
result->SetNull();
}
diff --git a/webkit/tools/test_shell/mac/webview_host.mm b/webkit/tools/test_shell/mac/webview_host.mm
index 960a55b..2acc00c 100644
--- a/webkit/tools/test_shell/mac/webview_host.mm
+++ b/webkit/tools/test_shell/mac/webview_host.mm
@@ -11,6 +11,7 @@
#include "base/gfx/size.h"
#include "skia/ext/platform_canvas.h"
#include "webkit/api/public/WebSize.h"
+#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webview.h"
using WebKit::WebSize;
@@ -33,7 +34,9 @@ WebViewHost* WebViewHost::Create(NSView* parent_view,
[parent_view addSubview:host->view_];
[host->view_ release];
- host->webwidget_ = WebView::Create(delegate, prefs);
+ host->webwidget_ = WebView::Create();
+ prefs.Apply(host->webview());
+ host->webview()->InitializeMainFrame(delegate);
host->webwidget_->resize(WebSize(content_rect.size.width,
content_rect.size.height));
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index cf35788..1f5931b 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -543,7 +543,7 @@ void TestShell::ResizeSubViews() {
// Clean up state between test runs.
webkit_glue::ResetBeforeTestRun(shell->webView());
ResetWebPreferences();
- shell->webView()->SetPreferences(*web_prefs_);
+ web_prefs_->Apply(shell->webView());
// TODO(agl): Maybe make the window hidden in the future. Window does this
// by positioning it off the screen but the GTK function to do this is
diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm
index e2a9139..dfd53f8 100644
--- a/webkit/tools/test_shell/test_shell_mac.mm
+++ b/webkit/tools/test_shell/test_shell_mac.mm
@@ -523,7 +523,7 @@ void TestShell::ResizeSubViews() {
// Clean up state between test runs.
webkit_glue::ResetBeforeTestRun(shell->webView());
ResetWebPreferences();
- shell->webView()->SetPreferences(*web_prefs_);
+ web_prefs_->Apply(shell->webView());
// Hide the window. We can't actually use NSWindow's |-setFrameTopLeftPoint:|
// because it leaves a chunk of the window visible instead of moving it
diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc
index 0a9e141..d07e17d 100644
--- a/webkit/tools/test_shell/test_shell_win.cc
+++ b/webkit/tools/test_shell/test_shell_win.cc
@@ -254,7 +254,7 @@ bool TestShell::RunFileTest(const TestParams& params) {
// Clean up state between test runs.
webkit_glue::ResetBeforeTestRun(shell->webView());
ResetWebPreferences();
- shell->webView()->SetPreferences(*web_prefs_);
+ web_prefs_->Apply(shell->webView());
SetWindowPos(shell->m_mainWnd, NULL,
kTestWindowXLocation, kTestWindowYLocation, 0, 0,
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index dbd199b..2836a5f 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -27,6 +27,7 @@
#include "webkit/api/public/WebFrame.h"
#include "webkit/api/public/WebKit.h"
#include "webkit/api/public/WebScreenInfo.h"
+#include "webkit/api/public/WebSettings.h"
#include "webkit/api/public/WebString.h"
#include "webkit/api/public/WebURL.h"
#include "webkit/api/public/WebURLError.h"
@@ -805,16 +806,16 @@ int TestWebViewDelegate::GetHistoryForwardListCount() {
}
void TestWebViewDelegate::SetUserStyleSheetEnabled(bool is_enabled) {
- WebPreferences* prefs = shell_->GetWebPreferences();
- prefs->user_style_sheet_enabled = is_enabled;
- shell_->webView()->SetPreferences(*prefs);
+ // Disabling/enabling this is really just setting it to an empty URL or
+ // setting it to something else. From this location in the code, there's
+ // no way to know what it's supposed to be. Luckily, right now, this is only
+ // used to disable the user style sheet.
+ DCHECK(!is_enabled);
+ shell_->webView()->GetSettings()->setUserStyleSheetLocation(WebURL());
}
void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) {
- WebPreferences* prefs = shell_->GetWebPreferences();
- prefs->user_style_sheet_enabled = true;
- prefs->user_style_sheet_location = location;
- shell_->webView()->SetPreferences(*prefs);
+ shell_->webView()->GetSettings()->setUserStyleSheetLocation(location);
}
// WebWidgetDelegate ---------------------------------------------------------
diff --git a/webkit/tools/test_shell/webview_host_gtk.cc b/webkit/tools/test_shell/webview_host_gtk.cc
index f9f030f..39a88ab 100644
--- a/webkit/tools/test_shell/webview_host_gtk.cc
+++ b/webkit/tools/test_shell/webview_host_gtk.cc
@@ -11,6 +11,7 @@
#include "base/gfx/size.h"
#include "skia/ext/platform_canvas.h"
#include "webkit/glue/plugins/gtk_plugin_container.h"
+#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webview.h"
// static
@@ -22,7 +23,9 @@ WebViewHost* WebViewHost::Create(GtkWidget* parent_view,
host->view_ = WebWidgetHost::CreateWidget(parent_view, host);
host->plugin_container_manager_.set_host_widget(host->view_);
- host->webwidget_ = WebView::Create(delegate, prefs);
+ host->webwidget_ = WebView::Create();
+ prefs.Apply(host->webview());
+ host->webview()->InitializeMainFrame(delegate);
host->webwidget_->layout();
return host;
diff --git a/webkit/tools/test_shell/webview_host_win.cc b/webkit/tools/test_shell/webview_host_win.cc
index d5c18ef..79b46b5 100644
--- a/webkit/tools/test_shell/webview_host_win.cc
+++ b/webkit/tools/test_shell/webview_host_win.cc
@@ -8,6 +8,7 @@
#include "base/gfx/size.h"
#include "base/win_util.h"
#include "skia/ext/platform_canvas.h"
+#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webview.h"
static const wchar_t kWindowClassName[] = L"WebViewHost";
@@ -37,7 +38,9 @@ WebViewHost* WebViewHost::Create(HWND parent_view,
GetModuleHandle(NULL), NULL);
win_util::SetWindowUserData(host->view_, host);
- host->webwidget_ = WebView::Create(delegate, prefs);
+ host->webwidget_ = WebView::Create();
+ prefs.Apply(host->webview());
+ host->webview()->InitializeMainFrame(delegate);
return host;
}
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index a4c7857..c54cc1a 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -1436,6 +1436,7 @@
'glue/webplugininfo.h',
'glue/webpopupmenu_impl.cc',
'glue/webpopupmenu_impl.h',
+ 'glue/webpreferences.cc',
'glue/webpreferences.h',
'glue/webthemeengine_impl_win.cc',
'glue/weburlloader_impl.cc',