File: chrome_client.h

package info (click to toggle)
chromium 90.0.4430.212-1~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,450,632 kB
  • sloc: cpp: 19,832,434; javascript: 2,948,838; ansic: 2,312,399; python: 1,464,622; xml: 584,121; java: 514,189; asm: 470,557; objc: 83,463; perl: 77,861; sh: 77,030; cs: 70,789; fortran: 24,137; tcl: 18,916; php: 18,872; makefile: 16,848; ruby: 16,721; pascal: 13,150; sql: 10,199; yacc: 7,507; lex: 1,313; lisp: 840; awk: 329; jsp: 39; sed: 19
file content (579 lines) | stat: -rw-r--r-- 25,356 bytes parent folder | download
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
/*
 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple, Inc. All rights
 * reserved.
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAGE_CHROME_CLIENT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAGE_CHROME_CLIENT_H_

#include <memory>

#include "base/gtest_prod_util.h"
#include "base/optional.h"
#include "cc/input/event_listener_properties.h"
#include "cc/input/layer_selection_bound.h"
#include "cc/input/overscroll_behavior.h"
#include "cc/paint/paint_image.h"
#include "cc/trees/paint_holding_commit_trigger.h"
#include "components/viz/common/delegated_ink_metadata.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "third_party/blink/public/common/dom_storage/session_storage_namespace_id.h"
#include "third_party/blink/public/common/feature_policy/feature_policy_features.h"
#include "third_party/blink/public/common/page/drag_operation.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink-forward.h"
#include "third_party/blink/public/platform/blame_context.h"
#include "third_party/blink/public/web/web_swap_result.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/html/battery_savings.h"
#include "third_party/blink/renderer/core/html/forms/external_date_time_chooser.h"
#include "third_party/blink/renderer/core/html/forms/popup_menu.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_offset.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/loader/navigation_policy.h"
#include "third_party/blink/renderer/core/scroll/scroll_types.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/platform/graphics/touch_action.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/text/text_direction.h"
#include "third_party/blink/renderer/platform/transforms/transformation_matrix.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"

// To avoid conflicts with the CreateWindow macro from the Windows SDK...
#undef CreateWindow

namespace cc {
struct ElementId;
class Layer;
struct OverscrollBehavior;
}

namespace ui {
class Cursor;
}

namespace blink {

class ColorChooser;
class ColorChooserClient;
class CompositorAnimationTimeline;
class DateTimeChooser;
class DateTimeChooserClient;
class Element;
class FileChooser;
class Frame;
class FullscreenOptions;
class HTMLFormControlElement;
class HTMLFormElement;
class HTMLInputElement;
class HTMLSelectElement;
class HitTestLocation;
class HitTestResult;
class IntRect;
class KeyboardEvent;
class LocalFrame;
class LocalFrameView;
class Node;
class Page;
class PagePopup;
class PagePopupClient;
class PopupOpeningObserver;
class WebDragData;
class WebViewImpl;

enum class FullscreenRequestType;

struct DateTimeChooserParameters;
struct FrameLoadRequest;
struct ViewportDescription;
struct ScreenInfo;
struct WebWindowFeatures;

namespace mojom {
namespace blink {
class TextAutosizerPageInfo;
}
}  // namespace mojom

using CompositorElementId = cc::ElementId;

class CORE_EXPORT ChromeClient : public GarbageCollected<ChromeClient> {
  DISALLOW_COPY_AND_ASSIGN(ChromeClient);

 public:
  virtual ~ChromeClient() = default;

  virtual WebViewImpl* GetWebView() const = 0;

  // Converts the scalar value from window coordinates to viewport scale.
  virtual float WindowToViewportScalar(LocalFrame*,
                                       const float value) const = 0;

  virtual bool IsPopup() { return false; }

  virtual void ChromeDestroyed() = 0;

  // For non-composited WebViews that exist to contribute to a "parent" WebView
  // painting. This informs the client of the area that needs to be redrawn.
  virtual void InvalidateRect(const IntRect& update_rect) = 0;

  // Converts the rect from the viewport coordinates to screen coordinates.
  virtual IntRect ViewportToScreen(const IntRect&,
                                   const LocalFrameView*) const = 0;

  virtual void ScheduleAnimation(const LocalFrameView*,
                                 base::TimeDelta = base::TimeDelta()) = 0;

  // Adjusts |pending_rect| for the minimum window size and |frame|'s screen
  // and returns the adjusted value.
  // Cross-screen window placements are passed on without same-screen clamping
  // if the |requesting_frame| (i.e. the opener or |frame| itself) has
  // experimental window placement features enabled. The browser will check
  // permissions before actually supporting cross-screen placement requests.
  IntRect CalculateWindowRectWithAdjustment(const IntRect& pending_rect,
                                            LocalFrame& frame,
                                            LocalFrame& requesting_frame);

  // Calls CalculateWindowRectWithAdjustment, then SetWindowRect.
  void SetWindowRectWithAdjustment(const IntRect& pending_rect,
                                   LocalFrame& frame);

  // This gives the rect of the top level window that the given LocalFrame is a
  // part of.
  virtual IntRect RootWindowRect(LocalFrame&) = 0;

  virtual void FocusPage() = 0;
  virtual void DidFocusPage() = 0;

  virtual bool CanTakeFocus(mojom::blink::FocusType) = 0;
  virtual void TakeFocus(mojom::blink::FocusType) = 0;

  virtual void SetKeyboardFocusURL(Element*) {}

  // Allow document lifecycle updates to be run in order to produce composited
  // outputs. Updates are blocked from occurring during loading navigation in
  // order to prevent contention and allow Blink to proceed more quickly. This
  // signals that enough progress has been made and document lifecycle updates
  // are desirable. This will allow visual updates to occur unless the caller
  // also uses StartDeferringCommits().
  //
  // This may only be called for the main frame, and takes it as
  // reference to make it clear that callers may only call this while a local
  // main frame is present and the values does not persist between instances of
  // local main frames.
  virtual void BeginLifecycleUpdates(LocalFrame& main_frame) = 0;

  // Start or stop compositor commits from occurring, with a timeout before they
  // are allowed again. Document lifecycle updates are still allowed during this
  // time, which will update compositor state, but this prevents the state from
  // being committed to the compositor thread and generating visual updates.
  //
  // These may only be called for the main frame, and takes it as
  // reference to make it clear that callers may only call this while a local
  // main frame is present and the state does not persist between instances of
  // local main frames.
  virtual void StartDeferringCommits(LocalFrame& main_frame,
                                     base::TimeDelta timeout) = 0;
  virtual void StopDeferringCommits(LocalFrame& main_frame,
                                    cc::PaintHoldingCommitTrigger) = 0;

  // Start a system drag and drop operation.
  virtual void StartDragging(LocalFrame*,
                             const WebDragData&,
                             DragOperationsMask,
                             const SkBitmap& drag_image,
                             const gfx::Point& drag_image_offset) = 0;
  virtual bool AcceptsLoadDrops() const = 0;

  // The LocalFrame pointer provides the ChromeClient with context about which
  // LocalFrame wants to create the new Page. Also, the newly created window
  // should not be shown to the user until the ChromeClient of the newly
  // created Page has its show method called.
  // The FrameLoadRequest parameter is only for ChromeClient to check if the
  // request could be fulfilled. The ChromeClient should not load the request.
  Page* CreateWindow(LocalFrame*,
                     const FrameLoadRequest&,
                     const AtomicString& frame_name,
                     const WebWindowFeatures&,
                     network::mojom::blink::WebSandboxFlags,
                     const SessionStorageNamespaceId&,
                     bool& consumed_user_gesture);

  // Show a previously created Page that was created via CreateWindow. This
  // should only be called once the newly created window when it is ready to be
  // shown. Under some circumstances CreateWindow's implementation may return a
  // previously shown page. Calling this method should still work and the
  // browser will discard the unnecessary show request.
  virtual void Show(const blink::LocalFrameToken& opener_frame_token,
                    NavigationPolicy navigation_policy,
                    const IntRect& initial_rect,
                    bool consumed_user_gesture) = 0;

  // All the parameters should be in viewport space. That is, if an event
  // scrolls by 10 px, but due to a 2X page scale we apply a 5px scroll to the
  // root frame, all of which is handled as overscroll, we should return 10px
  // as the |overscroll_delta|.
  virtual void DidOverscroll(const gfx::Vector2dF& overscroll_delta,
                             const gfx::Vector2dF& accumulated_overscroll,
                             const gfx::PointF& position_in_viewport,
                             const gfx::Vector2dF& velocity_in_viewport) = 0;

  // Causes a gesture event of |injected_type| to be dispatched at a later
  // point in time. |injected_type| is required to be one of
  // GestureScroll{Begin,Update,End}. If the main thread is currently handling
  // an input event, the gesture will be dispatched immediately after the
  // current event is finished being processed.
  // If there is no input event being handled, the gesture is queued up
  // on the main thread's input event queue.
  // The dispatched gesture will scroll the ScrollableArea identified by
  // |scrollable_area_element_id| by the given delta+granularity.
  virtual void InjectGestureScrollEvent(
      LocalFrame& local_frame,
      WebGestureDevice device,
      const gfx::Vector2dF& delta,
      ScrollGranularity granularity,
      CompositorElementId scrollable_area_element_id,
      WebInputEvent::Type injected_type) {}

  // Set the browser's behavior when overscroll happens, e.g. whether to glow
  // or navigate. This may only be called for the main frame, and takes it as
  // reference to make it clear that callers may only call this while a local
  // main frame is present and the values do not persist between instances of
  // local main frames.
  virtual void SetOverscrollBehavior(LocalFrame& main_frame,
                                     const cc::OverscrollBehavior&) = 0;

  virtual bool ShouldReportDetailedMessageForSourceAndSeverity(
      LocalFrame&,
      mojom::blink::ConsoleMessageLevel log_level,
      const String& source) = 0;
  virtual void AddMessageToConsole(LocalFrame*,
                                   mojom::ConsoleMessageSource,
                                   mojom::ConsoleMessageLevel,
                                   const String& message,
                                   unsigned line_number,
                                   const String& source_id,
                                   const String& stack_trace) = 0;

  virtual bool CanOpenBeforeUnloadConfirmPanel() = 0;
  bool OpenBeforeUnloadConfirmPanel(const String& message,
                                    LocalFrame*,
                                    bool is_reload);

  virtual void CloseWindowSoon() = 0;

  bool OpenJavaScriptAlert(LocalFrame*, const String&);
  bool OpenJavaScriptConfirm(LocalFrame*, const String&);
  bool OpenJavaScriptPrompt(LocalFrame*,
                            const String& message,
                            const String& default_value,
                            String& result);
  virtual bool TabsToLinks() = 0;

  virtual const ScreenInfo& GetScreenInfo(LocalFrame& frame) const = 0;

  virtual void SetCursor(const ui::Cursor&, LocalFrame* local_root) = 0;

  virtual void SetCursorOverridden(bool) = 0;

  virtual void AutoscrollStart(const gfx::PointF& position, LocalFrame*) {}
  virtual void AutoscrollFling(const gfx::Vector2dF& velocity, LocalFrame*) {}
  virtual void AutoscrollEnd(LocalFrame*) {}

  virtual ui::Cursor LastSetCursorForTesting() const = 0;
  Node* LastSetTooltipNodeForTesting() const {
    return last_mouse_over_node_.Get();
  }

  virtual void SetCursorForPlugin(const ui::Cursor&, LocalFrame*) = 0;

  // Returns a custom visible rect if a viewport override is active. Requires
  // the |frame| being painted, but only supports being used for the main frame.
  virtual void OverrideVisibleRectForMainFrame(LocalFrame& frame,
                                               IntRect* paint_rect) const {}

  // Returns the scale used to convert incoming input events while emulating
  // device metics.
  virtual float InputEventsScaleForEmulation() const { return 1; }

  virtual void DispatchViewportPropertiesDidChange(
      const ViewportDescription&) const {}

  virtual bool DoubleTapToZoomEnabled() const { return false; }

  virtual void EnablePreferredSizeChangedMode() {}

  virtual void ZoomToFindInPageRect(const gfx::Rect&) {}

  virtual void ContentsSizeChanged(LocalFrame*, const IntSize&) const = 0;
  // Call during pinch gestures, or when page-scale changes on main-frame load.
  virtual void PageScaleFactorChanged() const {}
  virtual float ClampPageScaleFactorToLimits(float scale) const {
    return scale;
  }
  virtual void MainFrameScrollOffsetChanged(LocalFrame& main_frame) const = 0;
  virtual void ResizeAfterLayout() const {}
  virtual void MainFrameLayoutUpdated() const {}

  void MouseDidMoveOverElement(LocalFrame&,
                               const HitTestLocation&,
                               const HitTestResult&);
  virtual void SetToolTip(LocalFrame&, const String&, TextDirection) = 0;
  void ClearToolTip(LocalFrame&);
  String GetLastToolTipTextForTesting() {
    return current_tool_tip_text_for_test_;
  }

  bool Print(LocalFrame*);

  virtual ColorChooser* OpenColorChooser(LocalFrame*,
                                         ColorChooserClient*,
                                         const Color&) = 0;

  // This function is used for:
  //  - Mandatory date/time choosers if InputMultipleFieldsUI flag is not set
  //  - Date/time choosers for types for which
  //    LayoutTheme::SupportsCalendarPicker returns true, if
  //    InputMultipleFieldsUI flag is set
  //  - <datalist> UI for date/time input types regardless of
  //    InputMultipleFieldsUI flag
  // |LocalFrame| should not be null.
  virtual DateTimeChooser* OpenDateTimeChooser(
      LocalFrame*,
      DateTimeChooserClient*,
      const DateTimeChooserParameters&) = 0;
  virtual ExternalDateTimeChooser* GetExternalDateTimeChooserForTesting() {
    return nullptr;
  }

  virtual void OpenTextDataListChooser(HTMLInputElement&) = 0;

  virtual void OpenFileChooser(LocalFrame*, scoped_refptr<FileChooser>) = 0;

  // Pass nullptr as the cc::Layer to detach the root layer.
  // This sets the cc::Layer for the LocalFrame's WebWidget, if it has
  // one. Otherwise it sets it for the WebViewImpl.
  virtual void AttachRootLayer(scoped_refptr<cc::Layer>,
                               LocalFrame* local_root) = 0;

  // Set the CompositorAnimationTimeline for a local root. Should later be unset
  // by a call to DetachCompositorAnimationTimeline().
  virtual void AttachCompositorAnimationTimeline(CompositorAnimationTimeline*,
                                                 LocalFrame* local_root) {}
  // Removes the CompositorAnimationTimeline for a local root. The timeline
  // would have previously been given to AttachCompositorAnimationTimeline() but
  // it's valid to call this even if the timeline was never attached.
  virtual void DetachCompositorAnimationTimeline(CompositorAnimationTimeline*,
                                                 LocalFrame* local_root) {}

  virtual void EnterFullscreen(LocalFrame&,
                               const FullscreenOptions*,
                               FullscreenRequestType) {}
  virtual void ExitFullscreen(LocalFrame&) {}
  virtual void FullscreenElementChanged(Element* old_element,
                                        Element* new_element,
                                        const FullscreenOptions* options,
                                        FullscreenRequestType) {}

  virtual void AnimateDoubleTapZoom(const gfx::Point& point,
                                    const gfx::Rect& rect) {}

  virtual void ClearLayerSelection(LocalFrame*) {}
  virtual void UpdateLayerSelection(LocalFrame*, const cc::LayerSelection&) {}

  // The client keeps track of which touch/mousewheel event types have handlers,
  // and if they do, whether the handlers are passive and/or blocking. This
  // allows the client to know which optimizations can be used for the
  // associated event classes.
  virtual void SetEventListenerProperties(LocalFrame*,
                                          cc::EventListenerClass,
                                          cc::EventListenerProperties) = 0;
  virtual cc::EventListenerProperties EventListenerProperties(
      LocalFrame*,
      cc::EventListenerClass) const = 0;

  virtual void SetHasScrollEventHandlers(LocalFrame*, bool) = 0;
  virtual void SetNeedsLowLatencyInput(LocalFrame*, bool) = 0;
  virtual void SetNeedsUnbufferedInputForDebugger(LocalFrame*, bool) = 0;
  virtual void RequestUnbufferedInputEvents(LocalFrame*) = 0;
  virtual void SetTouchAction(LocalFrame*, TouchAction) = 0;

  // Checks if there is an opened popup, called by LayoutMenuList::showPopup().
  virtual bool HasOpenedPopup() const = 0;
  virtual PopupMenu* OpenPopupMenu(LocalFrame&, HTMLSelectElement&) = 0;
  virtual PagePopup* OpenPagePopup(PagePopupClient*) = 0;
  virtual void ClosePagePopup(PagePopup*) = 0;
  virtual DOMWindow* PagePopupWindowForTesting() const = 0;

  virtual void SetBrowserControlsState(float top_height,
                                       float bottom_height,
                                       bool shrinks_layout) {}
  virtual void SetBrowserControlsShownRatio(float top_ratio,
                                            float bottom_ratio) {}

  virtual String AcceptLanguages() = 0;

  enum class UIElementType {
    kAlertDialog = 0,
    kConfirmDialog = 1,
    kPromptDialog = 2,
    kPrintDialog = 3,
    kPopup = 4
  };
  virtual bool ShouldOpenUIElementDuringPageDismissal(
      LocalFrame&,
      UIElementType,
      const String&,
      Document::PageDismissalType) const {
    return false;
  }

  virtual bool IsSVGImageChromeClient() const { return false; }

  virtual IntSize MinimumWindowSize() const { return IntSize(100, 100); }

  virtual bool IsChromeClientImpl() const { return false; }

  virtual void DidAssociateFormControlsAfterLoad(LocalFrame*) {}
  virtual void DidChangeValueInTextField(HTMLFormControlElement&) {}
  virtual void DidEndEditingOnTextField(HTMLInputElement&) {}
  virtual void HandleKeyboardEventOnTextField(HTMLInputElement&,
                                              KeyboardEvent&) {}
  virtual void TextFieldDataListChanged(HTMLInputElement&) {}
  virtual void DidChangeSelectionInSelectControl(HTMLFormControlElement&) {}
  virtual void SelectFieldOptionsChanged(HTMLFormControlElement&) {}
  virtual void AjaxSucceeded(LocalFrame*) {}

  // Input method editor related functions.
  virtual void ShowVirtualKeyboardOnElementFocus(LocalFrame&) {}

  virtual TransformationMatrix GetDeviceEmulationTransform() const {
    return TransformationMatrix();
  }

  virtual void OnMouseDown(Node&) {}

  virtual void DidUpdateBrowserControls() const {}

  virtual void RegisterPopupOpeningObserver(PopupOpeningObserver*) = 0;
  virtual void UnregisterPopupOpeningObserver(PopupOpeningObserver*) = 0;
  virtual void NotifyPopupOpeningObservers() const = 0;

  virtual FloatSize ElasticOverscroll() const { return FloatSize(); }

  virtual void InstallSupplements(LocalFrame&);

  virtual viz::FrameSinkId GetFrameSinkId(LocalFrame*) {
    return viz::FrameSinkId();
  }

  virtual void RequestDecode(LocalFrame*,
                             const cc::PaintImage& image,
                             base::OnceCallback<void(bool)> callback) {
    std::move(callback).Run(false);
  }

  // The |callback| will be fired when the corresponding renderer frame for the
  // |frame| is presented in the display compositor. The reported time could
  // sometimes be the swap time, as is the case when the swap is aborted. In
  // this case, WebSwapResult will be DidNotSwap.
  using ReportTimeCallback =
      WTF::CrossThreadOnceFunction<void(WebSwapResult, base::TimeTicks)>;
  virtual void NotifyPresentationTime(LocalFrame& frame,
                                      ReportTimeCallback callback) {}

  // Enable or disable BeginMainFrameNotExpected signals from the compositor of
  // the local root of |frame|. These signals would be consumed by the blink
  // scheduler.
  virtual void RequestBeginMainFrameNotExpected(LocalFrame& frame,
                                                bool request) = 0;

  // A stable numeric Id for |frame|'s local root's compositor. For
  // tracing/debugging purposes.
  virtual int GetLayerTreeId(LocalFrame& frame) = 0;

  virtual void Trace(Visitor*) const;

  virtual void DidUpdateTextAutosizerPageInfo(
      const mojom::blink::TextAutosizerPageInfo&) {}

  virtual void DocumentDetached(Document&) {}

  // Return the user's zoom factor which is different from the typical usage
  // of "zoom factor" in blink (e.g., |LocalFrame::PageZoomFactor()|) which
  // includes CSS zoom and the device scale factor (if use-zoom-for-dsf is
  // enabled). This only includes the zoom initiated by the user (ctrl +/-).
  virtual double UserZoomFactor() const { return 1; }

  virtual void SetDelegatedInkMetadata(
      LocalFrame* frame,
      std::unique_ptr<viz::DelegatedInkMetadata> metadata) {}

  virtual void BatterySavingsChanged(LocalFrame& main_frame,
                                     BatterySavingsFlags savings) = 0;

  virtual void FormElementReset(HTMLFormElement& element) {}

  virtual void PasswordFieldReset(HTMLInputElement& element) {}

 protected:
  ChromeClient() = default;

  virtual void ShowMouseOverURL(const HitTestResult&) = 0;
  virtual void SetWindowRect(const IntRect&, LocalFrame&) = 0;
  virtual bool OpenBeforeUnloadConfirmPanelDelegate(LocalFrame*,
                                                    bool is_reload) = 0;
  virtual bool OpenJavaScriptAlertDelegate(LocalFrame*, const String&) = 0;
  virtual bool OpenJavaScriptConfirmDelegate(LocalFrame*, const String&) = 0;
  virtual bool OpenJavaScriptPromptDelegate(LocalFrame*,
                                            const String& message,
                                            const String& default_value,
                                            String& result) = 0;
  virtual void PrintDelegate(LocalFrame*) = 0;
  virtual Page* CreateWindowDelegate(LocalFrame*,
                                     const FrameLoadRequest&,
                                     const AtomicString& frame_name,
                                     const WebWindowFeatures&,
                                     network::mojom::blink::WebSandboxFlags,
                                     const SessionStorageNamespaceId&,
                                     bool& consumed_user_gesture) = 0;

 private:
  bool CanOpenUIElementIfDuringPageDismissal(Frame& main_frame,
                                             UIElementType,
                                             const String& message);
  void SetToolTip(LocalFrame&, const HitTestLocation&, const HitTestResult&);

  WeakMember<Node> last_mouse_over_node_;
  PhysicalOffset last_tool_tip_point_;
  String last_tool_tip_text_;
  // |last_tool_tip_text_| is kept even if ClearToolTip is called. This is for
  // the tooltip text that is cleared when ClearToolTip is called.
  String current_tool_tip_text_for_test_;

  FRIEND_TEST_ALL_PREFIXES(ChromeClientTest, SetToolTipFlood);
  FRIEND_TEST_ALL_PREFIXES(ChromeClientTest, SetToolTipEmptyString);
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_PAGE_CHROME_CLIENT_H_