2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef WebPermissionClient_h
32 #define WebPermissionClient_h
37 class WebPermissionCallbacks;
38 class WebSecurityOrigin;
42 class WebPermissionClient {
44 // Controls whether access to Web Databases is allowed for this frame.
45 virtual bool allowDatabase(const WebString& name, const WebString& displayName, unsigned long estimatedSize) { return true; }
47 // Controls whether access to File System is allowed for this frame.
48 virtual bool allowFileSystem() { return true; }
50 virtual void requestFileSystemAccess(const WebPermissionCallbacks& callbacks) { }
52 // Controls whether images are allowed for this frame.
53 virtual bool allowImage(bool enabledPerSettings, const WebURL& imageURL) { return enabledPerSettings; }
55 // Controls whether access to Indexed DB are allowed for this frame.
56 virtual bool allowIndexedDB(const WebString& name, const WebSecurityOrigin&) { return true; }
58 // Controls whether plugins are allowed for this frame.
59 virtual bool allowPlugins(bool enabledPerSettings) { return enabledPerSettings; }
61 // Controls whether scripts are allowed to execute for this frame.
62 virtual bool allowScript(bool enabledPerSettings) { return enabledPerSettings; }
64 // Controls whether scripts loaded from the given URL are allowed to execute for this frame.
65 virtual bool allowScriptFromSource(bool enabledPerSettings, const WebURL& scriptURL) { return enabledPerSettings; }
67 // Controls whether insecrure content is allowed to display for this frame.
68 virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, const WebSecurityOrigin&, const WebURL&) { return enabledPerSettings; }
70 // Controls whether insecrure scripts are allowed to execute for this frame.
71 virtual bool allowRunningInsecureContent(bool enabledPerSettings, const WebSecurityOrigin&, const WebURL&) { return enabledPerSettings; }
73 // Controls whether the given script extension should run in a new script
74 // context in this frame. If extensionGroup is 0, the script context is the
75 // frame's main context. Otherwise, it is a context created by
76 // WebLocalFrame::executeScriptInIsolatedWorld with that same extensionGroup
78 virtual bool allowScriptExtension(const WebString& extensionName, int extensionGroup) { return true; }
80 virtual bool allowScriptExtension(const WebString& extensionName, int extensionGroup, int worldId)
82 return allowScriptExtension(extensionName, extensionGroup);
85 // Controls whether HTML5 Web Storage is allowed for this frame.
86 // If local is true, then this is for local storage, otherwise it's for session storage.
87 virtual bool allowStorage(bool local) { return true; }
89 // Controls whether access to read the clipboard is allowed for this frame.
90 virtual bool allowReadFromClipboard(bool defaultValue) { return defaultValue; }
92 // Controls whether access to write the clipboard is allowed for this frame.
93 virtual bool allowWriteToClipboard(bool defaultValue) { return defaultValue; }
95 // Controls whether enabling Web Components API for this frame.
96 virtual bool allowWebComponents(bool defaultValue) { return defaultValue; }
98 // Controls whether to enable MutationEvents for this frame.
99 // The common use case of this method is actually to selectively disable MutationEvents,
100 // but it's been named for consistency with the rest of the interface.
101 virtual bool allowMutationEvents(bool defaultValue) { return defaultValue; }
103 // Controls whether pushState and related History APIs are enabled for this frame.
104 virtual bool allowPushState() { return true; }
106 // Notifies the client that the frame would have instantiated a plug-in if plug-ins were enabled.
107 virtual void didNotAllowPlugins() { }
109 // Notifies the client that the frame would have executed script if script were enabled.
110 virtual void didNotAllowScript() { }
113 ~WebPermissionClient() { }