File: browser_window.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 (673 lines) | stat: -rw-r--r-- 28,576 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
671
672
673
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_BROWSER_WINDOW_H_
#define CHROME_BROWSER_UI_BROWSER_WINDOW_H_

#include <memory>
#include <optional>
#include <string>
#include <vector>

#include "base/feature_list.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/browser/apps/link_capturing/intent_picker_info.h"
#include "chrome/browser/lifetime/browser_close_manager.h"
#include "chrome/browser/share/share_attempt.h"
#include "chrome/browser/signin/chrome_signin_helper.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/ui/bookmarks/bookmark_bar.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h"
#include "chrome/browser/ui/hats/hats_service.h"
#include "chrome/browser/ui/page_action/page_action_icon_type.h"
#include "chrome/browser/ui/translate/partial_translate_bubble_model.h"
#include "chrome/browser/ui/user_education/browser_user_education_interface.h"
#include "chrome/browser/ui/webui/tab_search/tab_search.mojom.h"
#include "chrome/common/buildflags.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/translate/core/common/translate_errors.h"
#include "ui/base/base_window.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/mojom/window_show_state.mojom-forward.h"
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/native_widget_types.h"
#include "url/origin.h"

#if BUILDFLAG(IS_ANDROID)
#error This file should only be included on desktop.
#endif

class Browser;
class BrowserView;
class DownloadBubbleUIController;
class DownloadShelf;
class ExclusiveAccessContext;
class ExtensionsContainer;
class FindBar;
class GURL;
class LocationBar;
class SharingDialog;
class StatusBubble;
struct SharingDialogData;

namespace autofill {
class AutofillBubbleHandler;
}  // namespace autofill

namespace content {
class WebContents;
struct NativeWebKeyboardEvent;
enum class KeyboardEventProcessingResult;
}  // namespace content

namespace gfx {
class Size;
}

namespace qrcode_generator {
class QRCodeGeneratorBubbleView;
}  // namespace qrcode_generator

namespace send_tab_to_self {
class SendTabToSelfBubbleView;
}  // namespace send_tab_to_self

namespace sharing_hub {
class ScreenshotCapturedBubble;
class SharingHubBubbleView;
}  // namespace sharing_hub

namespace signin_metrics {
enum class AccessPoint;
}

namespace ui {
class ColorProvider;
class NativeTheme;
class ThemeProvider;
}  // namespace ui

namespace views {
class Button;
class WebView;
}  // namespace views

namespace web_modal {
class WebContentsModalDialogHost;
}

enum class ShowTranslateBubbleResult {
  // The Full Page Translate bubble was successfully shown.
  SUCCESS,

  // The various reasons for which the Full Page Translate bubble could fail to
  // be shown.
  BROWSER_WINDOW_NOT_VALID,
  BROWSER_WINDOW_MINIMIZED,
  BROWSER_WINDOW_NOT_ACTIVE,
  WEB_CONTENTS_NOT_ACTIVE,
  EDITABLE_FIELD_IS_ACTIVE,
};

enum class BrowserThemeChangeType {
  // User changes the browser theme.
  kBrowserTheme,
  // User changes the OS native theme.
  kNativeTheme,
  // A web app sets a theme color at launch, or changes theme color.
  kWebAppTheme
};

