blob: 8cea02d6fad62259866ff66527136c90192fb813 [file] [log] [blame]
James Cookb0bf8e82017-04-09 17:01:441// 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
15class GURL;
afakhry15eb9282017-04-27 04:03:3116class PrefService;
James Cookb0bf8e82017-04-09 17:01:4417
varkhad43f55242017-05-26 20:55:5818namespace aura {
19class Window;
20}
21
James Cookb0bf8e82017-04-09 17:01:4422namespace gfx {
23class Image;
24}
25
26namespace keyboard {
27class KeyboardUI;
28}
29
30namespace service_manager {
31class Connector;
32}
33
34namespace ui {
Scott Violet17a61722017-06-19 17:54:3135#if defined(USE_OZONE)
36class InputDeviceControllerClient;
37#endif
James Cookb0bf8e82017-04-09 17:01:4438class MenuModel;
39}
40
41namespace ash {
42
43class AccessibilityDelegate;
44class GPUSupport;
James Cookb0bf8e82017-04-09 17:01:4445class PaletteDelegate;
James Cook840177e2017-05-25 02:20:0146class Shelf;
James Cookb0bf8e82017-04-09 17:01:4447struct ShelfItem;
James Cook840177e2017-05-25 02:20:0148class SystemTrayDelegate;
James Cookb0bf8e82017-04-09 17:01:4449class WallpaperDelegate;
James Cookb0bf8e82017-04-09 17:01:4450
51// Delegate of the Shell.
52class 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.
varkhad43f55242017-05-26 20:55:5872 virtual bool CanShowWindowForUser(aura::Window* window) const = 0;
James Cookb0bf8e82017-04-09 17:01:4473
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
yhanada8909a542017-07-11 10:06:1990 // Create a shell-specific keyboard::KeyboardUI.
91 virtual std::unique_ptr<keyboard::KeyboardUI> CreateKeyboardUI() = 0;
James Cookb0bf8e82017-04-09 17:01:4492
93 // Opens the |url| in a new browser tab.
94 virtual void OpenUrlFromArc(const GURL& url) = 0;
95
msw5138f3d2017-04-20 00:22:0796 // Functions called when the shelf is initialized and shut down.
msw5c06364c2017-04-27 02:49:0697 // TODO(msw): Refine ChromeLauncherController lifetime management.
msw5138f3d2017-04-20 00:22:0798 virtual void ShelfInit() = 0;
99 virtual void ShelfShutdown() = 0;
James Cookb0bf8e82017-04-09 17:01:44100
101 // Creates a system-tray delegate. Shell takes ownership of the delegate.
102 virtual SystemTrayDelegate* CreateSystemTrayDelegate() = 0;
103
James Cookb0bf8e82017-04-09 17:01:44104 // Creates a wallpaper delegate. Shell takes ownership of the delegate.
105 virtual std::unique_ptr<WallpaperDelegate> CreateWallpaperDelegate() = 0;
106
James Cookb0bf8e82017-04-09 17:01:44107 // 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 Cook840177e2017-05-25 02:20:01112 // Creates a menu model for the |shelf| and optional shelf |item|.
James Cookb0bf8e82017-04-09 17:01:44113 // If |item| is null, this creates a context menu for the wallpaper or shelf.
James Cook840177e2017-05-25 02:20:01114 virtual ui::MenuModel* CreateContextMenu(Shelf* shelf,
James Cookb0bf8e82017-04-09 17:01:44115 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
afakhry15eb9282017-04-27 04:03:31127 virtual PrefService* GetActiveUserPrefService() const = 0;
128
Wenzhao Zang44240fb2017-07-13 01:36:54129 virtual PrefService* GetLocalStatePrefService() const = 0;
130
James Cookb0bf8e82017-04-09 17:01:44131 // 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() {}
warx67a6d3f2017-05-31 21:00:21146
147 // Suspends all WebContents-associated media sessions to stop managed players.
148 virtual void SuspendMediaSessions() {}
Scott Violet17a61722017-06-19 17:54:31149
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 Cookb0bf8e82017-04-09 17:01:44154};
155
156} // namespace ash
157
158#endif // ASH_SHELL_DELEGATE_H_