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