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
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 allowed = enabledPerSettings && m_scriptsAllowed;
......@@ -64,6 +72,11 @@ void WebPermissions::setImagesAllowed(bool imagesAllowed)
m_imagesAllowed = imagesAllowed;
}
void WebPermissions::setMediaAllowed(bool mediaAllowed)
{
m_mediaAllowed = mediaAllowed;
}
void WebPermissions::setScriptsAllowed(bool scriptsAllowed)
{
m_scriptsAllowed = scriptsAllowed;
......@@ -103,6 +116,7 @@ void WebPermissions::reset()
{
m_dumpCallbacks = false;
m_imagesAllowed = true;
m_mediaAllowed = true;
m_scriptsAllowed = true;
m_storageAllowed = true;
m_pluginsAllowed = true;
......
......@@ -20,6 +20,7 @@ public:
// Override WebPermissionClient methods.
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 allowStorage(bool local);
virtual bool allowPlugins(bool enabledPerSettings);
......@@ -28,6 +29,7 @@ public:
// Hooks to set the different policies.
void setImagesAllowed(bool);
void setMediaAllowed(bool);
void setScriptsAllowed(bool);
void setStorageAllowed(bool);
void setPluginsAllowed(bool);
......@@ -45,6 +47,7 @@ private:
bool m_dumpCallbacks;
bool m_imagesAllowed;
bool m_mediaAllowed;
bool m_scriptsAllowed;
bool m_storageAllowed;
bool m_pluginsAllowed;
......
......@@ -211,6 +211,7 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
void DumpResourceRequestCallbacks();
void DumpResourceResponseMIMETypes();
void SetImagesAllowed(bool allowed);
void SetMediaAllowed(bool allowed);
void SetScriptsAllowed(bool allowed);
void SetStorageAllowed(bool allowed);
void SetPluginsAllowed(bool allowed);
......@@ -429,6 +430,7 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
.SetMethod("dumpResourceResponseMIMETypes",
&TestRunnerBindings::DumpResourceResponseMIMETypes)
.SetMethod("setImagesAllowed", &TestRunnerBindings::SetImagesAllowed)
.SetMethod("setMediaAllowed", &TestRunnerBindings::SetMediaAllowed)
.SetMethod("setScriptsAllowed", &TestRunnerBindings::SetScriptsAllowed)
.SetMethod("setStorageAllowed", &TestRunnerBindings::SetStorageAllowed)
.SetMethod("setPluginsAllowed", &TestRunnerBindings::SetPluginsAllowed)
......@@ -1063,6 +1065,11 @@ void TestRunnerBindings::SetImagesAllowed(bool allowed) {
runner_->SetImagesAllowed(allowed);
}
void TestRunnerBindings::SetMediaAllowed(bool allowed) {
if (runner_)
runner_->SetMediaAllowed(allowed);
}
void TestRunnerBindings::SetScriptsAllowed(bool allowed) {
if (runner_)
runner_->SetScriptsAllowed(allowed);
......@@ -2499,6 +2506,10 @@ void TestRunner::SetImagesAllowed(bool allowed) {
web_permissions_->setImagesAllowed(allowed);
}
void TestRunner::SetMediaAllowed(bool allowed) {
web_permissions_->setMediaAllowed(allowed);
}
void TestRunner::SetScriptsAllowed(bool allowed) {
web_permissions_->setScriptsAllowed(allowed);
}
......
......@@ -416,6 +416,7 @@ class TestRunner : public WebTestRunner,
// WebPermissionClient related.
void SetImagesAllowed(bool allowed);
void SetMediaAllowed(bool allowed);
void SetScriptsAllowed(bool allowed);
void SetStorageAllowed(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