OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/shell/renderer/test_runner/WebPermissions.h" | 5 #include "content/shell/renderer/test_runner/WebPermissions.h" |
6 | 6 |
7 #include "content/shell/renderer/test_runner/TestCommon.h" | 7 #include "content/shell/renderer/test_runner/TestCommon.h" |
8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
9 #include "third_party/WebKit/public/platform/WebCString.h" | 9 #include "third_party/WebKit/public/platform/WebCString.h" |
10 #include "third_party/WebKit/public/platform/WebURL.h" | 10 #include "third_party/WebKit/public/platform/WebURL.h" |
11 | 11 |
12 using namespace std; | 12 using namespace std; |
13 | 13 |
14 namespace WebTestRunner { | 14 namespace WebTestRunner { |
15 | 15 |
16 WebPermissions::WebPermissions() | 16 WebPermissions::WebPermissions() |
17 : m_delegate(0) | 17 : m_delegate(0) |
18 { | 18 { |
19 reset(); | 19 reset(); |
20 } | 20 } |
21 | 21 |
22 WebPermissions::~WebPermissions() | 22 WebPermissions::~WebPermissions() |
23 { | 23 { |
24 } | 24 } |
25 | 25 |
26 bool WebPermissions::allowImage(blink::WebFrame*, bool enabledPerSettings, const
blink::WebURL& imageURL) | 26 bool WebPermissions::allowImage(blink::WebFrame*, bool enabledPerSettings, const
blink::WebURL& imageURL) |
27 { | 27 { |
| 28 return allowImage(enabledPerSettings, imageURL); |
| 29 } |
| 30 |
| 31 bool WebPermissions::allowScriptFromSource(blink::WebFrame*, bool enabledPerSett
ings, const blink::WebURL& scriptURL) |
| 32 { |
| 33 return allowScriptFromSource(enabledPerSettings, scriptURL); |
| 34 } |
| 35 |
| 36 bool WebPermissions::allowStorage(blink::WebFrame*, bool temp) |
| 37 { |
| 38 return allowStorage(temp); |
| 39 } |
| 40 |
| 41 bool WebPermissions::allowPlugins(blink::WebFrame*, bool enabledPerSettings) |
| 42 { |
| 43 return enabledPerSettings && m_pluginsAllowed; |
| 44 } |
| 45 |
| 46 bool WebPermissions::allowDisplayingInsecureContent(blink::WebFrame*, bool enabl
edPerSettings, const blink::WebSecurityOrigin& temp1, const blink::WebURL& temp2
) |
| 47 { |
| 48 return allowDisplayingInsecureContent(enabledPerSettings, temp1, temp2); |
| 49 } |
| 50 |
| 51 bool WebPermissions::allowRunningInsecureContent(blink::WebFrame*, bool enabledP
erSettings, const blink::WebSecurityOrigin& temp1, const blink::WebURL& temp2) |
| 52 { |
| 53 return allowRunningInsecureContent(enabledPerSettings, temp1, temp2); |
| 54 } |
| 55 |
| 56 bool WebPermissions::allowImage(bool enabledPerSettings, const blink::WebURL& im
ageURL) |
| 57 { |
28 bool allowed = enabledPerSettings && m_imagesAllowed; | 58 bool allowed = enabledPerSettings && m_imagesAllowed; |
29 if (m_dumpCallbacks && m_delegate) | 59 if (m_dumpCallbacks && m_delegate) |
30 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") +
normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false")
+ "\n"); | 60 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") +
normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false")
+ "\n"); |
31 return allowed; | 61 return allowed; |
32 } | 62 } |
33 | 63 |
34 bool WebPermissions::allowScriptFromSource(blink::WebFrame*, bool enabledPerSett
ings, const blink::WebURL& scriptURL) | 64 bool WebPermissions::allowScriptFromSource(bool enabledPerSettings, const blink:
:WebURL& scriptURL) |
35 { | 65 { |
36 bool allowed = enabledPerSettings && m_scriptsAllowed; | 66 bool allowed = enabledPerSettings && m_scriptsAllowed; |
37 if (m_dumpCallbacks && m_delegate) | 67 if (m_dumpCallbacks && m_delegate) |
38 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowScriptFrom
Source(") + normalizeLayoutTestURL(scriptURL.spec()) + "): " + (allowed ? "true"
: "false") + "\n"); | 68 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowScriptFrom
Source(") + normalizeLayoutTestURL(scriptURL.spec()) + "): " + (allowed ? "true"
: "false") + "\n"); |
39 return allowed; | 69 return allowed; |
40 } | 70 } |
41 | 71 |
42 bool WebPermissions::allowStorage(blink::WebFrame*, bool) | 72 bool WebPermissions::allowStorage(bool) |
43 { | 73 { |
44 return m_storageAllowed; | 74 return m_storageAllowed; |
45 } | 75 } |
46 | 76 |
47 bool WebPermissions::allowPlugins(blink::WebFrame*, bool enabledPerSettings) | 77 bool WebPermissions::allowPlugins(bool enabledPerSettings) |
48 { | 78 { |
49 return enabledPerSettings && m_pluginsAllowed; | 79 return enabledPerSettings && m_pluginsAllowed; |
50 } | 80 } |
51 | 81 |
52 bool WebPermissions::allowDisplayingInsecureContent(blink::WebFrame*, bool enabl
edPerSettings, const blink::WebSecurityOrigin&, const blink::WebURL&) | 82 bool WebPermissions::allowDisplayingInsecureContent(bool enabledPerSettings, con
st blink::WebSecurityOrigin&, const blink::WebURL&) |
53 { | 83 { |
54 return enabledPerSettings || m_displayingInsecureContentAllowed; | 84 return enabledPerSettings || m_displayingInsecureContentAllowed; |
55 } | 85 } |
56 | 86 |
57 bool WebPermissions::allowRunningInsecureContent(blink::WebFrame*, bool enabledP
erSettings, const blink::WebSecurityOrigin&, const blink::WebURL&) | 87 bool WebPermissions::allowRunningInsecureContent(bool enabledPerSettings, const
blink::WebSecurityOrigin&, const blink::WebURL&) |
58 { | 88 { |
59 return enabledPerSettings || m_runningInsecureContentAllowed; | 89 return enabledPerSettings || m_runningInsecureContentAllowed; |
60 } | 90 } |
61 | 91 |
62 void WebPermissions::setImagesAllowed(bool imagesAllowed) | 92 void WebPermissions::setImagesAllowed(bool imagesAllowed) |
63 { | 93 { |
64 m_imagesAllowed = imagesAllowed; | 94 m_imagesAllowed = imagesAllowed; |
65 } | 95 } |
66 | 96 |
67 void WebPermissions::setScriptsAllowed(bool scriptsAllowed) | 97 void WebPermissions::setScriptsAllowed(bool scriptsAllowed) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 m_dumpCallbacks = false; | 134 m_dumpCallbacks = false; |
105 m_imagesAllowed = true; | 135 m_imagesAllowed = true; |
106 m_scriptsAllowed = true; | 136 m_scriptsAllowed = true; |
107 m_storageAllowed = true; | 137 m_storageAllowed = true; |
108 m_pluginsAllowed = true; | 138 m_pluginsAllowed = true; |
109 m_displayingInsecureContentAllowed = false; | 139 m_displayingInsecureContentAllowed = false; |
110 m_runningInsecureContentAllowed = false; | 140 m_runningInsecureContentAllowed = false; |
111 } | 141 } |
112 | 142 |
113 } | 143 } |
OLD | NEW |