OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "content/shell/renderer/test_runner/WebPermissions.h" |
| 6 |
| 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" |
| 11 |
| 12 using namespace std; |
| 13 |
| 14 namespace WebTestRunner { |
| 15 |
| 16 WebPermissions::WebPermissions() |
| 17 : m_delegate(0) |
| 18 { |
| 19 reset(); |
| 20 } |
| 21 |
| 22 WebPermissions::~WebPermissions() |
| 23 { |
| 24 } |
| 25 |
| 26 bool WebPermissions::allowImage(blink::WebFrame*, bool enabledPerSettings, const
blink::WebURL& imageURL) |
| 27 { |
| 28 bool allowed = enabledPerSettings && m_imagesAllowed; |
| 29 if (m_dumpCallbacks && m_delegate) |
| 30 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") +
normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false")
+ "\n"); |
| 31 return allowed; |
| 32 } |
| 33 |
| 34 bool WebPermissions::allowScriptFromSource(blink::WebFrame*, bool enabledPerSett
ings, const blink::WebURL& scriptURL) |
| 35 { |
| 36 bool allowed = enabledPerSettings && m_scriptsAllowed; |
| 37 if (m_dumpCallbacks && m_delegate) |
| 38 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowScriptFrom
Source(") + normalizeLayoutTestURL(scriptURL.spec()) + "): " + (allowed ? "true"
: "false") + "\n"); |
| 39 return allowed; |
| 40 } |
| 41 |
| 42 bool WebPermissions::allowStorage(blink::WebFrame*, bool) |
| 43 { |
| 44 return m_storageAllowed; |
| 45 } |
| 46 |
| 47 bool WebPermissions::allowPlugins(blink::WebFrame*, bool enabledPerSettings) |
| 48 { |
| 49 return enabledPerSettings && m_pluginsAllowed; |
| 50 } |
| 51 |
| 52 bool WebPermissions::allowDisplayingInsecureContent(blink::WebFrame*, bool enabl
edPerSettings, const blink::WebSecurityOrigin&, const blink::WebURL&) |
| 53 { |
| 54 return enabledPerSettings || m_displayingInsecureContentAllowed; |
| 55 } |
| 56 |
| 57 bool WebPermissions::allowRunningInsecureContent(blink::WebFrame*, bool enabledP
erSettings, const blink::WebSecurityOrigin&, const blink::WebURL&) |
| 58 { |
| 59 return enabledPerSettings || m_runningInsecureContentAllowed; |
| 60 } |
| 61 |
| 62 void WebPermissions::setImagesAllowed(bool imagesAllowed) |
| 63 { |
| 64 m_imagesAllowed = imagesAllowed; |
| 65 } |
| 66 |
| 67 void WebPermissions::setScriptsAllowed(bool scriptsAllowed) |
| 68 { |
| 69 m_scriptsAllowed = scriptsAllowed; |
| 70 } |
| 71 |
| 72 void WebPermissions::setStorageAllowed(bool storageAllowed) |
| 73 { |
| 74 m_storageAllowed = storageAllowed; |
| 75 } |
| 76 |
| 77 void WebPermissions::setPluginsAllowed(bool pluginsAllowed) |
| 78 { |
| 79 m_pluginsAllowed = pluginsAllowed; |
| 80 } |
| 81 |
| 82 void WebPermissions::setDisplayingInsecureContentAllowed(bool allowed) |
| 83 { |
| 84 m_displayingInsecureContentAllowed = allowed; |
| 85 } |
| 86 |
| 87 void WebPermissions::setRunningInsecureContentAllowed(bool allowed) |
| 88 { |
| 89 m_runningInsecureContentAllowed = allowed; |
| 90 } |
| 91 |
| 92 void WebPermissions::setDelegate(WebTestDelegate* delegate) |
| 93 { |
| 94 m_delegate = delegate; |
| 95 } |
| 96 |
| 97 void WebPermissions::setDumpCallbacks(bool dumpCallbacks) |
| 98 { |
| 99 m_dumpCallbacks = dumpCallbacks; |
| 100 } |
| 101 |
| 102 void WebPermissions::reset() |
| 103 { |
| 104 m_dumpCallbacks = false; |
| 105 m_imagesAllowed = true; |
| 106 m_scriptsAllowed = true; |
| 107 m_storageAllowed = true; |
| 108 m_pluginsAllowed = true; |
| 109 m_displayingInsecureContentAllowed = false; |
| 110 m_runningInsecureContentAllowed = false; |
| 111 } |
| 112 |
| 113 } |
OLD | NEW |