summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-19 21:21:20 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-19 21:21:20 +0000
commit6b32470ecee792ab2baf7f2fbb84acdec2afb49c (patch)
treefe4259ab0a37e23759dbebb6ff04e02cdaf0e7e1
parent1fd456988642f12f398b05b1bcf05d59ecd86c56 (diff)
downloadchromium_src-6b32470ecee792ab2baf7f2fbb84acdec2afb49c.zip
chromium_src-6b32470ecee792ab2baf7f2fbb84acdec2afb49c.tar.gz
chromium_src-6b32470ecee792ab2baf7f2fbb84acdec2afb49c.tar.bz2
Implement two missing methods on layoutTestController:
- addUserStyleSheet - setAuthorAndUserStylesEnabled BUG=24197 BUG=21113 Review URL: http://codereview.chromium.org/1654007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44954 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/render_messages.h2
-rw-r--r--webkit/glue/webpreferences.cc1
-rw-r--r--webkit/glue/webpreferences.h2
-rw-r--r--webkit/tools/test_shell/layout_test_controller.cc21
-rw-r--r--webkit/tools/test_shell/layout_test_controller.h6
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc6
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h1
7 files changed, 37 insertions, 2 deletions
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index cff7401..aa0ad3c 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -1752,6 +1752,7 @@ struct ParamTraits<WebPreferences> {
WriteParam(m, p.tabs_to_links);
WriteParam(m, p.user_style_sheet_enabled);
WriteParam(m, p.user_style_sheet_location);
+ WriteParam(m, p.author_and_user_styles_enabled);
WriteParam(m, p.allow_universal_access_from_file_urls);
WriteParam(m, p.allow_file_access_from_file_urls);
WriteParam(m, p.experimental_webgl_enabled);
@@ -1793,6 +1794,7 @@ struct ParamTraits<WebPreferences> {
ReadParam(m, iter, &p->tabs_to_links) &&
ReadParam(m, iter, &p->user_style_sheet_enabled) &&
ReadParam(m, iter, &p->user_style_sheet_location) &&
+ ReadParam(m, iter, &p->author_and_user_styles_enabled) &&
ReadParam(m, iter, &p->allow_universal_access_from_file_urls) &&
ReadParam(m, iter, &p->allow_file_access_from_file_urls) &&
ReadParam(m, iter, &p->experimental_webgl_enabled) &&
diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc
index d6dbf63..f33375e 100644
--- a/webkit/glue/webpreferences.cc
+++ b/webkit/glue/webpreferences.cc
@@ -50,6 +50,7 @@ void WebPreferences::Apply(WebView* web_view) const {
settings->setUserStyleSheetLocation(user_style_sheet_location);
else
settings->setUserStyleSheetLocation(WebURL());
+ settings->setAuthorAndUserStylesEnabled(author_and_user_styles_enabled);
settings->setUsesPageCache(uses_page_cache);
settings->setDownloadableBinaryFontsEnabled(remote_fonts_enabled);
settings->setXSSAuditorEnabled(xss_auditor_enabled);
diff --git a/webkit/glue/webpreferences.h b/webkit/glue/webpreferences.h
index 0a2a544..650bb5e 100644
--- a/webkit/glue/webpreferences.h
+++ b/webkit/glue/webpreferences.h
@@ -54,6 +54,7 @@ struct WebPreferences {
bool user_style_sheet_enabled;
GURL user_style_sheet_location;
+ bool author_and_user_styles_enabled;
bool allow_universal_access_from_file_urls;
bool allow_file_access_from_file_urls;
bool experimental_webgl_enabled;
@@ -95,6 +96,7 @@ struct WebPreferences {
application_cache_enabled(false),
tabs_to_links(true),
user_style_sheet_enabled(false),
+ author_and_user_styles_enabled(true),
allow_universal_access_from_file_urls(false),
allow_file_access_from_file_urls(false),
experimental_webgl_enabled(false),
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc
index 08eb371..7643217 100644
--- a/webkit/tools/test_shell/layout_test_controller.cc
+++ b/webkit/tools/test_shell/layout_test_controller.cc
@@ -107,6 +107,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) :
BindMethod("setTabKeyCyclesThroughElements", &LayoutTestController::setTabKeyCyclesThroughElements);
BindMethod("setUserStyleSheetLocation", &LayoutTestController::setUserStyleSheetLocation);
BindMethod("setUserStyleSheetEnabled", &LayoutTestController::setUserStyleSheetEnabled);
+ BindMethod("setAuthorAndUserStylesEnabled", &LayoutTestController::setAuthorAndUserStylesEnabled);
BindMethod("pathToLocalResource", &LayoutTestController::pathToLocalResource);
BindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag);
BindMethod("execCommand", &LayoutTestController::execCommand);
@@ -133,6 +134,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) :
BindMethod("setPOSIXLocale", &LayoutTestController::setPOSIXLocale);
BindMethod("counterValueForElementById", &LayoutTestController::counterValueForElementById);
BindMethod("addUserScript", &LayoutTestController::addUserScript);
+ BindMethod("addUserStyleSheet", &LayoutTestController::addUserStyleSheet);
BindMethod("pageNumberForElementById", &LayoutTestController::pageNumberForElementById);
BindMethod("numberOfPages", &LayoutTestController::numberOfPages);
BindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect);
@@ -599,6 +601,15 @@ void LayoutTestController::setUserStyleSheetLocation(
result->SetNull();
}
+void LayoutTestController::setAuthorAndUserStylesEnabled(
+ const CppArgumentList& args, CppVariant* result) {
+ if (args.size() > 0 && args[0].isBool()) {
+ shell_->delegate()->SetAuthorAndUserStylesEnabled(args[0].value.boolValue);
+ }
+
+ result->SetNull();
+}
+
void LayoutTestController::execCommand(
const CppArgumentList& args, CppVariant* result) {
if (args.size() > 0 && args[0].isString()) {
@@ -1226,8 +1237,16 @@ void LayoutTestController::forceRedSelectionColors(const CppArgumentList& args,
void LayoutTestController::addUserScript(const CppArgumentList& args,
CppVariant* result) {
result->SetNull();
- if (args.size() < 1 || !args[0].isString() || !args[1].isBool())
+ if (args.size() < 2 || !args[0].isString() || !args[1].isBool())
return;
shell_->webView()->addUserScript(WebString::fromUTF8(args[0].ToString()),
args[1].ToBoolean());
}
+
+void LayoutTestController::addUserStyleSheet(const CppArgumentList& args,
+ CppVariant* result) {
+ result->SetNull();
+ if (args.size() < 1 || !args[0].isString())
+ return;
+ shell_->webView()->addUserStyleSheet(WebString::fromUTF8(args[0].ToString()));
+}
diff --git a/webkit/tools/test_shell/layout_test_controller.h b/webkit/tools/test_shell/layout_test_controller.h
index e6c4fd7..3a29544 100644
--- a/webkit/tools/test_shell/layout_test_controller.h
+++ b/webkit/tools/test_shell/layout_test_controller.h
@@ -114,6 +114,9 @@ class LayoutTestController : public CppBoundClass {
void setUserStyleSheetEnabled(const CppArgumentList& args, CppVariant* result);
void setUserStyleSheetLocation(const CppArgumentList& args, CppVariant* result);
+ // Passes this preference through to WebPreferences.
+ void setAuthorAndUserStylesEnabled(const CppArgumentList& args, CppVariant* result);
+
// Puts Webkit in "dashboard compatibility mode", which is used in obscure
// Mac-only circumstances. It's not really necessary, and will most likely
// never be used by Chrome, but some layout tests depend on its presence.
@@ -257,8 +260,9 @@ class LayoutTestController : public CppBoundClass {
void forceRedSelectionColors(const CppArgumentList& args,
CppVariant* result);
- // Adds a user script to be injected into new documents.
+ // Adds a user script or user style sheet to be injected into new documents.
void addUserScript(const CppArgumentList& args, CppVariant* result);
+ void addUserStyleSheet(const CppArgumentList& args, CppVariant* result);
public:
// The following methods are not exposed to JavaScript.
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index 7130779..3b52c75 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -301,6 +301,12 @@ void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) {
prefs->Apply(shell_->webView());
}
+void TestWebViewDelegate::SetAuthorAndUserStylesEnabled(bool is_enabled) {
+ WebPreferences* prefs = shell_->GetWebPreferences();
+ prefs->author_and_user_styles_enabled = is_enabled;
+ prefs->Apply(shell_->webView());
+}
+
// WebViewClient -------------------------------------------------------------
WebView* TestWebViewDelegate::createView(WebFrame* creator) {
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index 3d86b02..34b3ee6 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -261,6 +261,7 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
// Methods for modifying WebPreferences
void SetUserStyleSheetEnabled(bool is_enabled);
void SetUserStyleSheetLocation(const GURL& location);
+ void SetAuthorAndUserStylesEnabled(bool is_enabled);
// Sets the webview as a drop target.
void RegisterDragDrop();