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.
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_
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"
13 namespace extensions
{
15 // A delegate class of WebViewPermissionHelper to request permissions that are
16 // not a part of extensions.
17 class WebViewPermissionHelperDelegate
: public content::WebContentsObserver
{
19 explicit WebViewPermissionHelperDelegate(
20 WebViewPermissionHelper
* web_view_permission_helper
);
21 ~WebViewPermissionHelperDelegate() override
;
23 virtual void CanDownload(
24 content::RenderViewHost
* render_view_host
,
26 const std::string
& request_method
,
27 const base::Callback
<void(bool)>& callback
) {}
29 virtual void RequestPointerLockPermission(
31 bool last_unlocked_by_target
,
32 const base::Callback
<void(bool)>& callback
) {}
34 // Requests Geolocation Permission from the embedder.
35 virtual void RequestGeolocationPermission(
37 const GURL
& requesting_frame
,
39 const base::Callback
<void(bool)>& callback
) {}
41 virtual void CancelGeolocationPermissionRequest(int bridge_id
) {}
43 virtual void RequestFileSystemPermission(
45 bool allowed_by_default
,
46 const base::Callback
<void(bool)>& callback
) {}
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
58 virtual void FileSystemAccessedAsync(
59 int render_process_id
,
63 bool blocked_by_policy
) {}
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
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
76 virtual void FileSystemAccessedSync(
77 int render_process_id
,
80 bool blocked_by_policy
,
81 IPC::Message
* reply_msg
) {}
83 WebViewPermissionHelper
* web_view_permission_helper() const {
84 return web_view_permission_helper_
;
88 WebViewPermissionHelper
* const web_view_permission_helper_
;
90 DISALLOW_COPY_AND_ASSIGN(WebViewPermissionHelperDelegate
);
93 } // namespace extensions
95 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIWE_PERMISSION_HELPER_DELEGATE_H_