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 "components/test_runner/mock_content_settings_client.h" | |
6 | |
7 #include "components/test_runner/layout_test_runtime_flags.h" | |
8 #include "components/test_runner/test_common.h" | |
9 #include "components/test_runner/web_test_delegate.h" | |
10 #include "third_party/WebKit/public/platform/WebURL.h" | |
11 | |
12 namespace test_runner { | |
13 | |
14 MockContentSettingsClient::MockContentSettingsClient( | |
15 LayoutTestRuntimeFlags* layout_test_runtime_flags) | |
16 : delegate_(nullptr), flags_(layout_test_runtime_flags) {} | |
17 | |
18 MockContentSettingsClient::~MockContentSettingsClient() {} | |
19 | |
20 bool MockContentSettingsClient::allowImage(bool enabled_per_settings, | |
21 const blink::WebURL& image_url) { | |
22 bool allowed = enabled_per_settings && flags_->images_allowed(); | |
23 if (flags_->dump_web_content_settings_client_callbacks() && delegate_) { | |
24 delegate_->PrintMessage( | |
25 std::string("MockContentSettingsClient: allowImage(") + | |
26 NormalizeLayoutTestURL(image_url.string().utf8()) + | |
27 "): " + (allowed ? "true" : "false") + "\n"); | |
28 } | |
29 return allowed; | |
30 } | |
31 | |
32 bool MockContentSettingsClient::allowScript(bool enabled_per_settings) { | |
33 return enabled_per_settings && flags_->scripts_allowed(); | |
34 } | |
35 | |
36 bool MockContentSettingsClient::allowScriptFromSource( | |
37 bool enabled_per_settings, | |
38 const blink::WebURL& script_url) { | |
39 bool allowed = enabled_per_settings && flags_->scripts_allowed(); | |
40 if (flags_->dump_web_content_settings_client_callbacks() && delegate_) { | |
41 delegate_->PrintMessage( | |
42 std::string("MockContentSettingsClient: allowScriptFromSource(") + | |
43 NormalizeLayoutTestURL(script_url.string().utf8()) + "): " + | |
44 (allowed ? "true" : "false") + "\n"); | |
45 } | |
46 return allowed; | |
47 } | |
48 | |
49 bool MockContentSettingsClient::allowStorage(bool enabled_per_settings) { | |
50 return flags_->storage_allowed(); | |
51 } | |
52 | |
53 bool MockContentSettingsClient::allowPlugins(bool enabled_per_settings) { | |
54 return enabled_per_settings && flags_->plugins_allowed(); | |
55 } | |
56 | |
57 bool MockContentSettingsClient::allowRunningInsecureContent( | |
58 bool enabled_per_settings, | |
59 const blink::WebSecurityOrigin& context, | |
60 const blink::WebURL& url) { | |
61 return enabled_per_settings || flags_->running_insecure_content_allowed(); | |
62 } | |
63 | |
64 bool MockContentSettingsClient::allowAutoplay(bool default_value) { | |
65 return flags_->autoplay_allowed(); | |
66 } | |
67 | |
68 void MockContentSettingsClient::SetDelegate(WebTestDelegate* delegate) { | |
69 delegate_ = delegate; | |
70 } | |
71 | |
72 } // namespace test_runner | |
OLD | NEW |