////////////////////////////////////////////////////////////////////////////////
// BrowserWindow interface
//  An interface implemented by the "view" of the Browser window.
//  This interface includes ui::BaseWindow methods as well as Browser window
//  specific methods.
//
// NOTE: All getters may return NULL.
//
class BrowserWindow : public ui::BaseWindow,
                      public BrowserUserEducationInterface {
 public:
  ~BrowserWindow() override = default;

  //////////////////////////////////////////////////////////////////////////////
  // ui::BaseWindow interface notes:

  // Closes the window as soon as possible. If the window is not in a drag
  // session, it will close immediately; otherwise, it will move offscreen (so
  // events are still fired) until the drag ends, then close. This assumes
  // that the Browser is not immediately destroyed, but will be eventually
  // destroyed by other means (eg, the tab strip going to zero elements).
  // Bad things happen if the Browser dtor is called directly as a result of
  // invoking this method.
  // virtual void Close() = 0;

  // Browser::OnWindowDidShow should be called after showing the window.
  // virtual void Show() = 0;

  //////////////////////////////////////////////////////////////////////////////
  // Browser specific methods:

  // Returns the browser window currently hosting `web_contents`. If no browser
  // window exists this returns null.
  static BrowserWindow* FindBrowserWindowWithWebContents(
      content::WebContents* web_contents);

  // Returns true if the browser window is on the current workspace (a.k.a.
  // virtual desktop) or if we can't tell. False otherwise.
  //
  // On Windows, it must not be called while application is dispatching an input
  // synchronous call like SendMessage, because IsWindowOnCurrentVirtualDesktop
  // will return an error.
  virtual bool IsOnCurrentWorkspace() const = 0;

  // Returns true if the browser window is visible on the screen.
  virtual bool IsVisibleOnScreen() const = 0;

  // Sets the shown |ratio| of the browser's top controls (a.k.a. top-chrome) as
  // a result of gesture scrolling in |web_contents|.
  virtual void SetTopControlsShownRatio(content::WebContents* web_contents,
                                        float ratio) = 0;

  // Whether or not the renderer's viewport size should be shrunk by the height
  // of the browser's top controls.
  // As top-chrome is slided up or down, we don't actually resize the web
  // contents (for perf reasons) but we have to do a bunch of adjustments on the
  // renderer side to make it appear to the user like we're resizing things
  // smoothly:
  //
  // 1) Expose content beyond the web contents rect by expanding the clip.
  // 2) Push bottom-fixed elements around until we get a resize. As top-chrome
  //    hides, we push the fixed elements down by an equivalent amount so that
  //    they appear to stay fixed to the viewport bottom.
  //
  // Only when the user releases their finger to finish the scroll do we
  // actually resize the web contents and clear these adjustments. So web
  // contents has two possible sizes, viewport filling and shrunk by the top
  // controls.
  //
  // The GetTopControlsHeight is a static number that never changes (as long as
  // the top-chrome slide with gesture scrolls feature is enabled). To get the
  // actual "showing" height as the user sees, you multiply this by the shown
  // ratio. However, it's not enough to know this value, the renderer also needs
  // to know which direction it should be doing the above-mentioned adjustments.
  // That's what the DoBrowserControlsShrinkRendererSize bit is for. It tells
  // the renderer whether it's currently in the "viewport filling" or the
  // "shrunk by top controls" state.
  // The returned value should never change while sliding top-chrome is in
  // progress (either due to an in-progress gesture scroll, or due to a
  // renderer-initiated animation of the top controls shown ratio).
  virtual bool DoBrowserControlsShrinkRendererSize(
      const content::WebContents* contents) const = 0;

  // Returns the native theme associated with the frame.
  virtual ui::NativeTheme* GetNativeTheme() = 0;

  // Returns the ThemeProvider associated with the frame.
  virtual const ui::ThemeProvider* GetThemeProvider() const = 0;

  // Returns the ColorProvider associated with the frame.
  virtual const ui::ColorProvider* GetColorProvider() const = 0;

  // Returns the context for use with ElementTracker, InteractionSequence, etc.
  virtual ui::ElementContext GetElementContext() = 0;

  // Returns the height of the browser's top controls. This height doesn't
  // change with the current shown ratio above. Renderers will call this to
  // calculate the top-chrome shown ratio from the gesture scroll offset.
  //
  // Note: This should always return 0 if hiding top-chrome with page gesture
  // scrolls is disabled. This is needed so the renderer scrolls the page
  // immediately rather than changing the shown ratio, thinking that top-chrome
  // and the page's top edge are moving.
  virtual int GetTopControlsHeight() const = 0;

  // Propagates to the browser that gesture scrolling has changed state.
  virtual void SetTopControlsGestureScrollInProgress(bool in_progress) = 0;

  // Return the status bubble(s) associated with the frame. In a split view,
  // there will be multiple status bubbles with the active one listed first.
  // It is possible for this to be empty.
  virtual std::vector<StatusBubble*> GetStatusBubbles() = 0;

  // Inform the frame that the selected tab favicon or title has changed. Some
  // frames may need to refresh their title bar.
  virtual void UpdateTitleBar() = 0;

  // Invoked when the state of the bookmark bar changes. This is only invoked if
  // the state changes for the current tab, it is not sent when switching tabs.
  virtual void BookmarkBarStateChanged(
      BookmarkBar::AnimateChangeType change_type) = 0;

  // Temporarily force shows the bookmark bar for the provided |duration|.
  virtual void TemporarilyShowBookmarkBar(base::TimeDelta duration) = 0;

  // Inform the frame that the dev tools window for the selected tab has
  // changed.
  virtual void UpdateDevTools() = 0;

  // Update any loading animations running in the window. |is_visible| is true
  // if the window is visible.
  virtual void UpdateLoadingAnimations(bool is_visible) = 0;

  // Sets the starred state for the current tab.
  virtual void SetStarredState(bool is_starred) = 0;

  // Checks if the browser popup is a tab modal popup.
  virtual bool IsTabModalPopupDeprecated() const = 0;

  // Sets whether the browser popup is a tab modal popup. Tab modal popups, used
  // by autofill features, intentionally disable save card prompts because they
  // are not intended for saving new card details.
  virtual void SetIsTabModalPopupDeprecated(
      bool is_tab_modal_popup_deprecated) = 0;

  // Called when the active tab changes.  Subclasses which implement
  // TabStripModelObserver should implement this instead of ActiveTabChanged();
  // the Browser will call this method while processing that one.
  virtual void OnActiveTabChanged(content::WebContents* old_contents,
                                  content::WebContents* new_contents,
                                  int index,
                                  int reason) = 0;

  // Called when a tab is detached. Subclasses which implement
  // TabStripModelObserver should implement this instead of processing this
  // in OnTabStripModelChanged(); the Browser will call this method.
  virtual void OnTabDetached(content::WebContents* contents,
                             bool was_active) = 0;

  // Called to force the zoom state to for the active tab to be recalculated.
  // |can_show_bubble| is true when a user presses the zoom up or down keyboard
  // shortcuts and will be false in other cases (e.g. switching tabs, "clicking"
  // + or - in the app menu to change zoom).
  virtual void ZoomChangedForActiveTab(bool can_show_bubble) = 0;

  // Windows and GTK remove the browser controls in fullscreen, but Mac and Ash
  // keep the controls in a slide-down panel.
  virtual bool ShouldHideUIForFullscreen() const = 0;

  // Returns true if the fullscreen bubble is visible.
  virtual bool IsFullscreenBubbleVisible() const = 0;

  // True when we do not want to allow exiting fullscreen, e.g. in Chrome OS
  // Kiosk session.
  virtual bool IsForceFullscreen() const = 0;
  virtual void SetForceFullscreen(bool force_fullscreen) = 0;

  // Returns the size of WebContents in the browser. This may be called before
  // the TabStripModel has an active tab.
  virtual gfx::Size GetContentsSize() const = 0;

  // Resizes the window to fit a WebContents of a certain size. This should only
  // be called after the TabStripModel has an active tab.
  virtual void SetContentsSize(const gfx::Size& size) = 0;

  // Updates the visual state of the specified page action icon if present on
  // the window.
  virtual void UpdatePageActionIcon(PageActionIconType type) = 0;

  // Returns the AutofillBubbleHandler responsible for handling all
  // Autofill-related bubbles.
  virtual autofill::AutofillBubbleHandler* GetAutofillBubbleHandler() = 0;

  // Executes the action for the specified page action icon.
  virtual void ExecutePageActionIconForTesting(PageActionIconType type) = 0;

  // Returns the location bar.
  virtual LocationBar* GetLocationBar() const = 0;

  // Tries to focus the location bar.  Clears the window focus (to avoid
  // inconsistent state) if this fails.
  virtual void SetFocusToLocationBar(bool select_all) = 0;

  // Informs the view whether or not a load is in progress for the current tab.
  // The view can use this notification to update the reload/stop button.
  virtual void UpdateReloadStopState(bool is_loading, bool force) = 0;

  // Updates the toolbar with the state for the specified |contents|.
  virtual void UpdateToolbar(content::WebContents* contents) = 0;

  // Updates the toolbar's visible security state. Returns true if the toolbar
  // was redrawn.
  virtual bool UpdateToolbarSecurityState() = 0;

  // Updates whether or not the custom tab bar is visible. Animates the
  // transition if |animate| is true.
  virtual void UpdateCustomTabBarVisibility(bool visible, bool animate) = 0;

  // Updates the visibility of the scrim that covers the content area.
  virtual void SetContentScrimVisibility(bool visible) = 0;

  // Updates the visibility of the scrim that covers the devtools area.
  virtual void SetDevToolsScrimVisibility(bool visible) = 0;

  // Resets the toolbar's tab state for |contents|.
  virtual void ResetToolbarTabState(content::WebContents* contents) = 0;

  // Focuses the toolbar (for accessibility).
  virtual void FocusToolbar() = 0;

  // Returns the ExtensionsContainer associated with the window, if any.
  virtual ExtensionsContainer* GetExtensionsContainer() = 0;

  // Called from toolbar subviews during their show/hide animations.
  virtual void ToolbarSizeChanged(bool is_animating) = 0;

  // Called when the associated window's tab dragging status changed.
  virtual void TabDraggingStatusChanged(bool is_dragging) = 0;

  // Called when a link is opened in the window from a user gesture.
  // Link will be opened with |disposition|.
  // TODO(crbug.com/40719979): see if this can't be piped through TabStripModel
  // events instead.
  virtual void LinkOpeningFromGesture(WindowOpenDisposition disposition) = 0;

  // Focuses the app menu like it was a menu bar.
  //
  // Not used on the Mac, which has a "normal" menu bar.
  virtual void FocusAppMenu() = 0;

  // Focuses the bookmarks toolbar (for accessibility).
  virtual void FocusBookmarksToolbar() = 0;

  // Focuses a visible but inactive popup for accessibility.
  virtual void FocusInactivePopupForAccessibility() = 0;

  // Moves keyboard focus to the next pane.
  virtual void RotatePaneFocus(bool forwards) = 0;

  // Moves keyboard focus directly to the web contents pane.
  virtual void FocusWebContentsPane() = 0;

  // Returns whether the bookmark bar is visible or not.
  virtual bool IsBookmarkBarVisible() const = 0;

  // Returns whether the bookmark bar is animating or not.
  virtual bool IsBookmarkBarAnimating() const = 0;

  // Returns whether the tab strip is editable (for extensions).
  virtual bool IsTabStripEditable() const = 0;

  // Forces the tab strip into a not editable state for testing.
  virtual void SetTabStripNotEditableForTesting() = 0;

  // Returns whether the toolbar is available or not. It's called "Visible()"
  // to follow the name convention. But it does not indicate the visibility of
  // the toolbar, i.e. toolbar may be hidden, and only visible when the mouse
  // cursor is at a certain place.
  // TODO(zijiehe): Rename Visible() functions into Available() to match their
  // original meaning.
  virtual bool IsToolbarVisible() const = 0;

  // Returns whether the toolbar is showing up on the screen.
  // TODO(zijiehe): Rename this function into IsToolbarVisible() once other
  // Visible() functions are renamed to Available().
  virtual bool IsToolbarShowing() const = 0;

  // Returns whether the location bar is visible.
  virtual bool IsLocationBarVisible() const = 0;

  // Shows the dialog for a sharing feature.
  virtual SharingDialog* ShowSharingDialog(content::WebContents* contents,
                                           SharingDialogData data) = 0;

  // Shows the Update Recommended dialog box.
  virtual void ShowUpdateChromeDialog() = 0;

  // Shows the intent picker bubble. |app_info| contains the app candidates to
  // display, if |show_stay_in_chrome| is false, the 'Stay in
  // Chrome' (used for non-http(s) queries) button is hidden, if
  // |show_remember_selection| is false, the "remember my choice" checkbox is
  // hidden and |callback| helps to continue the flow back to either
  // AppsNavigationThrottle or ArcExternalProtocolDialog capturing the user's
  // decision and storing UMA metrics.
  virtual void ShowIntentPickerBubble(
      std::vector<apps::IntentPickerAppInfo> app_info,
      bool show_stay_in_chrome,
      bool show_remember_selection,
      apps::IntentPickerBubbleType bubble_type,
      const std::optional<url::Origin>& initiating_origin,
      IntentPickerResponse callback) = 0;

  // Shows the Bookmark bubble. |url| is the URL being bookmarked,
  // |already_bookmarked| is true if the url is already bookmarked.
  virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) = 0;

  // Shows the Screenshot bubble.
  virtual sharing_hub::ScreenshotCapturedBubble* ShowScreenshotCapturedBubble(
      content::WebContents* contents,
      const gfx::Image& image) = 0;

  // Shows the QR Code generator bubble. |url| is the URL for the initial code.
  virtual qrcode_generator::QRCodeGeneratorBubbleView*
  ShowQRCodeGeneratorBubble(content::WebContents* contents,
                            const GURL& url,
                            bool show_back_button) = 0;

  // Shows the "send tab to self" device picker bubble. This must only be called
  // as a direct result of user action.
  virtual send_tab_to_self::SendTabToSelfBubbleView*
  ShowSendTabToSelfDevicePickerBubble(content::WebContents* contents) = 0;

  // Shows the "send tab to self" promo bubble. This must only be called as a
  // direct result of user action.
  virtual send_tab_to_self::SendTabToSelfBubbleView*
  ShowSendTabToSelfPromoBubble(content::WebContents* contents,
                               bool show_signin_button) = 0;

