1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/shell/renderer/test_runner/WebPermissions.h"
7 #include "content/shell/renderer/test_runner/TestCommon.h"
8 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
9 #include "third_party/WebKit/public/platform/WebCString.h"
10 #include "third_party/WebKit/public/platform/WebURL.h"
12 using namespace WebTestRunner
;
17 WebPermissions::WebPermissions()
23 WebPermissions::~WebPermissions()
27 bool WebPermissions::allowImage(bool enabledPerSettings
, const blink::WebURL
& imageURL
)
29 bool allowed
= enabledPerSettings
&& m_imagesAllowed
;
30 if (m_dumpCallbacks
&& m_delegate
)
31 m_delegate
->printMessage(std::string("PERMISSION CLIENT: allowImage(") + normalizeLayoutTestURL(imageURL
.spec()) + "): " + (allowed
? "true" : "false") + "\n");
35 bool WebPermissions::allowScriptFromSource(bool enabledPerSettings
, const blink::WebURL
& scriptURL
)
37 bool allowed
= enabledPerSettings
&& m_scriptsAllowed
;
38 if (m_dumpCallbacks
&& m_delegate
)
39 m_delegate
->printMessage(std::string("PERMISSION CLIENT: allowScriptFromSource(") + normalizeLayoutTestURL(scriptURL
.spec()) + "): " + (allowed
? "true" : "false") + "\n");
43 bool WebPermissions::allowStorage(bool)
45 return m_storageAllowed
;
48 bool WebPermissions::allowPlugins(bool enabledPerSettings
)
50 return enabledPerSettings
&& m_pluginsAllowed
;
53 bool WebPermissions::allowDisplayingInsecureContent(bool enabledPerSettings
, const blink::WebSecurityOrigin
&, const blink::WebURL
&)
55 return enabledPerSettings
|| m_displayingInsecureContentAllowed
;
58 bool WebPermissions::allowRunningInsecureContent(bool enabledPerSettings
, const blink::WebSecurityOrigin
&, const blink::WebURL
&)
60 return enabledPerSettings
|| m_runningInsecureContentAllowed
;
63 void WebPermissions::setImagesAllowed(bool imagesAllowed
)
65 m_imagesAllowed
= imagesAllowed
;
68 void WebPermissions::setScriptsAllowed(bool scriptsAllowed
)
70 m_scriptsAllowed
= scriptsAllowed
;
73 void WebPermissions::setStorageAllowed(bool storageAllowed
)
75 m_storageAllowed
= storageAllowed
;
78 void WebPermissions::setPluginsAllowed(bool pluginsAllowed
)
80 m_pluginsAllowed
= pluginsAllowed
;
83 void WebPermissions::setDisplayingInsecureContentAllowed(bool allowed
)
85 m_displayingInsecureContentAllowed
= allowed
;
88 void WebPermissions::setRunningInsecureContentAllowed(bool allowed
)
90 m_runningInsecureContentAllowed
= allowed
;
93 void WebPermissions::setDelegate(WebTestDelegate
* delegate
)
95 m_delegate
= delegate
;
98 void WebPermissions::setDumpCallbacks(bool dumpCallbacks
)
100 m_dumpCallbacks
= dumpCallbacks
;
103 void WebPermissions::reset()
105 m_dumpCallbacks
= false;
106 m_imagesAllowed
= true;
107 m_scriptsAllowed
= true;
108 m_storageAllowed
= true;
109 m_pluginsAllowed
= true;
110 m_displayingInsecureContentAllowed
= false;
111 m_runningInsecureContentAllowed
= false;
114 } // namespace content