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(
25 const std::string
& request_method
,
26 const base::Callback
<void(bool)>& callback
) {}
28 virtual void RequestPointerLockPermission(
30 bool last_unlocked_by_target
,
31 const base::Callback
<void(bool)>& callback
) {}
33 // Requests Geolocation Permission from the embedder.
34 virtual void RequestGeolocationPermission(
36 const GURL
& requesting_frame
,
38 const base::Callback
<void(bool)>& callback
) {}
40 virtual void CancelGeolocationPermissionRequest(int bridge_id
) {}
42 virtual void RequestFileSystemPermission(
44 bool allowed_by_default
,
45 const base::Callback
<void(bool)>& callback
) {}
47 // Called when file system access is requested by the guest content using the
48 // asynchronous HTML5 file system API. The request is plumbed through the
49 // <webview> permission request API. The request will be:
50 // - Allowed if the embedder explicitly allowed it.
51 // - Denied if the embedder explicitly denied.
52 // - Determined by the guest's content settings if the embedder does not
53 // perform an explicit action.
54 // If access was blocked due to the page's content settings,
55 // |blocked_by_policy| should be true, and this function should invoke
57 virtual void FileSystemAccessedAsync(
58 int render_process_id
,
62 bool blocked_by_policy
) {}
64 // Called when file system access is requested by the guest content using the
65 // synchronous HTML5 file system API in a worker thread or shared worker. The
66 // request is plumbed through the <webview> permission request API. The
68 // - Allowed if the embedder explicitly allowed it.
69 // - Denied if the embedder explicitly denied.
70 // - Determined by the guest's content settings if the embedder does not
71 // perform an explicit action.
72 // If access was blocked due to the page's content settings,
73 // |blocked_by_policy| should be true, and this function should invoke
75 virtual void FileSystemAccessedSync(
76 int render_process_id
,
79 bool blocked_by_policy
,
80 IPC::Message
* reply_msg
) {}
82 WebViewPermissionHelper
* web_view_permission_helper() const {
83 return web_view_permission_helper_
;
87 WebViewPermissionHelper
* const web_view_permission_helper_
;
89 DISALLOW_COPY_AND_ASSIGN(WebViewPermissionHelperDelegate
);
92 } // namespace extensions
94 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIWE_PERMISSION_HELPER_DELEGATE_H_