diff options
Diffstat (limited to 'content/shell')
-rw-r--r-- | content/shell/shell_content_browser_client.cc | 2 | ||||
-rw-r--r-- | content/shell/shell_messages.h | 8 | ||||
-rw-r--r-- | content/shell/shell_webpreferences.cc | 25 | ||||
-rw-r--r-- | content/shell/shell_webpreferences.h | 14 | ||||
-rw-r--r-- | content/shell/webkit_test_controller.cc | 5 | ||||
-rw-r--r-- | content/shell/webkit_test_controller.h | 9 | ||||
-rw-r--r-- | content/shell/webkit_test_runner.cc | 20 | ||||
-rw-r--r-- | content/shell/webkit_test_runner.h | 2 |
8 files changed, 44 insertions, 41 deletions
diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc index 6858810..21ea92a 100644 --- a/content/shell/shell_content_browser_client.cc +++ b/content/shell/shell_content_browser_client.cc @@ -91,7 +91,7 @@ void ShellContentBrowserClient::OverrideWebkitPrefs( webkit_glue::WebPreferences* prefs) { if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) return; - WebKitTestController::Get()->web_preferences().Apply(prefs); + WebKitTestController::Get()->web_preferences().Export(prefs); } void ShellContentBrowserClient::ResourceDispatcherHostCreated() { diff --git a/content/shell/shell_messages.h b/content/shell/shell_messages.h index b943eed..72114f0 100644 --- a/content/shell/shell_messages.h +++ b/content/shell/shell_messages.h @@ -14,10 +14,10 @@ #define IPC_MESSAGE_START ShellMsgStart IPC_STRUCT_TRAITS_BEGIN(content::ShellWebPreferences) - IPC_STRUCT_TRAITS_MEMBER(allow_universal_access_from_file_urls) - IPC_STRUCT_TRAITS_MEMBER(dom_paste_enabled) - IPC_STRUCT_TRAITS_MEMBER(javascript_can_access_clipboard) - IPC_STRUCT_TRAITS_MEMBER(xss_auditor_enabled) + IPC_STRUCT_TRAITS_MEMBER(allowUniversalAccessFromFileURLs) + IPC_STRUCT_TRAITS_MEMBER(DOMPasteAllowed) + IPC_STRUCT_TRAITS_MEMBER(javaScriptCanAccessClipboard) + IPC_STRUCT_TRAITS_MEMBER(XSSAuditorEnabled) IPC_STRUCT_TRAITS_END() // Sets the current working directory to use for layout tests. diff --git a/content/shell/shell_webpreferences.cc b/content/shell/shell_webpreferences.cc index 3418531..0df2a58 100644 --- a/content/shell/shell_webpreferences.cc +++ b/content/shell/shell_webpreferences.cc @@ -8,24 +8,15 @@ namespace content { -ShellWebPreferences::ShellWebPreferences() - : allow_universal_access_from_file_urls(true), - dom_paste_enabled(true), - javascript_can_access_clipboard(true), - xss_auditor_enabled(true) { -} - -ShellWebPreferences::~ShellWebPreferences() {} - -void ShellWebPreferences::Apply(webkit_glue::WebPreferences* prefs) const { +void ShellWebPreferences::Export(webkit_glue::WebPreferences* prefs) const { prefs->allow_universal_access_from_file_urls = - allow_universal_access_from_file_urls; - prefs->dom_paste_enabled = dom_paste_enabled; - prefs->javascript_can_access_clipboard = javascript_can_access_clipboard; - prefs->xss_auditor_enabled = xss_auditor_enabled; -#if !defined(OS_MACOSX) - prefs->editing_behavior = webkit_glue::WebPreferences::EDITING_BEHAVIOR_WIN; -#endif + allowUniversalAccessFromFileURLs; + prefs->dom_paste_enabled = DOMPasteAllowed; + prefs->javascript_can_access_clipboard = javaScriptCanAccessClipboard; + prefs->xss_auditor_enabled = XSSAuditorEnabled; + prefs->editing_behavior = + static_cast<webkit_glue::WebPreferences::EditingBehavior>( + editingBehavior); } } // namespace content diff --git a/content/shell/shell_webpreferences.h b/content/shell/shell_webpreferences.h index 96579d2..17db08b 100644 --- a/content/shell/shell_webpreferences.h +++ b/content/shell/shell_webpreferences.h @@ -5,22 +5,16 @@ #ifndef CONTENT_SHELL_SHELL_WEBPREFERENCES_H_ #define CONTENT_SHELL_SHELL_WEBPREFERENCES_H_ +#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebPreferences.h" + namespace webkit_glue { struct WebPreferences; } namespace content { -struct ShellWebPreferences { - bool allow_universal_access_from_file_urls; - bool dom_paste_enabled; - bool javascript_can_access_clipboard; - bool xss_auditor_enabled; - - ShellWebPreferences(); - ~ShellWebPreferences(); - - void Apply(webkit_glue::WebPreferences* prefs) const; +struct ShellWebPreferences : public WebTestRunner::WebPreferences { + void Export(webkit_glue::WebPreferences* prefs) const; }; } // namespace content diff --git a/content/shell/webkit_test_controller.cc b/content/shell/webkit_test_controller.cc index 1222c22..858e0d9 100644 --- a/content/shell/webkit_test_controller.cc +++ b/content/shell/webkit_test_controller.cc @@ -18,6 +18,7 @@ #include "content/shell/shell_content_browser_client.h" #include "content/shell/shell_messages.h" #include "content/shell/shell_switches.h" +#include "content/shell/shell_webpreferences.h" #include "webkit/fileapi/isolated_context.h" #include "webkit/support/webkit_support_gfx.h" @@ -186,7 +187,7 @@ bool WebKitTestController::ResetAfterLayoutTest() { is_printing_ = false; should_stay_on_page_after_handling_before_unload_ = false; wait_until_done_ = false; - prefs_ = ShellWebPreferences(); + prefs_.reset(new ShellWebPreferences); { base::AutoLock lock(lock_); can_open_windows_ = false; @@ -361,7 +362,7 @@ void WebKitTestController::OnPrintMessage(const std::string& message) { void WebKitTestController::OnOverridePreferences( const ShellWebPreferences& prefs) { - prefs_ = prefs; + *prefs_.get() = prefs; } void WebKitTestController::OnNotifyDone() { diff --git a/content/shell/webkit_test_controller.h b/content/shell/webkit_test_controller.h index bf974a7..54f77dd 100644 --- a/content/shell/webkit_test_controller.h +++ b/content/shell/webkit_test_controller.h @@ -10,17 +10,18 @@ #include "base/cancelable_callback.h" #include "base/file_path.h" +#include "base/memory/scoped_ptr.h" #include "base/synchronization/lock.h" #include "base/threading/non_thread_safe.h" #include "content/public/browser/render_view_host_observer.h" #include "content/public/browser/web_contents_observer.h" -#include "content/shell/shell_webpreferences.h" class SkBitmap; namespace content { class Shell; +struct ShellWebPreferences; class WebKitTestResultPrinter { public: @@ -86,7 +87,7 @@ class WebKitTestController : public base::NonThreadSafe, void set_printer(WebKitTestResultPrinter* printer) { printer_.reset(printer); } - const ShellWebPreferences& web_preferences() const { return prefs_; } + const ShellWebPreferences& web_preferences() const { return *prefs_.get(); } bool should_stay_on_page_after_handling_before_unload() const { return should_stay_on_page_after_handling_before_unload_; } @@ -145,7 +146,9 @@ class WebKitTestController : public base::NonThreadSafe, bool is_printing_; bool should_stay_on_page_after_handling_before_unload_; bool wait_until_done_; - ShellWebPreferences prefs_; + // TODO(jochen): Once we remove layout tests from content_browsertests, make + // this a member instead of a scoped_ptr. + scoped_ptr<ShellWebPreferences> prefs_; base::CancelableClosure watchdog_; diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc index 3fde49b..20a06c7 100644 --- a/content/shell/webkit_test_runner.cc +++ b/content/shell/webkit_test_runner.cc @@ -47,6 +47,7 @@ using WebKit::WebSize; using WebKit::WebString; using WebKit::WebVector; using WebKit::WebView; +using WebTestRunner::WebPreferences; using WebTestRunner::WebTask; namespace content { @@ -235,6 +236,17 @@ WebString WebKitTestRunner::getAbsoluteWebStringFromUTF8Path( return webkit_base::FilePathToWebString(path); } +WebPreferences* WebKitTestRunner::preferences() { + return &prefs_; +} + +void WebKitTestRunner::applyPreferences() { + webkit_glue::WebPreferences prefs = render_view()->GetWebkitPreferences(); + prefs_.Export(&prefs); + render_view()->SetWebkitPreferences(prefs); + Send(new ShellViewHostMsg_OverridePreferences(routing_id(), prefs_)); +} + // RenderViewObserver -------------------------------------------------------- void WebKitTestRunner::DidClearWindowObject(WebFrame* frame) { @@ -276,9 +288,9 @@ void WebKitTestRunner::Display() { } void WebKitTestRunner::SetXSSAuditorEnabled(bool enabled) { - prefs_.xss_auditor_enabled = enabled; + prefs_.XSSAuditorEnabled = enabled; webkit_glue::WebPreferences prefs = render_view()->GetWebkitPreferences(); - prefs_.Apply(&prefs); + prefs_.Export(&prefs); render_view()->SetWebkitPreferences(prefs); Send(new ShellViewHostMsg_OverridePreferences(routing_id(), prefs_)); } @@ -340,9 +352,9 @@ void WebKitTestRunner::NotImplemented(const std::string& object, } void WebKitTestRunner::Reset() { - prefs_ = ShellWebPreferences(); + prefs_.reset(); webkit_glue::WebPreferences prefs = render_view()->GetWebkitPreferences(); - prefs_.Apply(&prefs); + prefs_.Export(&prefs); render_view()->SetWebkitPreferences(prefs); } diff --git a/content/shell/webkit_test_runner.h b/content/shell/webkit_test_runner.h index 072afaa..b7e731c 100644 --- a/content/shell/webkit_test_runner.h +++ b/content/shell/webkit_test_runner.h @@ -57,6 +57,8 @@ class WebKitTestRunner : public RenderViewObserver, virtual long long getCurrentTimeInMillisecond(); virtual WebKit::WebString getAbsoluteWebStringFromUTF8Path( const std::string& utf8_path); + virtual WebTestRunner::WebPreferences* preferences(); + virtual void applyPreferences(); void Reset(); void Display(); |