| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 bool MockContentSettingsClient::allowMedia(const blink::WebURL& image_url) { | 32 bool MockContentSettingsClient::allowMedia(const blink::WebURL& image_url) { |
| 33 bool allowed = flags_->media_allowed(); | 33 bool allowed = flags_->media_allowed(); |
| 34 if (flags_->dump_web_content_settings_client_callbacks() && delegate_) | 34 if (flags_->dump_web_content_settings_client_callbacks() && delegate_) |
| 35 delegate_->PrintMessage( | 35 delegate_->PrintMessage( |
| 36 std::string("MockContentSettingsClient: allowMedia(") + | 36 std::string("MockContentSettingsClient: allowMedia(") + |
| 37 NormalizeLayoutTestURL(image_url.string().utf8()) + | 37 NormalizeLayoutTestURL(image_url.string().utf8()) + |
| 38 "): " + (allowed ? "true" : "false") + "\n"); | 38 "): " + (allowed ? "true" : "false") + "\n"); |
| 39 return allowed; | 39 return allowed; |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool MockContentSettingsClient::allowScript(bool enabled_per_settings) { |
| 43 return enabled_per_settings && flags_->scripts_allowed(); |
| 44 } |
| 45 |
| 42 bool MockContentSettingsClient::allowScriptFromSource( | 46 bool MockContentSettingsClient::allowScriptFromSource( |
| 43 bool enabled_per_settings, | 47 bool enabled_per_settings, |
| 44 const blink::WebURL& scriptURL) { | 48 const blink::WebURL& script_url) { |
| 45 bool allowed = enabled_per_settings && flags_->scripts_allowed(); | 49 bool allowed = enabled_per_settings && flags_->scripts_allowed(); |
| 46 if (flags_->dump_web_content_settings_client_callbacks() && delegate_) { | 50 if (flags_->dump_web_content_settings_client_callbacks() && delegate_) { |
| 47 delegate_->PrintMessage( | 51 delegate_->PrintMessage( |
| 48 std::string("MockContentSettingsClient: allowScriptFromSource(") + | 52 std::string("MockContentSettingsClient: allowScriptFromSource(") + |
| 49 NormalizeLayoutTestURL(scriptURL.string().utf8()) + "): " + | 53 NormalizeLayoutTestURL(script_url.string().utf8()) + "): " + |
| 50 (allowed ? "true" : "false") + "\n"); | 54 (allowed ? "true" : "false") + "\n"); |
| 51 } | 55 } |
| 52 return allowed; | 56 return allowed; |
| 53 } | 57 } |
| 54 | 58 |
| 55 bool MockContentSettingsClient::allowStorage(bool) { | 59 bool MockContentSettingsClient::allowStorage(bool enabled_per_settings) { |
| 56 return flags_->storage_allowed(); | 60 return flags_->storage_allowed(); |
| 57 } | 61 } |
| 58 | 62 |
| 59 bool MockContentSettingsClient::allowPlugins(bool enabled_per_settings) { | 63 bool MockContentSettingsClient::allowPlugins(bool enabled_per_settings) { |
| 60 return enabled_per_settings && flags_->plugins_allowed(); | 64 return enabled_per_settings && flags_->plugins_allowed(); |
| 61 } | 65 } |
| 62 | 66 |
| 63 bool MockContentSettingsClient::allowDisplayingInsecureContent( | 67 bool MockContentSettingsClient::allowDisplayingInsecureContent( |
| 64 bool enabled_per_settings, | 68 bool enabled_per_settings, |
| 65 const blink::WebURL&) { | 69 const blink::WebURL& url) { |
| 66 return enabled_per_settings || flags_->displaying_insecure_content_allowed(); | 70 return enabled_per_settings || flags_->displaying_insecure_content_allowed(); |
| 67 } | 71 } |
| 68 | 72 |
| 69 bool MockContentSettingsClient::allowRunningInsecureContent( | 73 bool MockContentSettingsClient::allowRunningInsecureContent( |
| 70 bool enabled_per_settings, | 74 bool enabled_per_settings, |
| 71 const blink::WebSecurityOrigin&, | 75 const blink::WebSecurityOrigin& context, |
| 72 const blink::WebURL&) { | 76 const blink::WebURL& url) { |
| 73 return enabled_per_settings || flags_->running_insecure_content_allowed(); | 77 return enabled_per_settings || flags_->running_insecure_content_allowed(); |
| 74 } | 78 } |
| 75 | 79 |
| 76 bool MockContentSettingsClient::allowAutoplay(bool defaultValue) { | 80 bool MockContentSettingsClient::allowAutoplay(bool default_value) { |
| 77 return defaultValue || flags_->autoplay_allowed(); | 81 return default_value || flags_->autoplay_allowed(); |
| 78 } | 82 } |
| 79 | 83 |
| 80 void MockContentSettingsClient::SetDelegate(WebTestDelegate* delegate) { | 84 void MockContentSettingsClient::SetDelegate(WebTestDelegate* delegate) { |
| 81 delegate_ = delegate; | 85 delegate_ = delegate; |
| 82 } | 86 } |
| 83 | 87 |
| 84 } // namespace test_runner | 88 } // namespace test_runner |
| OLD | NEW |