#if BUILDFLAG(IS_CHROMEOS)
  // Returns the PageActionIconView for the Sharing Hub.
  virtual views::Button* GetSharingHubIconButton() = 0;

  // Toggles the multitask menu on the browser frame size button.
  virtual void ToggleMultitaskMenu() const = 0;
#else
  // Shows the Sharing Hub bubble. This must only be called as a direct result
  // of user action.
  virtual sharing_hub::SharingHubBubbleView* ShowSharingHubBubble(
      share::ShareAttempt attempt) = 0;
#endif  // BUILDFLAG(IS_CHROMEOS)

  // Shows the Full Page Translate bubble.
  //
  // |is_user_gesture| is true when the bubble is shown on the user's deliberate
  // action.
  virtual ShowTranslateBubbleResult ShowTranslateBubble(
      content::WebContents* contents,
      translate::TranslateStep step,
      const std::string& source_language,
      const std::string& target_language,
      translate::TranslateErrors error_type,
      bool is_user_gesture) = 0;

  // Shows the Partial Translate bubble.
  virtual void StartPartialTranslate(const std::string& source_language,
                                     const std::string& target_language,
                                     const std::u16string& text_selection) = 0;

  // Shows the one-click sign in confirmation UI. |email| holds the full email
  // address of the account that has signed in.
  virtual void ShowOneClickSigninConfirmation(
      const std::u16string& email,
      base::OnceCallback<void(bool)> confirmed_callback) = 0;

  // Whether or not the shelf view is visible.
  virtual bool IsDownloadShelfVisible() const = 0;

  // Returns the DownloadShelf. Returns null if download shelf is disabled. This
  // can happen if the new download bubble UI is enabled.
  virtual DownloadShelf* GetDownloadShelf() = 0;

  // Returns the TopContainerView.
  virtual views::View* GetTopContainer() = 0;

  // Returns the LensOverlayView.
  virtual views::View* GetLensOverlayView() = 0;

  // Returns the DownloadBubbleUIController. Returns null if Download Bubble
  // UI is not enabled, or if the download toolbar button does not exist.
  virtual DownloadBubbleUIController* GetDownloadBubbleUIController() = 0;

  // Shows the confirmation dialog box warning that the browser is closing with
  // in-progress downloads.
  // This method should call |callback| with the user's response.
  virtual void ConfirmBrowserCloseWithPendingDownloads(
      int download_count,
      Browser::DownloadCloseType dialog_type,
      base::OnceCallback<void(bool)> callback) = 0;

  // ThemeService calls this when a user has changed their theme, indicating
  // that it's time to redraw everything.
  virtual void UserChangedTheme(BrowserThemeChangeType theme_change_type) = 0;

  // Shows the app menu (for accessibility).
  virtual void ShowAppMenu() = 0;

  // Allows the BrowserWindow object to handle the specified mouse event
  // before sending it to the renderer.
  virtual bool PreHandleMouseEvent(const blink::WebMouseEvent& event) = 0;
  // Allows the BrowserWindow object to handle a mouse drag update
  // before sending it to the renderer.
  // `point` is relative to the content view.
  virtual void PreHandleDragUpdate(const content::DropData& drop_data,
                                   const gfx::PointF& point) = 0;
  virtual void PreHandleDragExit() = 0;
  // Allows the BrowserWindow object to handle the specified keyboard event
  // before sending it to the renderer.
  virtual content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
      const input::NativeWebKeyboardEvent& event) = 0;

  // Allows the BrowserWindow object to handle the specified keyboard event,
  // if the renderer did not process it.
  virtual bool HandleKeyboardEvent(
      const input::NativeWebKeyboardEvent& event) = 0;

  // Construct a FindBar implementation for the |browser|.
  virtual std::unique_ptr<FindBar> CreateFindBar() = 0;

  // Return the WebContentsModalDialogHost for use in positioning web contents
  // modal dialogs within the browser window. This can sometimes be NULL (for
  // instance during tab drag on Views/Win32).
  virtual web_modal::WebContentsModalDialogHost*
  GetWebContentsModalDialogHost() = 0;

  // Construct a BrowserWindow implementation for the specified |browser|.
  static BrowserWindow* CreateBrowserWindow(std::unique_ptr<Browser> browser,
                                            bool user_gesture,
                                            bool in_tab_dragging);

  virtual void ShowAvatarBubbleFromAvatarButton(bool is_source_accelerator) = 0;

  // Attempts showing the In-Produce-Help for profile Switching. This is called
  // after creating a new profile or opening an existing profile. If the profile
  // customization bubble is shown, the IPH should be shown after.
  virtual void MaybeShowProfileSwitchIPH() = 0;

  // Attempts showing the In-Product-Help for supervised user profiles.
  // This should be invoked for new signed-in supervised profiles created
  // by FRE, the profile picker, profile menu or chrome menu.
  // If the profile customization bubble is shown, the IPH should be shown
  // after.
  // TODO(351333491): To specify if this will be invoked on signing-in/turning
  // on sync for an existing profile.
  virtual void MaybeShowSupervisedUserProfileSignInIPH() = 0;

  // Shows User Happiness Tracking Survey's dialog after the survey associated
  // with |site_id| has been successfully loaded. Failure to load the survey
  // will result in the dialog not being shown. |product_specific_bits_data| and
  // |product_specific_string_data| should contain key-value pairs where the
  // keys match the field names set for the survey in hats_service.cc, and the
  // values are those which will be associated with the survey response.
  // The parameters |hats_histogram_name| and |hats_survey_ukm_id| allows HaTS
  // to log to UMA and UKM, respectively. These values are are populated in
  // chrome/browser/ui/hats/survey_config.cc and can be configured in finch.
  // Surveys that opt-in to UMA and UKM will need to have surveys reviewed by
  // privacy to ensure they are appropriate to log to UMA and/or UKM. This is
  // enforced through the OWNERS mechanism.
  virtual void ShowHatsDialog(
      const std::string& site_id,
      const std::optional<std::string>& hats_histogram_name,
      const std::optional<uint64_t> hats_survey_ukm_id,
      base::OnceClosure success_callback,
      base::OnceClosure failure_callback,
      const SurveyBitsData& product_specific_bits_data,
      const SurveyStringData& product_specific_string_data) = 0;

  // Returns object implementing ExclusiveAccessContext interface.
  virtual ExclusiveAccessContext* GetExclusiveAccessContext() = 0;

  // Returns the platform-specific ID of the workspace the browser window
  // currently resides in.
  virtual std::string GetWorkspace() const = 0;
  virtual bool IsVisibleOnAllWorkspaces() const = 0;

  // Shows the platform specific emoji picker.
  virtual void ShowEmojiPanel() = 0;

  // Opens the eye dropper.
  virtual std::unique_ptr<content::EyeDropper> OpenEyeDropper(
      content::RenderFrameHost* frame,
      content::EyeDropperListener* listener) = 0;

  // Shows a confirmation dialog about enabling caret browsing.
  virtual void ShowCaretBrowsingDialog() = 0;

  // Create and open the tab search bubble. Optionally force it to open to the
  // given section and organization feature.
  virtual void CreateTabSearchBubble(
      tab_search::mojom::TabSearchSection section,
      tab_search::mojom::TabOrganizationFeature organization_feature) = 0;
  void CreateTabSearchBubble(tab_search::mojom::TabSearchSection section =
                                 tab_search::mojom::TabSearchSection::kSearch) {
    CreateTabSearchBubble(section,
                          tab_search::mojom::TabOrganizationFeature::kNone);
  }

  // Closes the tab search bubble if open for the given browser instance.
  virtual void CloseTabSearchBubble() = 0;

  // Shows an Incognito clear browsing data dialog.
  virtual void ShowIncognitoClearBrowsingDataDialog() = 0;

  // Shows an Incognito history disclaimer dialog.
  virtual void ShowIncognitoHistoryDisclaimerDialog() = 0;

  // Returns true when the borderless mode should be displayed instead
  // of a full titlebar. This is only supported for desktop web apps.
  virtual bool IsBorderlessModeEnabled() const = 0;

  // Notifies `BrowserView` about the resizable boolean having been set with
  // `window.setResizable(bool)` API.
  virtual void OnWebApiWindowResizableChanged() = 0;

  // Returns the overall resizability of the `BrowserView` when considering
  // both the value set by the `window.setResizable(bool)` API and browser's
  // "native" resizability.
  virtual bool GetCanResize() = 0;

  virtual ui::mojom::WindowShowState GetWindowShowState() const = 0;

  // Shows the Chrome Labs bubble if enabled.
  virtual void ShowChromeLabs() = 0;

  // Returns the WebView backing the tab-contents area of the BrowserWindow.
  virtual views::WebView* GetContentsWebView() = 0;

  // In production code BrowserView is the only subclass for BrowserWindow. The
  // fact that this is not true in some tests is a problem with the tests. See
  // https://crbug.com/360163254.
  virtual BrowserView* AsBrowserView() = 0;

 protected:
  friend class BrowserCloseManager;
  friend class BrowserView;
  virtual void DestroyBrowser() = 0;
};

#endif  // CHROME_BROWSER_UI_BROWSER_WINDOW_H_