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 UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
6 #define UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
11 #include "base/callback_forward.h"
12 #include "base/files/file_path.h"
13 #include "base/strings/string16.h"
14 #include "base/time/time.h"
15 #include "ui/app_list/app_list_export.h"
26 #if defined(TOOLKIT_VIEWS)
35 class AppListViewDelegateObserver
;
39 class APP_LIST_EXPORT AppListViewDelegate
{
41 // A user of the app list.
42 struct APP_LIST_EXPORT User
{
46 // Whether or not this user is the current user of the app list.
49 // The name of this user.
52 // The email address of this user.
55 // The path to this user's profile directory.
56 base::FilePath profile_path
;
58 typedef std::vector
<User
> Users
;
60 virtual ~AppListViewDelegate() {}
62 // Whether to force the use of a native desktop widget when the app list
63 // window is first created.
64 virtual bool ForceNativeDesktop() const = 0;
66 // Sets the delegate to use the profile at |profile_path|. This is currently
67 // only used by non-Ash Windows.
68 virtual void SetProfileByPath(const base::FilePath
& profile_path
) = 0;
70 // Gets the model associated with the view delegate. The model may be owned
71 // by the delegate, or owned elsewhere (e.g. a profile keyed service).
72 virtual AppListModel
* GetModel() = 0;
74 // Gets the SpeechUIModel for the app list. Owned by the AppListViewDelegate.
75 virtual SpeechUIModel
* GetSpeechUI() = 0;
77 // Gets a path to a shortcut for the given app. Returns asynchronously as the
78 // shortcut may not exist yet.
79 virtual void GetShortcutPathForApp(
80 const std::string
& app_id
,
81 const base::Callback
<void(const base::FilePath
&)>& callback
) = 0;
83 // Invoked to start a new search. Delegate collects query input from
84 // SearchBoxModel and populates SearchResults. Both models are sub models
86 virtual void StartSearch() = 0;
88 // Invoked to stop the current search.
89 virtual void StopSearch() = 0;
91 // Invoked to open the search result.
92 virtual void OpenSearchResult(SearchResult
* result
,
96 // Called to invoke a custom action on |result|. |action_index| corresponds
97 // to the index of an icon in |result.action_icons()|.
98 virtual void InvokeSearchResultAction(SearchResult
* result
,
100 int event_flags
) = 0;
102 // Gets the timeout for auto-launching the first search result, or 0 if the
103 // auto-launch should not happen for the current search session.
104 virtual base::TimeDelta
GetAutoLaunchTimeout() = 0;
106 // Invoked when the auto-launch is canceled by the user action.
107 virtual void AutoLaunchCanceled() = 0;
109 // Invoked when the app list UI is created.
110 virtual void ViewInitialized() = 0;
112 // Invoked to dismiss app list. This may leave the view open but hidden from
114 virtual void Dismiss() = 0;
116 // Invoked when the app list is closing.
117 virtual void ViewClosing() = 0;
119 // Returns the icon to be displayed in the window and taskbar.
120 virtual gfx::ImageSkia
GetWindowIcon() = 0;
122 // Open the settings UI.
123 virtual void OpenSettings() = 0;
126 virtual void OpenHelp() = 0;
128 // Open the feedback UI.
129 virtual void OpenFeedback() = 0;
131 // Invoked to toggle the status of speech recognition.
132 virtual void ToggleSpeechRecognition() = 0;
134 // Shows the app list for the profile specified by |profile_path|.
135 virtual void ShowForProfileByPath(const base::FilePath
& profile_path
) = 0;
137 #if defined(TOOLKIT_VIEWS)
138 // Creates the web view for the start page. The caller takes the ownership of
139 // the returned view.
140 virtual views::View
* CreateStartPageWebView(const gfx::Size
& size
) = 0;
142 // Creates the web views for the user-specified custom pages. The caller takes
143 // ownership of the returned views.
144 virtual std::vector
<views::View
*> CreateCustomPageWebViews(
145 const gfx::Size
& size
) = 0;
147 // Invoked when the custom launcher page's animation changes.
148 virtual void CustomLauncherPageAnimationChanged(double progress
) = 0;
150 // Invoked when the custom launcher page's subpage should be popped.
151 virtual void CustomLauncherPagePopSubpage() = 0;
154 // Returns true if the delegate supports speech recognition.
155 virtual bool IsSpeechRecognitionEnabled() = 0;
157 // Returns the list of users (for AppListMenu).
158 virtual const Users
& GetUsers() const = 0;
160 // Returns true if the app list should be centered and in landscape mode.
161 virtual bool ShouldCenterWindow() const = 0;
163 // Adds/removes an observer for profile changes.
164 virtual void AddObserver(AppListViewDelegateObserver
* observer
) {}
165 virtual void RemoveObserver(AppListViewDelegateObserver
* observer
) {}
168 } // namespace app_list
170 #endif // UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_