Avi Drissman | 3a215d1e | 2022-09-07 19:43:09 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef ASH_SHELL_DELEGATE_H_ |
| 6 | #define ASH_SHELL_DELEGATE_H_ |
| 7 | |
| 8 | #include <memory> |
Xiaoqian Dai | e26ad850 | 2021-06-17 00:33:45 | [diff] [blame] | 9 | #include <vector> |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 10 | |
| 11 | #include "ash/ash_export.h" |
Yeunjoo Choi | 49b3047 | 2022-02-22 02:54:53 | [diff] [blame] | 12 | #include "ash/services/multidevice_setup/public/mojom/multidevice_setup.mojom-forward.h" |
Alexander Alekseev | 2b4c959 | 2021-05-04 22:26:44 | [diff] [blame] | 13 | #include "base/files/file_path.h" |
Stefan Kuhne | 39a4110 | 2021-09-28 18:50:17 | [diff] [blame] | 14 | #include "chromeos/ui/base/window_pin_type.h" |
Roger Tinkoff | f01d873 | 2022-07-07 23:59:40 | [diff] [blame] | 15 | #include "components/version_info/channel.h" |
Ken Rockot | 3f90e70e0 | 2019-12-04 23:27:23 | [diff] [blame] | 16 | #include "mojo/public/cpp/bindings/pending_receiver.h" |
Ken Rockot | b9bab54 | 2019-12-12 00:53:30 | [diff] [blame] | 17 | #include "services/device/public/mojom/bluetooth_system.mojom-forward.h" |
| 18 | #include "services/device/public/mojom/fingerprint.mojom-forward.h" |
Becca Hughes | c742784 | 2020-11-04 23:27:38 | [diff] [blame] | 19 | #include "services/media_session/public/cpp/media_session_service.h" |
Cattalyya Nuengsigkapian | 3c4480a | 2022-03-17 20:28:19 | [diff] [blame] | 20 | #include "services/network/public/cpp/shared_url_loader_factory.h" |
Simon Hangl | add76fef | 2022-08-18 14:26:56 | [diff] [blame] | 21 | #include "services/video_capture/public/mojom/multi_capture_service.mojom-forward.h" |
minch | 64f3b43b | 2019-10-21 21:59:26 | [diff] [blame] | 22 | #include "ui/gfx/native_widget_types.h" |
anina koehler | 3b05822 | 2022-01-12 16:30:17 | [diff] [blame] | 23 | #include "url/gurl.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 24 | |
varkha | d43f5524 | 2017-05-26 20:55:58 | [diff] [blame] | 25 | namespace aura { |
| 26 | class Window; |
| 27 | } |
| 28 | |
Collin Baker | 1ca0b7a3 | 2020-04-14 18:33:00 | [diff] [blame] | 29 | namespace ui { |
| 30 | class OSExchangeData; |
| 31 | } |
| 32 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 33 | namespace ash { |
| 34 | |
| 35 | class AccessibilityDelegate; |
Xiaoqian Dai | c9f06c79 | 2020-02-19 20:52:35 | [diff] [blame] | 36 | class BackGestureContextualNudgeController; |
Richard Chui | 7f2b9b0 | 2021-10-27 01:25:44 | [diff] [blame] | 37 | class BackGestureContextualNudgeDelegate; |
| 38 | class CaptureModeDelegate; |
Sammie Quon | 14392290 | 2021-11-12 00:02:01 | [diff] [blame] | 39 | class DesksTemplatesDelegate; |
James Cook | ddc9f169 | 2022-08-22 19:31:23 | [diff] [blame] | 40 | class GlanceablesController; |
James Cook | cc962016a | 2022-08-19 00:32:45 | [diff] [blame] | 41 | class GlanceablesDelegate; |
Curt Clemens | 1def3a3 | 2020-09-21 20:10:24 | [diff] [blame] | 42 | class NearbyShareController; |
Curt Clemens | c665963 | 2020-09-16 18:32:15 | [diff] [blame] | 43 | class NearbyShareDelegate; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 44 | |
| 45 | // Delegate of the Shell. |
| 46 | class ASH_EXPORT ShellDelegate { |
| 47 | public: |
| 48 | // The Shell owns the delegate. |
Ahmed Fakhry | 0c6efef | 2020-07-30 21:51:19 | [diff] [blame] | 49 | virtual ~ShellDelegate() = default; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 50 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 51 | // Returns true if |window| can be shown for the delegate's concept of current |
| 52 | // user. |
Andrew Xu | 048f24b | 2019-01-16 21:21:23 | [diff] [blame] | 53 | virtual bool CanShowWindowForUser(const aura::Window* window) const = 0; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 54 | |
Ahmed Fakhry | 0c6efef | 2020-07-30 21:51:19 | [diff] [blame] | 55 | // Creates and returns the delegate of the Capture Mode feature. |
| 56 | virtual std::unique_ptr<CaptureModeDelegate> CreateCaptureModeDelegate() |
| 57 | const = 0; |
| 58 | |
James Cook | cc962016a | 2022-08-19 00:32:45 | [diff] [blame] | 59 | // Creates the delegate for the Glanceables feature. |
James Cook | ddc9f169 | 2022-08-22 19:31:23 | [diff] [blame] | 60 | virtual std::unique_ptr<GlanceablesDelegate> CreateGlanceablesDelegate( |
| 61 | GlanceablesController* controller) const = 0; |
James Cook | cc962016a | 2022-08-19 00:32:45 | [diff] [blame] | 62 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 63 | // Creates a accessibility delegate. Shell takes ownership of the delegate. |
| 64 | virtual AccessibilityDelegate* CreateAccessibilityDelegate() = 0; |
| 65 | |
Xiaoqian Dai | c9f06c79 | 2020-02-19 20:52:35 | [diff] [blame] | 66 | // Creates a back gesture contextual nudge delegate for |controller|. |
| 67 | virtual std::unique_ptr<BackGestureContextualNudgeDelegate> |
| 68 | CreateBackGestureContextualNudgeDelegate( |
| 69 | BackGestureContextualNudgeController* controller) = 0; |
| 70 | |
Curt Clemens | 1def3a3 | 2020-09-21 20:10:24 | [diff] [blame] | 71 | virtual std::unique_ptr<NearbyShareDelegate> CreateNearbyShareDelegate( |
| 72 | NearbyShareController* controller) const = 0; |
Curt Clemens | c665963 | 2020-09-16 18:32:15 | [diff] [blame] | 73 | |
Sammie Quon | 14392290 | 2021-11-12 00:02:01 | [diff] [blame] | 74 | virtual std::unique_ptr<DesksTemplatesDelegate> CreateDesksTemplatesDelegate() |
| 75 | const = 0; |
| 76 | |
Cattalyya Nuengsigkapian | 3c4480a | 2022-03-17 20:28:19 | [diff] [blame] | 77 | // Returns the geolocation loader factory used to initialize geolocation |
| 78 | // provider. |
| 79 | virtual scoped_refptr<network::SharedURLLoaderFactory> |
Cattalyya Nuengsigkapian | 2e703a8 | 2022-03-26 00:29:59 | [diff] [blame] | 80 | GetGeolocationUrlLoaderFactory() const = 0; |
Cattalyya Nuengsigkapian | 3c4480a | 2022-03-17 20:28:19 | [diff] [blame] | 81 | |
minch | 64f3b43b | 2019-10-21 21:59:26 | [diff] [blame] | 82 | // Check whether the current tab of the browser window can go back. |
| 83 | virtual bool CanGoBack(gfx::NativeWindow window) const = 0; |
| 84 | |
chinsenj | ade910fd | 2020-09-30 20:28:16 | [diff] [blame] | 85 | // Sets the tab scrubber |enabled_| field to |enabled|. |
Antonio Gomes | deb475f5 | 2021-12-07 16:21:00 | [diff] [blame] | 86 | virtual void SetTabScrubberChromeOSEnabled(bool enabled) = 0; |
chinsenj | ade910fd | 2020-09-30 20:28:16 | [diff] [blame] | 87 | |
Xiaoqian Dai | 1067eab | 2020-06-03 22:20:33 | [diff] [blame] | 88 | // Returns true if |window| allows default touch behaviors. If false, it means |
| 89 | // no default touch behavior is allowed (i.e., the touch action of window is |
| 90 | // cc::TouchAction::kNone). This function is used by BackGestureEventHandler |
| 91 | // to decide if we can perform the system default back gesture. |
| 92 | virtual bool AllowDefaultTouchActions(gfx::NativeWindow window); |
| 93 | |
| 94 | // Returns true if we should wait for touch press ack when deciding if back |
| 95 | // gesture can be performed. |
| 96 | virtual bool ShouldWaitForTouchPressAck(gfx::NativeWindow window); |
| 97 | |
Collin Baker | e5fb2f69 | 2020-05-14 01:24:44 | [diff] [blame] | 98 | // Checks whether a drag-drop operation is a tab drag. |
| 99 | virtual bool IsTabDrag(const ui::OSExchangeData& drop_data); |
| 100 | |
Yuheng Huang | e141ef2 | 2021-07-07 18:03:51 | [diff] [blame] | 101 | // Return the height of WebUI tab strip used to determine if a tab has |
| 102 | // dragged out of it. |
| 103 | virtual int GetBrowserWebUITabStripHeight() = 0; |
| 104 | |
Ken Rockot | b9bab54 | 2019-12-12 00:53:30 | [diff] [blame] | 105 | // Binds a BluetoothSystemFactory receiver if possible. |
| 106 | virtual void BindBluetoothSystemFactory( |
| 107 | mojo::PendingReceiver<device::mojom::BluetoothSystemFactory> receiver) {} |
| 108 | |
| 109 | // Binds a fingerprint receiver in the Device Service if possible. |
| 110 | virtual void BindFingerprint( |
| 111 | mojo::PendingReceiver<device::mojom::Fingerprint> receiver) {} |
| 112 | |
Ken Rockot | 6b5017e | 2019-12-05 20:39:41 | [diff] [blame] | 113 | // Binds a MultiDeviceSetup receiver for the primary profile. |
| 114 | virtual void BindMultiDeviceSetup( |
Yeunjoo Choi | 98f3ec56 | 2022-03-04 04:26:00 | [diff] [blame] | 115 | mojo::PendingReceiver<multidevice_setup::mojom::MultiDeviceSetup> |
| 116 | receiver) = 0; |
Ken Rockot | 6b5017e | 2019-12-05 20:39:41 | [diff] [blame] | 117 | |
Simon Hangl | add76fef | 2022-08-18 14:26:56 | [diff] [blame] | 118 | // Binds a MultiCaptureService receiver to start observing |
| 119 | // MultiCaptureStarted() and MultiCaptureStopped() events. |
| 120 | virtual void BindMultiCaptureService( |
| 121 | mojo::PendingReceiver<video_capture::mojom::MultiCaptureService> |
| 122 | receiver) = 0; |
| 123 | |
Ken Rockot | b2ac2f1 | 2019-12-06 18:33:54 | [diff] [blame] | 124 | // Returns an interface to the Media Session service, or null if not |
| 125 | // available. |
Becca Hughes | c742784 | 2020-11-04 23:27:38 | [diff] [blame] | 126 | virtual media_session::MediaSessionService* GetMediaSessionService(); |
Ken Rockot | b2ac2f1 | 2019-12-06 18:33:54 | [diff] [blame] | 127 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 128 | virtual void OpenKeyboardShortcutHelpPage() const {} |
Cattalyya Nuengsigkapian | 8c45e30 | 2021-01-06 21:48:08 | [diff] [blame] | 129 | |
| 130 | // Returns if window browser sessions are restoring. |
| 131 | virtual bool IsSessionRestoreInProgress() const = 0; |
Alexander Alekseev | 494b2d3 | 2021-01-20 06:16:43 | [diff] [blame] | 132 | |
Sean Kau | 8542a12 | 2021-10-15 22:46:06 | [diff] [blame] | 133 | // Adjust system configuration for a Locked Fullscreen window. |
| 134 | virtual void SetUpEnvironmentForLockedFullscreen(bool locked) = 0; |
Stefan Kuhne | 39a4110 | 2021-09-28 18:50:17 | [diff] [blame] | 135 | |
Alexander Alekseev | 494b2d3 | 2021-01-20 06:16:43 | [diff] [blame] | 136 | // Ui Dev Tools control. |
| 137 | virtual bool IsUiDevToolsStarted() const; |
| 138 | virtual void StartUiDevTools() {} |
| 139 | virtual void StopUiDevTools() {} |
| 140 | virtual int GetUiDevToolsPort() const; |
Alexander Alekseev | 2b4c959 | 2021-05-04 22:26:44 | [diff] [blame] | 141 | |
| 142 | // Returns true if Chrome was started with --disable-logging-redirect option. |
| 143 | virtual bool IsLoggingRedirectDisabled() const = 0; |
| 144 | |
Xiaoqian Dai | e26ad850 | 2021-06-17 00:33:45 | [diff] [blame] | 145 | // Returns empty path if user session has not started yet, or path to the |
Alexander Alekseev | 2b4c959 | 2021-05-04 22:26:44 | [diff] [blame] | 146 | // primary user Downloads folder if user has already logged in. |
| 147 | virtual base::FilePath GetPrimaryUserDownloadsFolder() const = 0; |
Xiaoqian Dai | e26ad850 | 2021-06-17 00:33:45 | [diff] [blame] | 148 | |
minch | 3453ad1 | 2021-06-21 18:25:11 | [diff] [blame] | 149 | // Opens the feedback page with pre-populated description #BentoBar for |
| 150 | // persistent desks bar. Note, this will be removed once the feature is fully |
| 151 | // launched or removed. |
| 152 | virtual void OpenFeedbackPageForPersistentDesksBar() = 0; |
anina koehler | 3b05822 | 2022-01-12 16:30:17 | [diff] [blame] | 153 | |
| 154 | // Returns the last committed URL from the web contents if the given |window| |
| 155 | // contains a browser frame, otherwise returns GURL::EmptyURL(). |
| 156 | virtual const GURL& GetLastCommittedURLForWindowIfAny(aura::Window* window); |
Roger Tinkoff | f01d873 | 2022-07-07 23:59:40 | [diff] [blame] | 157 | |
| 158 | // Retrieves the release track on which the device resides. |
| 159 | virtual version_info::Channel GetChannel() = 0; |
Ben Becker | 6a2af1b | 2022-07-20 22:41:11 | [diff] [blame] | 160 | |
| 161 | // Tells browsers not to ask the user to confirm that they want to close a |
| 162 | // window when that window is closed. |
| 163 | virtual void ForceSkipWarningUserOnClose( |
| 164 | const std::vector<aura::Window*>& windows) = 0; |
Roger Tinkoff | bc55d769 | 2022-07-22 23:58:27 | [diff] [blame] | 165 | |
| 166 | // Retrieves the official Chrome version string e.g. 105.0.5178.0. |
| 167 | virtual std::string GetVersionString() = 0; |
anina koehler | f1e29df6 | 2022-08-10 07:22:32 | [diff] [blame] | 168 | |
| 169 | // Forwards the ShouldExitFullscreenBeforeLock() call to the crosapi browser |
| 170 | // manager. |
| 171 | using ShouldExitFullscreenCallback = base::OnceCallback<void(bool)>; |
| 172 | virtual void ShouldExitFullscreenBeforeLock( |
| 173 | ShouldExitFullscreenCallback callback); |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | } // namespace ash |
| 177 | |
| 178 | #endif // ASH_SHELL_DELEGATE_H_ |