Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / public / web / WebPermissionClient.h
1 /*
2  * Copyright (C) 2011 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
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
13  * distribution.
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.
17  *
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.
29  */
30
31 #ifndef WebPermissionClient_h
32 #define WebPermissionClient_h
33
34 namespace blink {
35
36 class WebDocument;
37 class WebPermissionCallbacks;
38 class WebSecurityOrigin;
39 class WebString;
40 class WebURL;
41
42 class WebPermissionClient {
43 public:
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; }
46
47     // Controls whether access to File System is allowed for this frame.
48     virtual bool allowFileSystem() { return true; }
49
50     virtual void requestFileSystemAccess(const WebPermissionCallbacks& callbacks) { }
51
52     // Controls whether images are allowed for this frame.
53     virtual bool allowImage(bool enabledPerSettings, const WebURL& imageURL) { return enabledPerSettings; }
54
55     // Controls whether access to Indexed DB are allowed for this frame.
56     virtual bool allowIndexedDB(const WebString& name, const WebSecurityOrigin&) { return true; }
57
58     // Controls whether plugins are allowed for this frame.
59     virtual bool allowPlugins(bool enabledPerSettings) { return enabledPerSettings; }
60
61     // Controls whether scripts are allowed to execute for this frame.
62     virtual bool allowScript(bool enabledPerSettings) { return enabledPerSettings; }
63
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; }
66
67     // Controls whether insecrure content is allowed to display for this frame.
68     virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, const WebSecurityOrigin&, const WebURL&) { return enabledPerSettings; }
69
70     // Controls whether insecrure scripts are allowed to execute for this frame.
71     virtual bool allowRunningInsecureContent(bool enabledPerSettings, const WebSecurityOrigin&, const WebURL&) { return enabledPerSettings; }
72
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
77     // value.
78     virtual bool allowScriptExtension(const WebString& extensionName, int extensionGroup) { return true; }
79
80     virtual bool allowScriptExtension(const WebString& extensionName, int extensionGroup, int worldId)
81     {
82         return allowScriptExtension(extensionName, extensionGroup);
83     }
84
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; }
88
89     // Controls whether access to read the clipboard is allowed for this frame.
90     virtual bool allowReadFromClipboard(bool defaultValue) { return defaultValue; }
91
92     // Controls whether access to write the clipboard is allowed for this frame.
93     virtual bool allowWriteToClipboard(bool defaultValue) { return defaultValue; }
94
95     // Controls whether enabling Web Components API for this frame.
96     virtual bool allowWebComponents(bool defaultValue) { return defaultValue; }
97
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; }
102
103     // Controls whether pushState and related History APIs are enabled for this frame.
104     virtual bool allowPushState() { return true; }
105
106     // Notifies the client that the frame would have instantiated a plug-in if plug-ins were enabled.
107     virtual void didNotAllowPlugins() { }
108
109     // Notifies the client that the frame would have executed script if script were enabled.
110     virtual void didNotAllowScript() { }
111
112 protected:
113     ~WebPermissionClient() { }
114 };
115
116 } // namespace blink
117
118 #endif