OLD | NEW |
| (Empty) |
1 // Copyright 2014 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/web_content_settings.h" | |
6 | |
7 #include "content/shell/renderer/test_runner/test_common.h" | |
8 #include "content/shell/renderer/test_runner/web_test_delegate.h" | |
9 #include "third_party/WebKit/public/platform/WebCString.h" | |
10 #include "third_party/WebKit/public/platform/WebURL.h" | |
11 | |
12 namespace content { | |
13 | |
14 WebContentSettings::WebContentSettings() : delegate_(0) { | |
15 Reset(); | |
16 } | |
17 | |
18 WebContentSettings::~WebContentSettings() {} | |
19 | |
20 bool WebContentSettings::allowImage(bool enabled_per_settings, | |
21 const blink::WebURL& image_url) { | |
22 bool allowed = enabled_per_settings && images_allowed_; | |
23 if (dump_callbacks_ && delegate_) { | |
24 delegate_->PrintMessage(std::string("PERMISSION CLIENT: allowImage(") + | |
25 NormalizeLayoutTestURL(image_url.spec()) + "): " + | |
26 (allowed ? "true" : "false") + "\n"); | |
27 } | |
28 return allowed; | |
29 } | |
30 | |
31 bool WebContentSettings::allowMedia(const blink::WebURL& image_url) { | |
32 bool allowed = media_allowed_; | |
33 if (dump_callbacks_ && delegate_) | |
34 delegate_->PrintMessage(std::string("PERMISSION CLIENT: allowMedia(") + | |
35 NormalizeLayoutTestURL(image_url.spec()) + "): " + | |
36 (allowed ? "true" : "false") + "\n"); | |
37 return allowed; | |
38 } | |
39 | |
40 bool WebContentSettings::allowScriptFromSource(bool enabled_per_settings, | |
41 const blink::WebURL& scriptURL) { | |
42 bool allowed = enabled_per_settings && scripts_allowed_; | |
43 if (dump_callbacks_ && delegate_) { | |
44 delegate_->PrintMessage( | |
45 std::string("PERMISSION CLIENT: allowScriptFromSource(") + | |
46 NormalizeLayoutTestURL(scriptURL.spec()) + "): " + | |
47 (allowed ? "true" : "false") + "\n"); | |
48 } | |
49 return allowed; | |
50 } | |
51 | |
52 bool WebContentSettings::allowStorage(bool) { | |
53 return storage_allowed_; | |
54 } | |
55 | |
56 bool WebContentSettings::allowPlugins(bool enabled_per_settings) { | |
57 return enabled_per_settings && plugins_allowed_; | |
58 } | |
59 | |
60 bool WebContentSettings::allowDisplayingInsecureContent( | |
61 bool enabled_per_settings, | |
62 const blink::WebSecurityOrigin&, | |
63 const blink::WebURL&) { | |
64 return enabled_per_settings || displaying_insecure_content_allowed_; | |
65 } | |
66 | |
67 bool WebContentSettings::allowRunningInsecureContent( | |
68 bool enabled_per_settings, | |
69 const blink::WebSecurityOrigin&, | |
70 const blink::WebURL&) { | |
71 return enabled_per_settings || running_insecure_content_allowed_; | |
72 } | |
73 | |
74 void WebContentSettings::SetImagesAllowed(bool images_allowed) { | |
75 images_allowed_ = images_allowed; | |
76 } | |
77 | |
78 void WebContentSettings::SetMediaAllowed(bool media_allowed) { | |
79 media_allowed_ = media_allowed; | |
80 } | |
81 | |
82 void WebContentSettings::SetScriptsAllowed(bool scripts_allowed) { | |
83 scripts_allowed_ = scripts_allowed; | |
84 } | |
85 | |
86 void WebContentSettings::SetStorageAllowed(bool storage_allowed) { | |
87 storage_allowed_ = storage_allowed; | |
88 } | |
89 | |
90 void WebContentSettings::SetPluginsAllowed(bool plugins_allowed) { | |
91 plugins_allowed_ = plugins_allowed; | |
92 } | |
93 | |
94 void WebContentSettings::SetDisplayingInsecureContentAllowed(bool allowed) { | |
95 displaying_insecure_content_allowed_ = allowed; | |
96 } | |
97 | |
98 void WebContentSettings::SetRunningInsecureContentAllowed(bool allowed) { | |
99 running_insecure_content_allowed_ = allowed; | |
100 } | |
101 | |
102 void WebContentSettings::SetDelegate(WebTestDelegate* delegate) { | |
103 delegate_ = delegate; | |
104 } | |
105 | |
106 void WebContentSettings::SetDumpCallbacks(bool dump_callbacks) { | |
107 dump_callbacks_ = dump_callbacks; | |
108 } | |
109 | |
110 void WebContentSettings::Reset() { | |
111 dump_callbacks_ = false; | |
112 images_allowed_ = true; | |
113 media_allowed_ = true; | |
114 scripts_allowed_ = true; | |
115 storage_allowed_ = true; | |
116 plugins_allowed_ = true; | |
117 displaying_insecure_content_allowed_ = false; | |
118 running_insecure_content_allowed_ = false; | |
119 } | |
120 | |
121 } // namespace content | |
OLD | NEW |