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