web_view_permission_helper_delegate.h revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
1// Copyright 2014 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#ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIWE_PERMISSION_HELPER_DELEGATE_H_ 6#define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIWE_PERMISSION_HELPER_DELEGATE_H_ 7 8#include "content/public/browser/web_contents.h" 9#include "content/public/browser/web_contents_observer.h" 10#include "content/public/common/media_stream_request.h" 11#include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" 12 13namespace extensions { 14 15// A delegate class of WebViewPermissionHelper to request permissions that are 16// not a part of extensions. 17class WebViewPermissionHelperDelegate : public content::WebContentsObserver { 18 public: 19 explicit WebViewPermissionHelperDelegate( 20 WebViewPermissionHelper* web_view_permission_helper); 21 virtual ~WebViewPermissionHelperDelegate(); 22 23 virtual void CanDownload( 24 content::RenderViewHost* render_view_host, 25 const GURL& url, 26 const std::string& request_method, 27 const base::Callback<void(bool)>& callback) {} 28 29 virtual void RequestPointerLockPermission( 30 bool user_gesture, 31 bool last_unlocked_by_target, 32 const base::Callback<void(bool)>& callback) {} 33 34 // Requests Geolocation Permission from the embedder. 35 virtual void RequestGeolocationPermission( 36 int bridge_id, 37 const GURL& requesting_frame, 38 bool user_gesture, 39 const base::Callback<void(bool)>& callback) {} 40 41 virtual void CancelGeolocationPermissionRequest(int bridge_id) {} 42 43 virtual void RequestFileSystemPermission( 44 const GURL& url, 45 bool allowed_by_default, 46 const base::Callback<void(bool)>& callback) {} 47 48 // Called when file system access is requested by the guest content using the 49 // asynchronous HTML5 file system API. The request is plumbed through the 50 // <webview> permission request API. The request will be: 51 // - Allowed if the embedder explicitly allowed it. 52 // - Denied if the embedder explicitly denied. 53 // - Determined by the guest's content settings if the embedder does not 54 // perform an explicit action. 55 // If access was blocked due to the page's content settings, 56 // |blocked_by_policy| should be true, and this function should invoke 57 // OnContentBlocked. 58 virtual void FileSystemAccessedAsync( 59 int render_process_id, 60 int render_frame_id, 61 int request_id, 62 const GURL& url, 63 bool blocked_by_policy) {} 64 65 // Called when file system access is requested by the guest content using the 66 // synchronous HTML5 file system API in a worker thread or shared worker. The 67 // request is plumbed through the <webview> permission request API. The 68 // request will be: 69 // - Allowed if the embedder explicitly allowed it. 70 // - Denied if the embedder explicitly denied. 71 // - Determined by the guest's content settings if the embedder does not 72 // perform an explicit action. 73 // If access was blocked due to the page's content settings, 74 // |blocked_by_policy| should be true, and this function should invoke 75 // OnContentBlocked. 76 virtual void FileSystemAccessedSync( 77 int render_process_id, 78 int render_frame_id, 79 const GURL& url, 80 bool blocked_by_policy, 81 IPC::Message* reply_msg) {} 82 83 WebViewPermissionHelper* web_view_permission_helper() const { 84 return web_view_permission_helper_; 85 } 86 87 private: 88 WebViewPermissionHelper* const web_view_permission_helper_; 89 90 DISALLOW_COPY_AND_ASSIGN(WebViewPermissionHelperDelegate); 91}; 92 93} // namespace extensions 94 95#endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIWE_PERMISSION_HELPER_DELEGATE_H_ 96