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> |
| 10 | |
| 11 | #include "ash/ash_export.h" |
| 12 | #include "base/callback.h" |
| 13 | #include "base/strings/string16.h" |
| 14 | |
| 15 | class GURL; |
afakhry | 15eb928 | 2017-04-27 04:03:31 | [diff] [blame] | 16 | class PrefService; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 17 | |
varkha | d43f5524 | 2017-05-26 20:55:58 | [diff] [blame] | 18 | namespace aura { |
| 19 | class Window; |
| 20 | } |
| 21 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 22 | namespace gfx { |
| 23 | class Image; |
| 24 | } |
| 25 | |
| 26 | namespace keyboard { |
| 27 | class KeyboardUI; |
| 28 | } |
| 29 | |
| 30 | namespace service_manager { |
| 31 | class Connector; |
| 32 | } |
| 33 | |
| 34 | namespace ui { |
Scott Violet | 17a6172 | 2017-06-19 17:54:31 | [diff] [blame] | 35 | #if defined(USE_OZONE) |
| 36 | class InputDeviceControllerClient; |
| 37 | #endif |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 38 | class MenuModel; |
| 39 | } |
| 40 | |
| 41 | namespace ash { |
| 42 | |
| 43 | class AccessibilityDelegate; |
| 44 | class GPUSupport; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 45 | class PaletteDelegate; |
James Cook | 840177e | 2017-05-25 02:20:01 | [diff] [blame] | 46 | class Shelf; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 47 | struct ShelfItem; |
James Cook | 840177e | 2017-05-25 02:20:01 | [diff] [blame] | 48 | class SystemTrayDelegate; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 49 | class WallpaperDelegate; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 50 | |
| 51 | // Delegate of the Shell. |
| 52 | class ASH_EXPORT ShellDelegate { |
| 53 | public: |
| 54 | // The Shell owns the delegate. |
| 55 | virtual ~ShellDelegate() {} |
| 56 | |
| 57 | // Returns the connector for the mojo service manager. Returns null in tests. |
| 58 | virtual service_manager::Connector* GetShellConnector() const = 0; |
| 59 | |
| 60 | // Returns true if multi-profiles feature is enabled. |
| 61 | virtual bool IsMultiProfilesEnabled() const = 0; |
| 62 | |
| 63 | // Returns true if incognito mode is allowed for the user. |
| 64 | // Incognito windows are restricted for supervised users. |
| 65 | virtual bool IsIncognitoAllowed() const = 0; |
| 66 | |
| 67 | // Returns true if we're running in forced app mode. |
| 68 | virtual bool IsRunningInForcedAppMode() const = 0; |
| 69 | |
| 70 | // Returns true if |window| can be shown for the delegate's concept of current |
| 71 | // user. |
varkha | d43f5524 | 2017-05-26 20:55:58 | [diff] [blame] | 72 | virtual bool CanShowWindowForUser(aura::Window* window) const = 0; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 73 | |
| 74 | // Returns true if the first window shown on first run should be |
| 75 | // unconditionally maximized, overriding the heuristic that normally chooses |
| 76 | // the window size. |
| 77 | virtual bool IsForceMaximizeOnFirstRun() const = 0; |
| 78 | |
| 79 | // Called before processing |Shell::Init()| so that the delegate |
| 80 | // can perform tasks necessary before the shell is initialized. |
| 81 | virtual void PreInit() = 0; |
| 82 | |
| 83 | // Called at the beginninig of Shell destructor so that |
| 84 | // delegate can use Shell instance to perform cleanup tasks. |
| 85 | virtual void PreShutdown() = 0; |
| 86 | |
| 87 | // Invoked when the user uses Ctrl-Shift-Q to close chrome. |
| 88 | virtual void Exit() = 0; |
| 89 | |
yhanada | 8909a54 | 2017-07-11 10:06:19 | [diff] [blame] | 90 | // Create a shell-specific keyboard::KeyboardUI. |
| 91 | virtual std::unique_ptr<keyboard::KeyboardUI> CreateKeyboardUI() = 0; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 92 | |
| 93 | // Opens the |url| in a new browser tab. |
| 94 | virtual void OpenUrlFromArc(const GURL& url) = 0; |
| 95 | |
msw | 5138f3d | 2017-04-20 00:22:07 | [diff] [blame] | 96 | // Functions called when the shelf is initialized and shut down. |
msw | 5c06364c | 2017-04-27 02:49:06 | [diff] [blame] | 97 | // TODO(msw): Refine ChromeLauncherController lifetime management. |
msw | 5138f3d | 2017-04-20 00:22:07 | [diff] [blame] | 98 | virtual void ShelfInit() = 0; |
| 99 | virtual void ShelfShutdown() = 0; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 100 | |
| 101 | // Creates a system-tray delegate. Shell takes ownership of the delegate. |
| 102 | virtual SystemTrayDelegate* CreateSystemTrayDelegate() = 0; |
| 103 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 104 | // Creates a wallpaper delegate. Shell takes ownership of the delegate. |
| 105 | virtual std::unique_ptr<WallpaperDelegate> CreateWallpaperDelegate() = 0; |
| 106 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 107 | // Creates a accessibility delegate. Shell takes ownership of the delegate. |
| 108 | virtual AccessibilityDelegate* CreateAccessibilityDelegate() = 0; |
| 109 | |
| 110 | virtual std::unique_ptr<PaletteDelegate> CreatePaletteDelegate() = 0; |
| 111 | |
James Cook | 840177e | 2017-05-25 02:20:01 | [diff] [blame] | 112 | // Creates a menu model for the |shelf| and optional shelf |item|. |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 113 | // If |item| is null, this creates a context menu for the wallpaper or shelf. |
James Cook | 840177e | 2017-05-25 02:20:01 | [diff] [blame] | 114 | virtual ui::MenuModel* CreateContextMenu(Shelf* shelf, |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 115 | const ShelfItem* item) = 0; |
| 116 | |
| 117 | // Creates a GPU support object. Shell takes ownership of the object. |
| 118 | virtual GPUSupport* CreateGPUSupport() = 0; |
| 119 | |
| 120 | // Get the product name. |
| 121 | virtual base::string16 GetProductName() const = 0; |
| 122 | |
| 123 | virtual void OpenKeyboardShortcutHelpPage() const {} |
| 124 | |
| 125 | virtual gfx::Image GetDeprecatedAcceleratorImage() const = 0; |
| 126 | |
afakhry | 15eb928 | 2017-04-27 04:03:31 | [diff] [blame] | 127 | virtual PrefService* GetActiveUserPrefService() const = 0; |
| 128 | |
Wenzhao Zang | 44240fb | 2017-07-13 01:36:54 | [diff] [blame] | 129 | virtual PrefService* GetLocalStatePrefService() const = 0; |
| 130 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 131 | // If |use_local_state| is true, returns the touchscreen status from local |
| 132 | // state, otherwise from user prefs. |
| 133 | virtual bool IsTouchscreenEnabledInPrefs(bool use_local_state) const = 0; |
| 134 | |
| 135 | // Sets the status of touchscreen to |enabled| in prefs. If |use_local_state|, |
| 136 | // pref is set in local state, otherwise in user prefs. |
| 137 | virtual void SetTouchscreenEnabledInPrefs(bool enabled, |
| 138 | bool use_local_state) = 0; |
| 139 | |
| 140 | // Updates the enabled/disabled status of the touchscreen from prefs. Enabled |
| 141 | // if both local state and user prefs are enabled, otherwise disabled. |
| 142 | virtual void UpdateTouchscreenStatusFromPrefs() = 0; |
| 143 | |
| 144 | // Toggles the status of touchpad between enabled and disabled. |
| 145 | virtual void ToggleTouchpad() {} |
warx | 67a6d3f | 2017-05-31 21:00:21 | [diff] [blame] | 146 | |
| 147 | // Suspends all WebContents-associated media sessions to stop managed players. |
| 148 | virtual void SuspendMediaSessions() {} |
Scott Violet | 17a6172 | 2017-06-19 17:54:31 | [diff] [blame] | 149 | |
| 150 | #if defined(USE_OZONE) |
| 151 | // Creator of Shell owns this; it's assumed this outlives Shell. |
| 152 | virtual ui::InputDeviceControllerClient* GetInputDeviceControllerClient() = 0; |
| 153 | #endif |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | } // namespace ash |
| 157 | |
| 158 | #endif // ASH_SHELL_DELEGATE_H_ |