File: web_view_internal_api.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (670 lines) | stat: -rw-r--r-- 21,101 bytes parent folder | download | duplicates (5)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
// 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_API_GUEST_VIEW_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_
#define EXTENSIONS_BROWSER_API_GUEST_VIEW_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_

#include <stdint.h>

#include "base/memory/scoped_refptr.h"
#include "base/time/time.h"
#include "base/values.h"
#include "extensions/browser/api/execute_code_function.h"
#include "extensions/browser/api/web_contents_capture_client.h"
#include "extensions/browser/extension_function.h"
#include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/url_fetcher.h"

class SkBitmap;

namespace base {
class TaskRunner;
}

// WARNING: WebViewInternal could be loaded in an unprivileged context, thus any
// new APIs must extend WebViewInternalExtensionFunction or
// WebViewInternalExecuteCodeFunction which do a process ID check to prevent
// abuse by normal renderer processes.
namespace extensions {

class WebViewInternalExtensionFunction : public ExtensionFunction {
 public:
  WebViewInternalExtensionFunction() = default;

 protected:
  ~WebViewInternalExtensionFunction() override = default;
  bool PreRunValidation(std::string* error) override;

  WebViewGuest& GetGuest();

 private:
  int instance_id_ = 0;
};

class WebViewInternalCaptureVisibleRegionFunction
    : public WebViewInternalExtensionFunction,
      public WebContentsCaptureClient {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.captureVisibleRegion",
                             WEBVIEWINTERNAL_CAPTUREVISIBLEREGION)
  WebViewInternalCaptureVisibleRegionFunction();

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

 protected:
  ~WebViewInternalCaptureVisibleRegionFunction() override {}

  // ExtensionFunction:
  ResponseAction Run() override;
  void GetQuotaLimitHeuristics(QuotaLimitHeuristics* heuristics) const override;
  bool ShouldSkipQuotaLimiting() const override;

 private:
  // extensions::WebContentsCaptureClient:
  ScreenshotAccess GetScreenshotAccess(
      content::WebContents* web_contents) const override;
  bool ClientAllowsTransparency() override;
  void OnCaptureSuccess(const SkBitmap& bitmap) override;
  void OnCaptureFailure(CaptureResult result) override;

  void EncodeBitmapOnWorkerThread(
      scoped_refptr<base::TaskRunner> reply_task_runner,
      const SkBitmap& bitmap);
  void OnBitmapEncodedOnUIThread(std::optional<std::string> base64_result);

  std::string GetErrorMessage(CaptureResult result);

  bool is_guest_transparent_;
};

class WebViewInternalNavigateFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.navigate",
                             WEBVIEWINTERNAL_NAVIGATE)
  WebViewInternalNavigateFunction() {}

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

 protected:
  ~WebViewInternalNavigateFunction() override {}

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalExecuteCodeFunction
    : public extensions::ExecuteCodeFunction {
 public:
  // This is called when a file URL request is complete.
  // Parameters:
  // - whether the request is success.
  // - If yes, the content of the file.
  // This callback should match the associated LoadFileCallback types
  // specified in WebUIURLFetcher and ControlledFrameEmbedderURLFetcher.
  using LoadFileCallback =
      base::OnceCallback<void(bool, std::unique_ptr<std::string>)>;

  WebViewInternalExecuteCodeFunction();

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

 protected:
  ~WebViewInternalExecuteCodeFunction() override;

  // Initialize `details_` if it hasn't already been.
  InitResult Init() override;
  bool ShouldInsertCSS() const override;
  bool ShouldRemoveCSS() const override;
  bool CanExecuteScriptOnPage(std::string* error) override;
  // Guarded by a process ID check.
  extensions::ScriptExecutor* GetScriptExecutor(std::string* error) final;
  bool IsWebView() const override;
  int GetRootFrameId() const override;
  const GURL& GetWebViewSrc() const override;
  bool LoadFile(const std::string& file, std::string* error) override;

 private:
  // Loads a file url in embedders such as WebUI and Controlled Frame.
  bool LoadFileForEmbedder(const std::string& file_src,
                           LoadFileCallback callback);
  void DidLoadFileForEmbedder(const std::string& file,
                              bool success,
                              std::unique_ptr<std::string> data);

  // Contains extension resource built from path of file which is
  // specified in JSON arguments.
  extensions::ExtensionResource resource_;

  int guest_instance_id_;

  GURL guest_src_;

  std::unique_ptr<URLFetcher> url_fetcher_;
};

