| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 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 /* |
| 6 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 7 * |
| 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions are |
| 10 * met: |
| 11 * |
| 12 * * Redistributions of source code must retain the above copyright |
| 13 * notice, this list of conditions and the following disclaimer. |
| 14 * * Redistributions in binary form must reproduce the above |
| 15 * copyright notice, this list of conditions and the following disclaimer |
| 16 * in the documentation and/or other materials provided with the |
| 17 * distribution. |
| 18 * * Neither the name of Google Inc. nor the names of its |
| 19 * contributors may be used to endorse or promote products derived from |
| 20 * this software without specific prior written permission. |
| 21 * |
| 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 */ |
| 34 |
| 35 #include "content/test/layout_tests/runner/WebPermissions.h" |
| 36 |
| 37 #include "content/test/layout_tests/runner/TestCommon.h" |
| 38 #include "third_party/WebKit/public/platform/WebCString.h" |
| 39 #include "third_party/WebKit/public/platform/WebURL.h" |
| 40 #include "content/public/test/layout_tests/WebTestDelegate.h" |
| 41 |
| 42 using namespace std; |
| 43 |
| 44 namespace WebTestRunner { |
| 45 |
| 46 WebPermissions::WebPermissions() |
| 47 : m_delegate(0) |
| 48 { |
| 49 reset(); |
| 50 } |
| 51 |
| 52 WebPermissions::~WebPermissions() |
| 53 { |
| 54 } |
| 55 |
| 56 bool WebPermissions::allowImage(blink::WebFrame*, bool enabledPerSettings, const
blink::WebURL& imageURL) |
| 57 { |
| 58 bool allowed = enabledPerSettings && m_imagesAllowed; |
| 59 if (m_dumpCallbacks && m_delegate) |
| 60 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") +
normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false")
+ "\n"); |
| 61 return allowed; |
| 62 } |
| 63 |
| 64 bool WebPermissions::allowScriptFromSource(blink::WebFrame*, bool enabledPerSett
ings, const blink::WebURL& scriptURL) |
| 65 { |
| 66 bool allowed = enabledPerSettings && m_scriptsAllowed; |
| 67 if (m_dumpCallbacks && m_delegate) |
| 68 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowScriptFrom
Source(") + normalizeLayoutTestURL(scriptURL.spec()) + "): " + (allowed ? "true"
: "false") + "\n"); |
| 69 return allowed; |
| 70 } |
| 71 |
| 72 bool WebPermissions::allowStorage(blink::WebFrame*, bool) |
| 73 { |
| 74 return m_storageAllowed; |
| 75 } |
| 76 |
| 77 bool WebPermissions::allowPlugins(blink::WebFrame*, bool enabledPerSettings) |
| 78 { |
| 79 return enabledPerSettings && m_pluginsAllowed; |
| 80 } |
| 81 |
| 82 bool WebPermissions::allowDisplayingInsecureContent(blink::WebFrame*, bool enabl
edPerSettings, const blink::WebSecurityOrigin&, const blink::WebURL&) |
| 83 { |
| 84 return enabledPerSettings || m_displayingInsecureContentAllowed; |
| 85 } |
| 86 |
| 87 bool WebPermissions::allowRunningInsecureContent(blink::WebFrame*, bool enabledP
erSettings, const blink::WebSecurityOrigin&, const blink::WebURL&) |
| 88 { |
| 89 return enabledPerSettings || m_runningInsecureContentAllowed; |
| 90 } |
| 91 |
| 92 void WebPermissions::setImagesAllowed(bool imagesAllowed) |
| 93 { |
| 94 m_imagesAllowed = imagesAllowed; |
| 95 } |
| 96 |
| 97 void WebPermissions::setScriptsAllowed(bool scriptsAllowed) |
| 98 { |
| 99 m_scriptsAllowed = scriptsAllowed; |
| 100 } |
| 101 |
| 102 void WebPermissions::setStorageAllowed(bool storageAllowed) |
| 103 { |
| 104 m_storageAllowed = storageAllowed; |
| 105 } |
| 106 |
| 107 void WebPermissions::setPluginsAllowed(bool pluginsAllowed) |
| 108 { |
| 109 m_pluginsAllowed = pluginsAllowed; |
| 110 } |
| 111 |
| 112 void WebPermissions::setDisplayingInsecureContentAllowed(bool allowed) |
| 113 { |
| 114 m_displayingInsecureContentAllowed = allowed; |
| 115 } |
| 116 |
| 117 void WebPermissions::setRunningInsecureContentAllowed(bool allowed) |
| 118 { |
| 119 m_runningInsecureContentAllowed = allowed; |
| 120 } |
| 121 |
| 122 void WebPermissions::setDelegate(WebTestDelegate* delegate) |
| 123 { |
| 124 m_delegate = delegate; |
| 125 } |
| 126 |
| 127 void WebPermissions::setDumpCallbacks(bool dumpCallbacks) |
| 128 { |
| 129 m_dumpCallbacks = dumpCallbacks; |
| 130 } |
| 131 |
| 132 void WebPermissions::reset() |
| 133 { |
| 134 m_dumpCallbacks = false; |
| 135 m_imagesAllowed = true; |
| 136 m_scriptsAllowed = true; |
| 137 m_storageAllowed = true; |
| 138 m_pluginsAllowed = true; |
| 139 m_displayingInsecureContentAllowed = false; |
| 140 m_runningInsecureContentAllowed = false; |
| 141 } |
| 142 |
| 143 } |
| OLD | NEW |