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 // AppListView owns the delegate.
61 virtual ~AppListViewDelegate() {}
63 // Whether to force the use of a native desktop widget when the app list
64 // window is first created.
65 virtual bool ForceNativeDesktop() const = 0;
67 // Sets the delegate to use the profile at |profile_path|. This is currently
68 // only used by non-Ash Windows.
69 virtual void SetProfileByPath(const base::FilePath
& profile_path
) = 0;
71 // Gets the model associated with the view delegate. The model may be owned
72 // by the delegate, or owned elsewhere (e.g. a profile keyed service).
73 virtual AppListModel
* GetModel() = 0;
75 // Gets the SpeechUIModel for the app list. Owned by the AppListViewDelegate.
76 virtual SpeechUIModel
* GetSpeechUI() = 0;
78 // Gets a path to a shortcut for the given app. Returns asynchronously as the
79 // shortcut may not exist yet.
80 virtual void GetShortcutPathForApp(
81 const std::string
& app_id
,
82 const base::Callback
<void(const base::FilePath
&)>& callback
) = 0;
84 // Invoked to start a new search. Delegate collects query input from
85 // SearchBoxModel and populates SearchResults. Both models are sub models
87 virtual void StartSearch() = 0;
89 // Invoked to stop the current search.
90 virtual void StopSearch() = 0;
92 // Invoked to open the search result.
93 virtual void OpenSearchResult(SearchResult
* result
,
97 // Called to invoke a custom action on |result|. |action_index| corresponds
98 // to the index of an icon in |result.action_icons()|.
99 virtual void InvokeSearchResultAction(SearchResult
* result
,
101 int event_flags
) = 0;
103 // Gets the timeout for auto-launching the first search result, or 0 if the
104 // auto-launch should not happen for the current search session.
105 virtual base::TimeDelta
GetAutoLaunchTimeout() = 0;
107 // Invoked when the auto-launch is canceled by the user action.
108 virtual void AutoLaunchCanceled() = 0;
110 // Invoked when the app list UI is created.
111 virtual void ViewInitialized() = 0;
113 // Invoked to dismiss app list. This may leave the view open but hidden from
115 virtual void Dismiss() = 0;
117 // Invoked when the app list is closing.
118 virtual void ViewClosing() = 0;
120 // Returns the icon to be displayed in the window and taskbar.
121 virtual gfx::ImageSkia
GetWindowIcon() = 0;
123 // Open the settings UI.
124 virtual void OpenSettings() = 0;
127 virtual void OpenHelp() = 0;
129 // Open the feedback UI.
130 virtual void OpenFeedback() = 0;
132 // Invoked to toggle the status of speech recognition.
133 virtual void ToggleSpeechRecognition() = 0;
135 // Shows the app list for the profile specified by |profile_path|.
136 virtual void ShowForProfileByPath(const base::FilePath
& profile_path
) = 0;
138 #if defined(TOOLKIT_VIEWS)
139 // Creates the web view for the start page. The caller takes the ownership of
140 // the returned view.
141 virtual views::View
* CreateStartPageWebView(const gfx::Size
& size
) = 0;
144 // Returns true if the delegate supports speech recognition.
145 virtual bool IsSpeechRecognitionEnabled() = 0;
147 // Returns the list of users (for AppListMenu).
148 virtual const Users
& GetUsers() const = 0;
150 // Returns true if the app list should be centered and in landscape mode.
151 virtual bool ShouldCenterWindow() const = 0;
153 // Adds/removes an observer for profile changes.
154 virtual void AddObserver(AppListViewDelegateObserver
* observer
) {}
155 virtual void RemoveObserver(AppListViewDelegateObserver
* observer
) {}
158 } // namespace app_list
160 #endif // UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_