James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 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> |
| 9 | #include <string> |
Xiaoqian Dai | e26ad850 | 2021-06-17 00:33:45 | [diff] [blame] | 10 | #include <vector> |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 11 | |
| 12 | #include "ash/ash_export.h" |
| 13 | #include "base/callback.h" |
Alexander Alekseev | 2b4c959 | 2021-05-04 22:26:44 | [diff] [blame] | 14 | #include "base/files/file_path.h" |
Ken Rockot | 6b5017e | 2019-12-05 20:39:41 | [diff] [blame] | 15 | #include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom-forward.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" |
minch | 64f3b43b | 2019-10-21 21:59:26 | [diff] [blame] | 20 | #include "ui/gfx/native_widget_types.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 21 | |
varkha | d43f5524 | 2017-05-26 20:55:58 | [diff] [blame] | 22 | namespace aura { |
| 23 | class Window; |
| 24 | } |
| 25 | |
Collin Baker | 1ca0b7a3 | 2020-04-14 18:33:00 | [diff] [blame] | 26 | namespace ui { |
| 27 | class OSExchangeData; |
| 28 | } |
| 29 | |
Xiaoqian Dai | 87b325b | 2021-06-22 02:18:11 | [diff] [blame] | 30 | namespace full_restore { |
| 31 | struct AppLaunchInfo; |
| 32 | } |
| 33 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 34 | namespace ash { |
| 35 | |
| 36 | class AccessibilityDelegate; |
Ahmed Fakhry | 0c6efef | 2020-07-30 21:51:19 | [diff] [blame] | 37 | class CaptureModeDelegate; |
James Cook | 5e9d340 | 2017-11-01 00:20:12 | [diff] [blame] | 38 | class ScreenshotDelegate; |
Xiaoqian Dai | c9f06c79 | 2020-02-19 20:52:35 | [diff] [blame] | 39 | class BackGestureContextualNudgeDelegate; |
| 40 | class BackGestureContextualNudgeController; |
Curt Clemens | 1def3a3 | 2020-09-21 20:10:24 | [diff] [blame] | 41 | class NearbyShareController; |
Curt Clemens | c665963 | 2020-09-16 18:32:15 | [diff] [blame] | 42 | class NearbyShareDelegate; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 43 | |
| 44 | // Delegate of the Shell. |
| 45 | class ASH_EXPORT ShellDelegate { |
| 46 | public: |
| 47 | // The Shell owns the delegate. |
Ahmed Fakhry | 0c6efef | 2020-07-30 21:51:19 | [diff] [blame] | 48 | virtual ~ShellDelegate() = default; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 49 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 50 | // Returns true if |window| can be shown for the delegate's concept of current |
| 51 | // user. |
Andrew Xu | 048f24b | 2019-01-16 21:21:23 | [diff] [blame] | 52 | virtual bool CanShowWindowForUser(const aura::Window* window) const = 0; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 53 | |
Ahmed Fakhry | 0c6efef | 2020-07-30 21:51:19 | [diff] [blame] | 54 | // Creates and returns the delegate of the Capture Mode feature. |
| 55 | virtual std::unique_ptr<CaptureModeDelegate> CreateCaptureModeDelegate() |
| 56 | const = 0; |
| 57 | |
James Cook | d0312761 | 2020-08-28 20:11:04 | [diff] [blame] | 58 | // Creates the screenshot delegate, which has dependencies on //chrome. |
James Cook | 5e9d340 | 2017-11-01 00:20:12 | [diff] [blame] | 59 | virtual std::unique_ptr<ScreenshotDelegate> CreateScreenshotDelegate() = 0; |
| 60 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 61 | // Creates a accessibility delegate. Shell takes ownership of the delegate. |
| 62 | virtual AccessibilityDelegate* CreateAccessibilityDelegate() = 0; |
| 63 | |
Xiaoqian Dai | c9f06c79 | 2020-02-19 20:52:35 | [diff] [blame] | 64 | // Creates a back gesture contextual nudge delegate for |controller|. |
| 65 | virtual std::unique_ptr<BackGestureContextualNudgeDelegate> |
| 66 | CreateBackGestureContextualNudgeDelegate( |
| 67 | BackGestureContextualNudgeController* controller) = 0; |
| 68 | |
Curt Clemens | 1def3a3 | 2020-09-21 20:10:24 | [diff] [blame] | 69 | virtual std::unique_ptr<NearbyShareDelegate> CreateNearbyShareDelegate( |
| 70 | NearbyShareController* controller) const = 0; |
Curt Clemens | c665963 | 2020-09-16 18:32:15 | [diff] [blame] | 71 | |
minch | 64f3b43b | 2019-10-21 21:59:26 | [diff] [blame] | 72 | // Check whether the current tab of the browser window can go back. |
| 73 | virtual bool CanGoBack(gfx::NativeWindow window) const = 0; |
| 74 | |
chinsenj | ade910fd | 2020-09-30 20:28:16 | [diff] [blame] | 75 | // Sets the tab scrubber |enabled_| field to |enabled|. |
| 76 | virtual void SetTabScrubberEnabled(bool enabled) = 0; |
| 77 | |
Xiaoqian Dai | 1067eab | 2020-06-03 22:20:33 | [diff] [blame] | 78 | // Returns true if |window| allows default touch behaviors. If false, it means |
| 79 | // no default touch behavior is allowed (i.e., the touch action of window is |
| 80 | // cc::TouchAction::kNone). This function is used by BackGestureEventHandler |
| 81 | // to decide if we can perform the system default back gesture. |
| 82 | virtual bool AllowDefaultTouchActions(gfx::NativeWindow window); |
| 83 | |
| 84 | // Returns true if we should wait for touch press ack when deciding if back |
| 85 | // gesture can be performed. |
| 86 | virtual bool ShouldWaitForTouchPressAck(gfx::NativeWindow window); |
| 87 | |
Collin Baker | e5fb2f69 | 2020-05-14 01:24:44 | [diff] [blame] | 88 | // Checks whether a drag-drop operation is a tab drag. |
| 89 | virtual bool IsTabDrag(const ui::OSExchangeData& drop_data); |
| 90 | |
| 91 | // Drops tab in a new browser window. |drop_data| must be from a tab |
| 92 | // drag as determined by IsTabDrag() above. |
Collin Baker | aec4387 | 2020-05-07 20:28:57 | [diff] [blame] | 93 | virtual aura::Window* CreateBrowserForTabDrop( |
| 94 | aura::Window* source_window, |
| 95 | const ui::OSExchangeData& drop_data); |
Collin Baker | 1ca0b7a3 | 2020-04-14 18:33:00 | [diff] [blame] | 96 | |
Ken Rockot | b9bab54 | 2019-12-12 00:53:30 | [diff] [blame] | 97 | // Binds a BluetoothSystemFactory receiver if possible. |
| 98 | virtual void BindBluetoothSystemFactory( |
| 99 | mojo::PendingReceiver<device::mojom::BluetoothSystemFactory> receiver) {} |
| 100 | |
| 101 | // Binds a fingerprint receiver in the Device Service if possible. |
| 102 | virtual void BindFingerprint( |
| 103 | mojo::PendingReceiver<device::mojom::Fingerprint> receiver) {} |
| 104 | |
Ken Rockot | 6b5017e | 2019-12-05 20:39:41 | [diff] [blame] | 105 | // Binds a MultiDeviceSetup receiver for the primary profile. |
| 106 | virtual void BindMultiDeviceSetup( |
| 107 | mojo::PendingReceiver< |
| 108 | chromeos::multidevice_setup::mojom::MultiDeviceSetup> receiver) = 0; |
| 109 | |
Ken Rockot | b2ac2f1 | 2019-12-06 18:33:54 | [diff] [blame] | 110 | // Returns an interface to the Media Session service, or null if not |
| 111 | // available. |
Becca Hughes | c742784 | 2020-11-04 23:27:38 | [diff] [blame] | 112 | virtual media_session::MediaSessionService* GetMediaSessionService(); |
Ken Rockot | b2ac2f1 | 2019-12-06 18:33:54 | [diff] [blame] | 113 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 114 | virtual void OpenKeyboardShortcutHelpPage() const {} |
Cattalyya Nuengsigkapian | 8c45e30 | 2021-01-06 21:48:08 | [diff] [blame] | 115 | |
| 116 | // Returns if window browser sessions are restoring. |
| 117 | virtual bool IsSessionRestoreInProgress() const = 0; |
Alexander Alekseev | 494b2d3 | 2021-01-20 06:16:43 | [diff] [blame] | 118 | |
| 119 | // Ui Dev Tools control. |
| 120 | virtual bool IsUiDevToolsStarted() const; |
| 121 | virtual void StartUiDevTools() {} |
| 122 | virtual void StopUiDevTools() {} |
| 123 | virtual int GetUiDevToolsPort() const; |
Alexander Alekseev | 2b4c959 | 2021-05-04 22:26:44 | [diff] [blame] | 124 | |
| 125 | // Returns true if Chrome was started with --disable-logging-redirect option. |
| 126 | virtual bool IsLoggingRedirectDisabled() const = 0; |
| 127 | |
Xiaoqian Dai | e26ad850 | 2021-06-17 00:33:45 | [diff] [blame] | 128 | // 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] | 129 | // primary user Downloads folder if user has already logged in. |
| 130 | virtual base::FilePath GetPrimaryUserDownloadsFolder() const = 0; |
Xiaoqian Dai | e26ad850 | 2021-06-17 00:33:45 | [diff] [blame] | 131 | |
minch | 3453ad1 | 2021-06-21 18:25:11 | [diff] [blame] | 132 | // Opens the feedback page with pre-populated description #BentoBar for |
| 133 | // persistent desks bar. Note, this will be removed once the feature is fully |
| 134 | // launched or removed. |
| 135 | virtual void OpenFeedbackPageForPersistentDesksBar() = 0; |
Xiaoqian Dai | 87b325b | 2021-06-22 02:18:11 | [diff] [blame] | 136 | |
| 137 | // Returns the app launch data that's associated with a particular |window| in |
| 138 | // order to construct a desk template. Return nullptr if no such app launch |
| 139 | // data can be constructed, which can happen if the |window| does not have |
| 140 | // an app id associated with it, or we're not in the primary active user |
| 141 | // session. |
| 142 | virtual std::unique_ptr<full_restore::AppLaunchInfo> |
| 143 | GetAppLaunchDataForDeskTemplate(aura::Window* window) const = 0; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | } // namespace ash |
| 147 | |
| 148 | #endif // ASH_SHELL_DELEGATE_H_ |