class WebViewInternalExecuteScriptFunction
    : public WebViewInternalExecuteCodeFunction {
 public:
  WebViewInternalExecuteScriptFunction();

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

 protected:
  ~WebViewInternalExecuteScriptFunction() override {}

  DECLARE_EXTENSION_FUNCTION("webViewInternal.executeScript",
                             WEBVIEWINTERNAL_EXECUTESCRIPT)
};

class WebViewInternalInsertCSSFunction
    : public WebViewInternalExecuteCodeFunction {
 public:
  WebViewInternalInsertCSSFunction();

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

 protected:
  ~WebViewInternalInsertCSSFunction() override {}

  bool ShouldInsertCSS() const override;

  DECLARE_EXTENSION_FUNCTION("webViewInternal.insertCSS",
                             WEBVIEWINTERNAL_INSERTCSS)
};

class WebViewInternalAddContentScriptsFunction : public ExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.addContentScripts",
                             WEBVIEWINTERNAL_ADDCONTENTSCRIPTS)

  WebViewInternalAddContentScriptsFunction();

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

 protected:
  ~WebViewInternalAddContentScriptsFunction() override;

 private:
  ExecuteCodeFunction::ResponseAction Run() override;
};

class WebViewInternalRemoveContentScriptsFunction : public ExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.removeContentScripts",
                             WEBVIEWINTERNAL_REMOVECONTENTSCRIPTS)

  WebViewInternalRemoveContentScriptsFunction();

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

 protected:
  ~WebViewInternalRemoveContentScriptsFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalSetNameFunction : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.setName", WEBVIEWINTERNAL_SETNAME)

  WebViewInternalSetNameFunction();

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

 protected:
  ~WebViewInternalSetNameFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalSetAllowTransparencyFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.setAllowTransparency",
                             WEBVIEWINTERNAL_SETALLOWTRANSPARENCY)

  WebViewInternalSetAllowTransparencyFunction();

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

 protected:
  ~WebViewInternalSetAllowTransparencyFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalSetAllowScalingFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.setAllowScaling",
                             WEBVIEWINTERNAL_SETALLOWSCALING)

  WebViewInternalSetAllowScalingFunction();

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

 protected:
  ~WebViewInternalSetAllowScalingFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalSetZoomFunction : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.setZoom", WEBVIEWINTERNAL_SETZOOM)

  WebViewInternalSetZoomFunction();

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

 protected:
  ~WebViewInternalSetZoomFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalGetZoomFunction : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.getZoom", WEBVIEWINTERNAL_GETZOOM)

  WebViewInternalGetZoomFunction();

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

 protected:
  ~WebViewInternalGetZoomFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalSetZoomModeFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.setZoomMode",
                             WEBVIEWINTERNAL_SETZOOMMODE)

  WebViewInternalSetZoomModeFunction();

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

 protected:
  ~WebViewInternalSetZoomModeFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalGetZoomModeFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.getZoomMode",
                             WEBVIEWINTERNAL_GETZOOMMODE)

  WebViewInternalGetZoomModeFunction();

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

 protected:
  ~WebViewInternalGetZoomModeFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalFindFunction : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.find", WEBVIEWINTERNAL_FIND)

  WebViewInternalFindFunction();

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

  // Used by WebViewInternalFindHelper to Respond().
  void ForwardResponse(base::Value::Dict results);

 protected:
  ~WebViewInternalFindFunction() override;

 private:
  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalStopFindingFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.stopFinding",
                             WEBVIEWINTERNAL_STOPFINDING)

  WebViewInternalStopFindingFunction();

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

 protected:
  ~WebViewInternalStopFindingFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalLoadDataWithBaseUrlFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.loadDataWithBaseUrl",
                             WEBVIEWINTERNAL_LOADDATAWITHBASEURL)

  WebViewInternalLoadDataWithBaseUrlFunction();

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

 protected:
  ~WebViewInternalLoadDataWithBaseUrlFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalGoFunction : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.go", WEBVIEWINTERNAL_GO)

  WebViewInternalGoFunction();

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

 protected:
  ~WebViewInternalGoFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalReloadFunction : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.reload", WEBVIEWINTERNAL_RELOAD)

  WebViewInternalReloadFunction();

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

 protected:
  ~WebViewInternalReloadFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalSetPermissionFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.setPermission",
                             WEBVIEWINTERNAL_SETPERMISSION)

  WebViewInternalSetPermissionFunction();

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

 protected:
  ~WebViewInternalSetPermissionFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalOverrideUserAgentFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.overrideUserAgent",
                             WEBVIEWINTERNAL_OVERRIDEUSERAGENT)

  WebViewInternalOverrideUserAgentFunction();

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

 protected:
  ~WebViewInternalOverrideUserAgentFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalStopFunction : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.stop", WEBVIEWINTERNAL_STOP)

  WebViewInternalStopFunction();

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

 protected:
  ~WebViewInternalStopFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalSetAudioMutedFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.setAudioMuted",
                             WEBVIEWINTERNAL_SETAUDIOMUTED)

  WebViewInternalSetAudioMutedFunction();

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

 protected:
  ~WebViewInternalSetAudioMutedFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalIsAudioMutedFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.isAudioMuted",
                             WEBVIEWINTERNAL_ISAUDIOMUTED)

  WebViewInternalIsAudioMutedFunction();

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

 protected:
  ~WebViewInternalIsAudioMutedFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalGetAudioStateFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.getAudioState",
                             WEBVIEWINTERNAL_GETAUDIOSTATE)

  WebViewInternalGetAudioStateFunction();

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

 protected:
  ~WebViewInternalGetAudioStateFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalTerminateFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.terminate",
                             WEBVIEWINTERNAL_TERMINATE)

  WebViewInternalTerminateFunction();

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

 protected:
  ~WebViewInternalTerminateFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalClearDataFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.clearData",
                             WEBVIEWINTERNAL_CLEARDATA)

  WebViewInternalClearDataFunction();

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

 protected:
  ~WebViewInternalClearDataFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;

 private:
  uint32_t GetRemovalMask();
  void ClearDataDone();

  // Removal start time.
  base::Time remove_since_;
  // Removal mask, corresponds to StoragePartition::RemoveDataMask enum.
  uint32_t remove_mask_;
  // Tracks any data related or parse errors.
  bool bad_message_;
};

class WebViewInternalSetSpatialNavigationEnabledFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.setSpatialNavigationEnabled",
                             WEBVIEWINTERNAL_SETSPATIALNAVIGATIONENABLED)

  WebViewInternalSetSpatialNavigationEnabledFunction();

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

 protected:
  ~WebViewInternalSetSpatialNavigationEnabledFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

class WebViewInternalIsSpatialNavigationEnabledFunction
    : public WebViewInternalExtensionFunction {
 public:
  DECLARE_EXTENSION_FUNCTION("webViewInternal.isSpatialNavigationEnabled",
                             WEBVIEWINTERNAL_ISSPATIALNAVIGATIONENABLED)

  WebViewInternalIsSpatialNavigationEnabledFunction();

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

 protected:
  ~WebViewInternalIsSpatialNavigationEnabledFunction() override;

  // ExtensionFunction:
  ResponseAction Run() override;
};

}  // namespace extensions

#endif  // EXTENSIONS_BROWSER_API_GUEST_VIEW_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_