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