File: controlled_frame_api_methods.js

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 (111 lines) | stat: -rw-r--r-- 3,606 bytes parent folder | download | duplicates (6)
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
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This module contains the public-facing API functions for <controlledframe>.

// Contains a list of API method names that do not produce asynchronous results
// for use in GuestViewContainerElement.forwardApiMethods().
const CONTROLLED_FRAME_API_METHODS = [
  // Returns whether there is a previous history entry to navigate to.
  'canGoBack',

  // Returns whether there is a subsequent history entry to navigate to.
  'canGoForward',

  // Returns the user agent string used by the webview for guest page requests.
  'getUserAgent',

  // Returns whether the user agent string has been overridden.
  'isUserAgentOverridden',

  // Prints the contents of the webview.
  'print',

  // Reloads the current top-level page.
  'reload',

  // Set audio mute.
  'setAudioMuted',

  // Override the user agent string used by the webview for guest page requests.
  'setUserAgentOverride',

  // Stops loading the current navigation if one is in progress.
  'stop',

  // Toggles whether client hints use the Controlled Frame brand.
  'setClientHintsUABrandEnabled',
];

// Contains a list of API details that can return Promises. The details have the
// API name and the argument list index for their callback parameter. The
// callback index is necessary for APIs that are implemented by an internal API
// object, since there is not a way to know the expected size of the arguments
// accepted by the function.
const CONTROLLED_FRAME_PROMISE_API_METHODS = [
  // Add content scripts for the guest page.
  {name: 'addContentScripts', callbackIndex: 1},

  // Navigates to the previous history entry.
  {name: 'back', callbackIndex: 0},

  // Captures the visible region of the WebView contents into a bitmap.
  {name: 'captureVisibleRegion', callbackIndex: 1},

  // Clears browsing data for the WebView partition.
  {name: 'clearData', callbackIndex: 2},

  // Injects JavaScript code into the guest page.
  {name: 'executeScript', callbackIndex: 1},

  // Navigates to the subsequent history entry.
  {name: 'forward', callbackIndex: 0},

  // Returns audio state.
  {name: 'getAudioState', callbackIndex: 0},

  // Gets the current zoom factor.
  {name: 'getZoom', callbackIndex: 0},

  // Navigates to a history entry using a history index relative to the current
  // navigation.
  {name: 'go', callbackIndex: 1},

  // Injects CSS into the guest page.
  {name: 'insertCSS', callbackIndex: 1},

  // Returns whether audio is muted.
  {name: 'isAudioMuted', callbackIndex: 0},

  // Removes content scripts for the guest page.
  {name: 'removeContentScripts', callbackIndex: 1},

  // Changes the zoom factor of the page.
  {name: 'setZoom', callbackIndex: 1},

  // Changes the zoom mode of the webview.
  {name: 'setZoomMode', callbackIndex: 1},
];

// Contains a list of API method names that should be deleted from the
// ControlledFrame element if they exist. These methods exist on other
// GuestView implementations but aren't supported in Controlled Frame.
const CONTROLLED_FRAME_DELETED_API_METHODS = [
  'find',
  'getProcessId',
  'getZoomMode',
  'isSpatialNavigationEnabled',
  'loadDataWithBaseUrl',
  'setSpatialNavigationEnabled',
  'stopFinding',
  'terminate',
];

exports.$set('CONTROLLED_FRAME_API_METHODS', CONTROLLED_FRAME_API_METHODS);
exports.$set(
    'CONTROLLED_FRAME_DELETED_API_METHODS',
    CONTROLLED_FRAME_DELETED_API_METHODS);
exports.$set(
    'CONTROLLED_FRAME_PROMISE_API_METHODS',
    CONTROLLED_FRAME_PROMISE_API_METHODS);