File: web_view_permission_helper_delegate.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (116 lines) | stat: -rw-r--r-- 4,434 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_PERMISSION_HELPER_DELEGATE_H_
#define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_PERMISSION_HELPER_DELEGATE_H_

#include <string>

#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"

namespace content {
struct MediaStreamRequest;
class WebContents;
}  // namespace content

namespace url {
class Origin;
}  // namespace url

class GURL;

namespace extensions {

// A delegate class of WebViewPermissionHelper to request permissions that are
// not a part of extensions.
class WebViewPermissionHelperDelegate {
 public:
  explicit WebViewPermissionHelperDelegate(
      WebViewPermissionHelper* web_view_permission_helper);

  WebViewPermissionHelperDelegate(const WebViewPermissionHelperDelegate&) =
      delete;
  WebViewPermissionHelperDelegate& operator=(
      const WebViewPermissionHelperDelegate&) = delete;

  virtual ~WebViewPermissionHelperDelegate();

  virtual void CanDownload(const GURL& url,
                           const std::string& request_method,
                           base::OnceCallback<void(bool)> callback) {}

  virtual void RequestMediaAccessPermissionForControlledFrame(
      content::WebContents* source,
      const content::MediaStreamRequest& request,
      content::MediaResponseCallback callback) {}

  virtual bool CheckMediaAccessPermissionForControlledFrame(
      content::RenderFrameHost* render_frame_host,
      const url::Origin& security_origin,
      blink::mojom::MediaStreamType type);

  virtual void RequestPointerLockPermission(
      bool user_gesture,
      bool last_unlocked_by_target,
      base::OnceCallback<void(bool)> callback) {}

  // Requests Geolocation Permission from the embedder.
  virtual void RequestGeolocationPermission(
      const GURL& requesting_frame_url,
      bool user_gesture,
      base::OnceCallback<void(bool)> callback) {}

  virtual void RequestHidPermission(const GURL& requesting_frame_url,
                                    base::OnceCallback<void(bool)> callback) {}

  virtual void RequestFileSystemPermission(
      const GURL& url,
      bool allowed_by_default,
      base::OnceCallback<void(bool)> callback) {}

  virtual void RequestFullscreenPermission(
      const url::Origin& requesting_origin,
      WebViewPermissionHelper::PermissionResponseCallback callback) {}

  // Called when file system access is requested by the guest content using the
  // asynchronous HTML5 file system API. The request is plumbed through the
  // <webview> permission request API. The request will be:
  // - Allowed if the embedder explicitly allowed it.
  // - Denied if the embedder explicitly denied.
  // - Determined by the guest's content settings if the embedder does not
  // perform an explicit action.
  // If access was blocked due to the page's content settings,
  // `blocked_by_policy` should be true, and this function should invoke
  // OnContentBlocked.
  virtual void FileSystemAccessedAsync(int render_process_id,
                                       int render_frame_id,
                                       int request_id,
                                       const GURL& url,
                                       bool blocked_by_policy) {}

  // Whether media requests approved by the webview embedder are forwarded as
  // the embedder. When false, media requests retain the embedded origin.
  virtual bool ForwardEmbeddedMediaPermissionChecksAsEmbedder(
      const url::Origin& embedder_origin);

  // Allows the delegate to override the results of permission requests; useful
  // when custom handling is needed for specific webviews.
  virtual std::optional<content::PermissionResult> OverridePermissionResult(
      ContentSettingsType type);

  WebViewPermissionHelper* web_view_permission_helper() const {
    return web_view_permission_helper_;
  }

 private:
  const raw_ptr<WebViewPermissionHelper> web_view_permission_helper_;
};

}  // namespace extensions

#endif  // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_PERMISSION_HELPER_DELEGATE_H_