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) 345267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)namespace WebKit { 355267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 365267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebDocument; 375267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebFrame; 385267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebSecurityOrigin; 395267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebString; 405267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebURL; 415267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 425267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebPermissionClient { 435267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)public: 445267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether access to Web Databases is allowed for this frame. 455267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) { return true; } 465267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 475267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether access to File System is allowed for this frame. 485267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowFileSystem(WebFrame*) { return true; } 495267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 505267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether images are allowed for this frame. 515267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowImage(WebFrame* frame, bool enabledPerSettings, const WebURL& imageURL) { return enabledPerSettings; } 525267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 535267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether access to Indexed DB are allowed for this frame. 545267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowIndexedDB(WebFrame*, const WebString& name, const WebSecurityOrigin&) { return true; } 555267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 565267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether plugins are allowed for this frame. 575267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowPlugins(WebFrame*, bool enabledPerSettings) { return enabledPerSettings; } 585267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 595267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether scripts are allowed to execute for this frame. 605267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowScript(WebFrame*, bool enabledPerSettings) { return enabledPerSettings; } 615267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 625267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether scripts loaded from the given URL are allowed to execute for this frame. 635267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowScriptFromSource(WebFrame*, bool enabledPerSettings, const WebURL& scriptURL) { return enabledPerSettings; } 645267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 655267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether insecrure content is allowed to display for this frame. 665267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowDisplayingInsecureContent(WebFrame*, bool enabledPerSettings, const WebSecurityOrigin&, const WebURL&) { return enabledPerSettings; } 675267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 685267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether insecrure scripts are allowed to execute for this frame. 695267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowRunningInsecureContent(WebFrame*, bool enabledPerSettings, const WebSecurityOrigin&, const WebURL&) { return enabledPerSettings; } 705267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 715267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether the given script extension should run in a new script 725267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // context in this frame. If extensionGroup is 0, the script context is the 735267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // frame's main context. Otherwise, it is a context created by 745267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // WebFrame::executeScriptInIsolatedWorld with that same extensionGroup 755267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // value. 765267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowScriptExtension(WebFrame*, const WebString& extensionName, int extensionGroup) { return true; } 775267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 785267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowScriptExtension(WebFrame* webFrame, const WebString& extensionName, int extensionGroup, int worldId) 795267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) { 805267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) return allowScriptExtension(webFrame, extensionName, extensionGroup); 815267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) } 825267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 835267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether HTML5 Web Storage is allowed for this frame. 845267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // If local is true, then this is for local storage, otherwise it's for session storage. 855267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowStorage(WebFrame*, bool local) { return true; } 865267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 875267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether access to read the clipboard is allowed for this frame. 885267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowReadFromClipboard(WebFrame*, bool defaultValue) { return defaultValue; } 895267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 905267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether access to write the clipboard is allowed for this frame. 915267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowWriteToClipboard(WebFrame*, bool defaultValue) { return defaultValue; } 925267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 935267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether enabling Web Components API for this frame. 945267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowWebComponents(const WebDocument&, bool defaultValue) { return defaultValue; } 955267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 965267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether to enable MutationEvents for this document. 975267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // The common use case of this method is actually to selectively disable MutationEvents, 985267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // but it's been named for consistency with the rest of the interface. 995267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowMutationEvents(const WebDocument&, bool defaultValue) { return defaultValue; } 1005267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1015267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Controls whether pushState and related History APIs are enabled for this frame. 1025267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual bool allowPushState(const WebDocument&) { return true; } 1035267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1045267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Notifies the client that the frame would have instantiated a plug-in if plug-ins were enabled. 1055267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual void didNotAllowPlugins(WebFrame*) { } 1065267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1075267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) // Notifies the client that the frame would have executed script if script were enabled. 1085267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) virtual void didNotAllowScript(WebFrame*) { } 1095267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1105267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)protected: 1115267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) ~WebPermissionClient() { } 1125267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)}; 1135267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1145267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)} // namespace WebKit 1155267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 1165267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#endif 117