15267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)/* 25267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * Copyright (C) 2011 Google Inc. All rights reserved. 35267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * 45267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without 55267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * modification, are permitted provided that the following conditions are 65267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * met: 75267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * 85267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * * Redistributions of source code must retain the above copyright 95267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * notice, this list of conditions and the following disclaimer. 105267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * * Redistributions in binary form must reproduce the above 115267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer 125267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * in the documentation and/or other materials provided with the 135267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * distribution. 145267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * * Neither the name of Google Inc. nor the names of its 155267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * contributors may be used to endorse or promote products derived from 165267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * this software without specific prior written permission. 175267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * 185267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 195267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 205267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 215267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 225267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 235267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 245267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 255267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 265267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 275267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 285267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 295267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) */ 305267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 315267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#ifndef WebPermissionClient_h 325267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#define WebPermissionClient_h 335267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 34d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)#include "public/platform/WebPermissionCallbacks.h" 35d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) 3651b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)namespace blink { 375267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 385267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebDocument; 395267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebSecurityOrigin; 405267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebString; 415267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebURL; 425267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 435267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebPermissionClient { 445267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)public: 455267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether access to Web Databases is allowed for this frame. 46a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowDatabase(const WebString& name, const WebString& displayName, unsigned long estimatedSize) { return true; } 475267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 485267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether access to File System is allowed for this frame. 49d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) virtual bool requestFileSystemAccessSync() { return true; } 505267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 51d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) // Controls whether access to File System is allowed for this frame. 52d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) virtual void requestFileSystemAccessAsync(const WebPermissionCallbacks& callbacks) { WebPermissionCallbacks permissionCallbacks(callbacks); permissionCallbacks.doAllow(); } 53d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 545267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether images are allowed for this frame. 55a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowImage(bool enabledPerSettings, const WebURL& imageURL) { return enabledPerSettings; } 565267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 575267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether access to Indexed DB are allowed for this frame. 58a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowIndexedDB(const WebString& name, const WebSecurityOrigin&) { return true; } 595267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 60197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch // Controls whether HTML5 media elements (<audio>, <video>) are allowed for this frame. 61197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch virtual bool allowMedia(const WebURL& videoURL) { return true; } 62197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 635267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether plugins are allowed for this frame. 64a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowPlugins(bool enabledPerSettings) { return enabledPerSettings; } 655267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 665267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether scripts are allowed to execute for this frame. 67a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowScript(bool enabledPerSettings) { return enabledPerSettings; } 685267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 695267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether scripts loaded from the given URL are allowed to execute for this frame. 70a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowScriptFromSource(bool enabledPerSettings, const WebURL& scriptURL) { return enabledPerSettings; } 715267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 725267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether insecrure content is allowed to display for this frame. 73a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, const WebSecurityOrigin&, const WebURL&) { return enabledPerSettings; } 745267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 755267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether insecrure scripts are allowed to execute for this frame. 76a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowRunningInsecureContent(bool enabledPerSettings, const WebSecurityOrigin&, const WebURL&) { return enabledPerSettings; } 775267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 785267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether the given script extension should run in a new script 795267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // context in this frame. If extensionGroup is 0, the script context is the 805267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // frame's main context. Otherwise, it is a context created by 8107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // WebLocalFrame::executeScriptInIsolatedWorld with that same extensionGroup 825267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // value. 83a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowScriptExtension(const WebString& extensionName, int extensionGroup) { return true; } 845267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 85a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowScriptExtension(const WebString& extensionName, int extensionGroup, int worldId) 865267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) { 87a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch return allowScriptExtension(extensionName, extensionGroup); 885267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) } 895267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 905267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether HTML5 Web Storage is allowed for this frame. 915267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // If local is true, then this is for local storage, otherwise it's for session storage. 92a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowStorage(bool local) { return true; } 935267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 945267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether access to read the clipboard is allowed for this frame. 95a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowReadFromClipboard(bool defaultValue) { return defaultValue; } 965267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 975267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether access to write the clipboard is allowed for this frame. 98a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowWriteToClipboard(bool defaultValue) { return defaultValue; } 995267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1005267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether enabling Web Components API for this frame. 101a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowWebComponents(bool defaultValue) { return defaultValue; } 1025267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 10309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) // Controls whether to enable MutationEvents for this frame. 1045267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // The common use case of this method is actually to selectively disable MutationEvents, 1055267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // but it's been named for consistency with the rest of the interface. 106a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowMutationEvents(bool defaultValue) { return defaultValue; } 1075267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1085267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether pushState and related History APIs are enabled for this frame. 109a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual bool allowPushState() { return true; } 11019cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles) 1115267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Notifies the client that the frame would have instantiated a plug-in if plug-ins were enabled. 112a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual void didNotAllowPlugins() { } 1135267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1145267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Notifies the client that the frame would have executed script if script were enabled. 115a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch virtual void didNotAllowScript() { } 1165267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1175267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)protected: 1185267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) ~WebPermissionClient() { } 1195267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)}; 1205267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 12151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} // namespace blink 1225267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1235267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#endif 124