Commit e19024b9 authored by costan@gmail.com's avatar costan@gmail.com

Content Shell test_runner hooks for <audio> and <video> blocking.

These hooks are necessary for the LayoutTests in the blink-side CL
referenced below, which adds the ability to block <audio> and <video>
media. The blocking works similarly to the currently implemented ability
to block images.

https://codereview.chromium.org/27694002/

BUG=50132
TEST=LayoutTests in the blink CL pass with this CL patched in

Review URL: https://codereview.chromium.org/312103004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275984 0039d316-1c4b-4281-b951-d872f2087c98
parent 3034d901
...@@ -31,6 +31,14 @@ bool WebPermissions::allowImage(bool enabledPerSettings, const blink::WebURL& im ...@@ -31,6 +31,14 @@ bool WebPermissions::allowImage(bool enabledPerSettings, const blink::WebURL& im
return allowed; return allowed;
} }
bool WebPermissions::allowMedia(const blink::WebURL& imageURL)
{
bool allowed = m_mediaAllowed;
if (m_dumpCallbacks && m_delegate)
m_delegate->printMessage(std::string("PERMISSION CLIENT: allowMedia(") + normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
return allowed;
}
bool WebPermissions::allowScriptFromSource(bool enabledPerSettings, const blink::WebURL& scriptURL) bool WebPermissions::allowScriptFromSource(bool enabledPerSettings, const blink::WebURL& scriptURL)
{ {
bool allowed = enabledPerSettings && m_scriptsAllowed; bool allowed = enabledPerSettings && m_scriptsAllowed;
...@@ -64,6 +72,11 @@ void WebPermissions::setImagesAllowed(bool imagesAllowed) ...@@ -64,6 +72,11 @@ void WebPermissions::setImagesAllowed(bool imagesAllowed)
m_imagesAllowed = imagesAllowed; m_imagesAllowed = imagesAllowed;
} }
void WebPermissions::setMediaAllowed(bool mediaAllowed)
{
m_mediaAllowed = mediaAllowed;
}
void WebPermissions::setScriptsAllowed(bool scriptsAllowed) void WebPermissions::setScriptsAllowed(bool scriptsAllowed)
{ {
m_scriptsAllowed = scriptsAllowed; m_scriptsAllowed = scriptsAllowed;
...@@ -103,6 +116,7 @@ void WebPermissions::reset() ...@@ -103,6 +116,7 @@ void WebPermissions::reset()
{ {
m_dumpCallbacks = false; m_dumpCallbacks = false;
m_imagesAllowed = true; m_imagesAllowed = true;
m_mediaAllowed = true;
m_scriptsAllowed = true; m_scriptsAllowed = true;
m_storageAllowed = true; m_storageAllowed = true;
m_pluginsAllowed = true; m_pluginsAllowed = true;
......
...@@ -20,6 +20,7 @@ public: ...@@ -20,6 +20,7 @@ public:
// Override WebPermissionClient methods. // Override WebPermissionClient methods.
virtual bool allowImage(bool enabledPerSettings, const blink::WebURL& imageURL); virtual bool allowImage(bool enabledPerSettings, const blink::WebURL& imageURL);
virtual bool allowMedia(const blink::WebURL& mediaURL);
virtual bool allowScriptFromSource(bool enabledPerSettings, const blink::WebURL& scriptURL); virtual bool allowScriptFromSource(bool enabledPerSettings, const blink::WebURL& scriptURL);
virtual bool allowStorage(bool local); virtual bool allowStorage(bool local);
virtual bool allowPlugins(bool enabledPerSettings); virtual bool allowPlugins(bool enabledPerSettings);
...@@ -28,6 +29,7 @@ public: ...@@ -28,6 +29,7 @@ public:
// Hooks to set the different policies. // Hooks to set the different policies.
void setImagesAllowed(bool); void setImagesAllowed(bool);
void setMediaAllowed(bool);
void setScriptsAllowed(bool); void setScriptsAllowed(bool);
void setStorageAllowed(bool); void setStorageAllowed(bool);
void setPluginsAllowed(bool); void setPluginsAllowed(bool);
...@@ -45,6 +47,7 @@ private: ...@@ -45,6 +47,7 @@ private:
bool m_dumpCallbacks; bool m_dumpCallbacks;
bool m_imagesAllowed; bool m_imagesAllowed;
bool m_mediaAllowed;
bool m_scriptsAllowed; bool m_scriptsAllowed;
bool m_storageAllowed; bool m_storageAllowed;
bool m_pluginsAllowed; bool m_pluginsAllowed;
......
...@@ -211,6 +211,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> { ...@@ -211,6 +211,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
void DumpResourceRequestCallbacks(); void DumpResourceRequestCallbacks();
void DumpResourceResponseMIMETypes(); void DumpResourceResponseMIMETypes();
void SetImagesAllowed(bool allowed); void SetImagesAllowed(bool allowed);
void SetMediaAllowed(bool allowed);
void SetScriptsAllowed(bool allowed); void SetScriptsAllowed(bool allowed);
void SetStorageAllowed(bool allowed); void SetStorageAllowed(bool allowed);
void SetPluginsAllowed(bool allowed); void SetPluginsAllowed(bool allowed);
...@@ -429,6 +430,7 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder( ...@@ -429,6 +430,7 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
.SetMethod("dumpResourceResponseMIMETypes", .SetMethod("dumpResourceResponseMIMETypes",
&TestRunnerBindings::DumpResourceResponseMIMETypes) &TestRunnerBindings::DumpResourceResponseMIMETypes)
.SetMethod("setImagesAllowed", &TestRunnerBindings::SetImagesAllowed) .SetMethod("setImagesAllowed", &TestRunnerBindings::SetImagesAllowed)
.SetMethod("setMediaAllowed", &TestRunnerBindings::SetMediaAllowed)
.SetMethod("setScriptsAllowed", &TestRunnerBindings::SetScriptsAllowed) .SetMethod("setScriptsAllowed", &TestRunnerBindings::SetScriptsAllowed)
.SetMethod("setStorageAllowed", &TestRunnerBindings::SetStorageAllowed) .SetMethod("setStorageAllowed", &TestRunnerBindings::SetStorageAllowed)
.SetMethod("setPluginsAllowed", &TestRunnerBindings::SetPluginsAllowed) .SetMethod("setPluginsAllowed", &TestRunnerBindings::SetPluginsAllowed)
...@@ -1063,6 +1065,11 @@ void TestRunnerBindings::SetImagesAllowed(bool allowed) { ...@@ -1063,6 +1065,11 @@ void TestRunnerBindings::SetImagesAllowed(bool allowed) {
runner_->SetImagesAllowed(allowed); runner_->SetImagesAllowed(allowed);
} }
void TestRunnerBindings::SetMediaAllowed(bool allowed) {
if (runner_)
runner_->SetMediaAllowed(allowed);
}
void TestRunnerBindings::SetScriptsAllowed(bool allowed) { void TestRunnerBindings::SetScriptsAllowed(bool allowed) {
if (runner_) if (runner_)
runner_->SetScriptsAllowed(allowed); runner_->SetScriptsAllowed(allowed);
...@@ -2499,6 +2506,10 @@ void TestRunner::SetImagesAllowed(bool allowed) { ...@@ -2499,6 +2506,10 @@ void TestRunner::SetImagesAllowed(bool allowed) {
web_permissions_->setImagesAllowed(allowed); web_permissions_->setImagesAllowed(allowed);
} }
void TestRunner::SetMediaAllowed(bool allowed) {
web_permissions_->setMediaAllowed(allowed);
}
void TestRunner::SetScriptsAllowed(bool allowed) { void TestRunner::SetScriptsAllowed(bool allowed) {
web_permissions_->setScriptsAllowed(allowed); web_permissions_->setScriptsAllowed(allowed);
} }
......
...@@ -416,6 +416,7 @@ class TestRunner : public WebTestRunner, ...@@ -416,6 +416,7 @@ class TestRunner : public WebTestRunner,
// WebPermissionClient related. // WebPermissionClient related.
void SetImagesAllowed(bool allowed); void SetImagesAllowed(bool allowed);
void SetMediaAllowed(bool allowed);
void SetScriptsAllowed(bool allowed); void SetScriptsAllowed(bool allowed);
void SetStorageAllowed(bool allowed); void SetStorageAllowed(bool allowed);
void SetPluginsAllowed(bool allowed); void SetPluginsAllowed(bool allowed);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment