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.
5 #ifndef ASH_SHELL_DELEGATE_H_
6 #define ASH_SHELL_DELEGATE_H_
10 #include "ash/ash_export.h"
11 #include "ash/shell.h"
12 #include "base/callback.h"
13 #include "base/string16.h"
14 #include "base/time.h"
17 class AppListViewDelegate
;
24 class UserActionClient
;
38 class CapsLockDelegate
;
39 class LauncherDelegate
;
42 class SystemTrayDelegate
;
43 class UserWallpaperDelegate
;
45 enum UserMetricsAction
{
46 UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6
,
47 UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7
,
48 UMA_ACCEL_MAXIMIZE_RESTORE_F4
,
50 UMA_ACCEL_NEXTWINDOW_F5
,
51 UMA_ACCEL_NEXTWINDOW_TAB
,
52 UMA_ACCEL_PREVWINDOW_F5
,
53 UMA_ACCEL_PREVWINDOW_TAB
,
54 UMA_ACCEL_SEARCH_LWIN
,
55 UMA_LAUNCHER_CLICK_ON_APP
,
56 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON
,
58 UMA_TOUCHSCREEN_TAP_DOWN
,
61 // Delegate of the Shell.
62 class ASH_EXPORT ShellDelegate
{
64 // The Shell owns the delegate.
65 virtual ~ShellDelegate() {}
67 // Returns true if user has logged in.
68 virtual bool IsUserLoggedIn() = 0;
70 // Returns true if we're logged in and browser has been started
71 virtual bool IsSessionStarted() = 0;
73 // Returns true if this is the first time that the shell has been run after
74 // the system has booted. false is returned after the shell has been
75 // restarted, typically due to logging in as a guest or logging out.
76 virtual bool IsFirstRunAfterBoot() = 0;
78 // Invoked when a user locks the screen.
79 virtual void LockScreen() = 0;
81 // Unlock the screen. Currently used only for tests.
82 virtual void UnlockScreen() = 0;
84 // Returns true if the screen is currently locked.
85 virtual bool IsScreenLocked() const = 0;
87 // Shuts down the environment.
88 virtual void Shutdown() = 0;
90 // Invoked when the user uses Ctrl-Shift-Q to close chrome.
91 virtual void Exit() = 0;
93 // Invoked when the user uses Ctrl+T to open a new tab.
94 virtual void NewTab() = 0;
96 // Invoked when the user uses Ctrl-N or Ctrl-Shift-N to open a new window.
97 virtual void NewWindow(bool incognito
) = 0;
99 // Invoked when the user uses F4 to toggle window maximized state.
100 virtual void ToggleMaximized() = 0;
102 // Invoked when the user uses Ctrl-M or Ctrl-O to open file manager.
103 virtual void OpenFileManager(bool as_dialog
) = 0;
105 // Invoked when the user opens Crosh.
106 virtual void OpenCrosh() = 0;
108 // Invoked when the user needs to set up mobile networking.
109 virtual void OpenMobileSetup(const std::string
& service_path
) = 0;
111 // Invoked when the user uses Shift+Ctrl+T to restore the closed tab.
112 virtual void RestoreTab() = 0;
114 // Moves keyboard focus to the next pane. Returns false if no browser window
116 virtual bool RotatePaneFocus(Shell::Direction direction
) = 0;
118 // Shows the keyboard shortcut overlay.
119 virtual void ShowKeyboardOverlay() = 0;
121 // Shows the task manager window.
122 virtual void ShowTaskManager() = 0;
124 // Get the current browser context. This will get us the current profile.
125 virtual content::BrowserContext
* GetCurrentBrowserContext() = 0;
127 // Invoked when the user presses a shortcut to toggle spoken feedback
128 // for accessibility.
129 virtual void ToggleSpokenFeedback() = 0;
131 // Returns true if spoken feedback is enabled.
132 virtual bool IsSpokenFeedbackEnabled() const = 0;
134 // Invoked to create an AppListViewDelegate. Shell takes the ownership of
135 // the created delegate.
136 virtual app_list::AppListViewDelegate
* CreateAppListViewDelegate() = 0;
138 // Creates a new LauncherDelegate. Shell takes ownership of the returned
140 virtual LauncherDelegate
* CreateLauncherDelegate(
141 ash::LauncherModel
* model
) = 0;
143 // Creates a system-tray delegate. Shell takes ownership of the delegate.
144 virtual SystemTrayDelegate
* CreateSystemTrayDelegate() = 0;
146 // Creates a user wallpaper delegate. Shell takes ownership of the delegate.
147 virtual UserWallpaperDelegate
* CreateUserWallpaperDelegate() = 0;
149 // Creates a caps lock delegate. Shell takes ownership of the delegate.
150 virtual CapsLockDelegate
* CreateCapsLockDelegate() = 0;
152 // Creates a user action client. Shell takes ownership of the object.
153 virtual aura::client::UserActionClient
* CreateUserActionClient() = 0;
155 // Opens the feedback page for "Report Issue".
156 virtual void OpenFeedbackPage() = 0;
158 // Records that the user performed an action.
159 virtual void RecordUserMetricsAction(UserMetricsAction action
) = 0;
161 // Handles the Next Track Media shortcut key.
162 virtual void HandleMediaNextTrack() = 0;
164 // Handles the Play/Pause Toggle Media shortcut key.
165 virtual void HandleMediaPlayPause() = 0;
167 // Handles the Previous Track Media shortcut key.
168 virtual void HandleMediaPrevTrack() = 0;
170 // Produces l10n-ed text of remaining time, e.g.: "13 mins left" or
171 // "13 Minuten übrig".
172 // Used, for example, to display the remaining battery life.
173 virtual string16
GetTimeRemainingString(base::TimeDelta delta
) = 0;
175 // Saves the zoom scale of the full screen magnifier.
176 virtual void SaveScreenMagnifierScale(double scale
) = 0;
178 // Gets a saved value of the zoom scale of full screen magnifier. If a value
179 // is not saved, return a negative value.
180 virtual double GetSavedScreenMagnifierScale() = 0;
182 // Creates a menu model of the context for the |root_window|.
183 virtual ui::MenuModel
* CreateContextMenu(aura::RootWindow
* root_window
) = 0;
188 #endif // ASH_SHELL_DELEGATE_H_