1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_SHELL_DELEGATE_H_
6 #define ASH_SHELL_DELEGATE_H_
11 #include "ash/ash_export.h"
12 #include "base/files/file_path.h"
13 #include "chromeos/ash/services/multidevice_setup/public/mojom/multidevice_setup.mojom-forward.h"
14 #include "chromeos/ui/base/window_pin_type.h"
15 #include "components/version_info/channel.h"
16 #include "mojo/public/cpp/bindings/pending_receiver.h"
17 #include "services/device/public/mojom/fingerprint.mojom-forward.h"
18 #include "services/media_session/public/cpp/media_session_service.h"
19 #include "services/network/public/cpp/shared_url_loader_factory.h"
20 #include "services/video_capture/public/mojom/multi_capture_service.mojom-forward.h"
21 #include "ui/gfx/native_widget_types.h"
34 class AcceleratorPrefsDelegate;
35 class AccessibilityDelegate;
36 class BackGestureContextualNudgeController;
37 class BackGestureContextualNudgeDelegate;
38 class CaptureModeDelegate;
39 class ClipboardHistoryControllerDelegate;
40 class GameDashboardDelegate;
41 class MediaNotificationProvider;
42 class NearbyShareController;
43 class NearbyShareDelegate;
44 class SavedDeskDelegate;
45 class SystemSoundsDelegate;
46 class UserEducationDelegate;
49 // Delegate of the Shell.
50 class ASH_EXPORT ShellDelegate {
52 enum class FeedbackSource {
57 // The Shell owns the delegate.
58 virtual ~ShellDelegate() = default;
60 // Returns true if |window| can be shown for the delegate's concept of current
62 virtual bool CanShowWindowForUser(const aura::Window* window) const = 0;
64 // Creates and returns the delegate of the Capture Mode feature.
65 virtual std::unique_ptr<CaptureModeDelegate> CreateCaptureModeDelegate()
68 // Creates and returns the delegate of the clipboard history feature.
69 virtual std::unique_ptr<ClipboardHistoryControllerDelegate>
70 CreateClipboardHistoryControllerDelegate() const = 0;
72 // Creates and returns the delegate of the Game Dashboard feature.
73 virtual std::unique_ptr<GameDashboardDelegate> CreateGameDashboardDelegate()
76 // Creates a accelerator_prefs_delegate.
77 virtual std::unique_ptr<AcceleratorPrefsDelegate>
78 CreateAcceleratorPrefsDelegate() const = 0;
80 // Creates a accessibility delegate. Shell takes ownership of the delegate.
81 virtual AccessibilityDelegate* CreateAccessibilityDelegate() = 0;
83 // Creates a back gesture contextual nudge delegate for |controller|.
84 virtual std::unique_ptr<BackGestureContextualNudgeDelegate>
85 CreateBackGestureContextualNudgeDelegate(
86 BackGestureContextualNudgeController* controller) = 0;
88 virtual std::unique_ptr<MediaNotificationProvider>
89 CreateMediaNotificationProvider() = 0;
91 virtual std::unique_ptr<NearbyShareDelegate> CreateNearbyShareDelegate(
92 NearbyShareController* controller) const = 0;
94 virtual std::unique_ptr<SavedDeskDelegate> CreateSavedDeskDelegate()
97 // Creates and returns the delegate of the System Sounds feature.
98 virtual std::unique_ptr<SystemSoundsDelegate> CreateSystemSoundsDelegate()
101 // Creates and returns the delegate for user education features.
102 virtual std::unique_ptr<UserEducationDelegate> CreateUserEducationDelegate()
105 // Returns the geolocation loader factory used to initialize geolocation
107 virtual scoped_refptr<network::SharedURLLoaderFactory>
108 GetGeolocationUrlLoaderFactory() const = 0;
110 // Check whether the current tab of the browser window can go back.
111 virtual bool CanGoBack(gfx::NativeWindow window) const = 0;
113 // Sets the tab scrubber |enabled_| field to |enabled|.
114 virtual void SetTabScrubberChromeOSEnabled(bool enabled) = 0;
116 // Returns true if |window| allows default touch behaviors. If false, it means
117 // no default touch behavior is allowed (i.e., the touch action of window is
118 // cc::TouchAction::kNone). This function is used by BackGestureEventHandler
119 // to decide if we can perform the system default back gesture.
120 virtual bool AllowDefaultTouchActions(gfx::NativeWindow window);
122 // Returns true if we should wait for touch press ack when deciding if back
123 // gesture can be performed.
124 virtual bool ShouldWaitForTouchPressAck(gfx::NativeWindow window);
126 // Checks whether a drag-drop operation is a tab drag.
127 virtual bool IsTabDrag(const ui::OSExchangeData& drop_data);
129 // Return the height of WebUI tab strip used to determine if a tab has
130 // dragged out of it.
131 virtual int GetBrowserWebUITabStripHeight() = 0;
133 // Binds a fingerprint receiver in the Device Service if possible.
134 virtual void BindFingerprint(
135 mojo::PendingReceiver<device::mojom::Fingerprint> receiver) {}
137 // Binds a MultiDeviceSetup receiver for the primary profile.
138 virtual void BindMultiDeviceSetup(
139 mojo::PendingReceiver<multidevice_setup::mojom::MultiDeviceSetup>
142 // Binds a MultiCaptureService receiver to start observing
143 // MultiCaptureStarted() and MultiCaptureStopped() events.
144 virtual void BindMultiCaptureService(
145 mojo::PendingReceiver<video_capture::mojom::MultiCaptureService>
148 // Returns an interface to the Media Session service, or null if not
150 virtual media_session::MediaSessionService* GetMediaSessionService();
152 virtual void OpenKeyboardShortcutHelpPage() const {}
154 // Returns if window browser sessions are restoring.
155 virtual bool IsSessionRestoreInProgress() const = 0;
157 // Adjust system configuration for a Locked Fullscreen window.
158 virtual void SetUpEnvironmentForLockedFullscreen(
159 const WindowState& window_state) = 0;
161 // Ui Dev Tools control.
162 virtual bool IsUiDevToolsStarted() const;
163 virtual void StartUiDevTools() {}
164 virtual void StopUiDevTools() {}
165 virtual int GetUiDevToolsPort() const;
167 // Returns true if Chrome was started with --disable-logging-redirect option.
168 virtual bool IsLoggingRedirectDisabled() const = 0;
170 // Returns empty path if user session has not started yet, or path to the
171 // primary user Downloads folder if user has already logged in.
172 virtual base::FilePath GetPrimaryUserDownloadsFolder() const = 0;
174 // Opens the feedback page with pre-populated `source` and
175 // `description_template` fields. Note, this will only be used by features
176 // before they are fully launched or removed.
177 virtual void OpenFeedbackDialog(FeedbackSource source,
178 const std::string& description_template) = 0;
180 // Returns the last committed URL from the web contents if the given |window|
181 // contains a browser frame, otherwise returns GURL::EmptyURL().
182 virtual const GURL& GetLastCommittedURLForWindowIfAny(aura::Window* window);
184 // Retrieves the release track on which the device resides.
185 virtual version_info::Channel GetChannel() = 0;
187 // Tells browsers not to ask the user to confirm that they want to close a
188 // window when that window is closed.
189 virtual void ForceSkipWarningUserOnClose(
190 const std::vector<aura::Window*>& windows) = 0;
192 // Retrieves the official Chrome version string e.g. 105.0.5178.0.
193 virtual std::string GetVersionString() = 0;
195 // Forwards the ShouldExitFullscreenBeforeLock() call to the crosapi browser
197 using ShouldExitFullscreenCallback = base::OnceCallback<void(bool)>;
198 virtual void ShouldExitFullscreenBeforeLock(
199 ShouldExitFullscreenCallback callback);
204 #endif // ASH_SHELL_DELEGATE_H_