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 UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ 6 #define UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ 7 8 #include <string> 9 #include <vector> 10 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" 16 17 namespace base { 18 class FilePath; 19 } 20 21 namespace gfx { 22 class ImageSkia; 23 class Size; 24 } 25 26 #if defined(TOOLKIT_VIEWS) 27 namespace views { 28 class View; 29 } 30 #endif 31 32 namespace app_list { 33 34 class AppListModel; 35 class AppListViewDelegateObserver; 36 class SearchResult; 37 class SpeechUIModel; 38 39 class APP_LIST_EXPORT AppListViewDelegate { 40 public: 41 // A user of the app list. 42 struct APP_LIST_EXPORT User { 43 User(); 44 ~User(); 45 46 // Whether or not this user is the current user of the app list. 47 bool active; 48 49 // The name of this user. 50 base::string16 name; 51 52 // The email address of this user. 53 base::string16 email; 54 55 // The path to this user's profile directory. 56 base::FilePath profile_path; 57 }; 58 typedef std::vector<User> Users; 59 60 // AppListView owns the delegate. 61 virtual ~AppListViewDelegate() {} 62 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; 66 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; 70 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; 74 75 // Gets the SpeechUIModel for the app list. Owned by the AppListViewDelegate. 76 virtual SpeechUIModel* GetSpeechUI() = 0; 77 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; 83 84 // Invoked to start a new search. Delegate collects query input from 85 // SearchBoxModel and populates SearchResults. Both models are sub models 86 // of AppListModel. 87 virtual void StartSearch() = 0; 88 89 // Invoked to stop the current search. 90 virtual void StopSearch() = 0; 91 92 // Invoked to open the search result. 93 virtual void OpenSearchResult(SearchResult* result, 94 bool auto_launch, 95 int event_flags) = 0; 96 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, 100 int action_index, 101 int event_flags) = 0; 102 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; 106 107 // Invoked when the auto-launch is canceled by the user action. 108 virtual void AutoLaunchCanceled() = 0; 109 110 // Invoked when the app list UI is created. 111 virtual void ViewInitialized() = 0; 112 113 // Invoked to dismiss app list. This may leave the view open but hidden from 114 // the user. 115 virtual void Dismiss() = 0; 116 117 // Invoked when the app list is closing. 118 virtual void ViewClosing() = 0; 119 120 // Returns the icon to be displayed in the window and taskbar. 121 virtual gfx::ImageSkia GetWindowIcon() = 0; 122 123 // Open the settings UI. 124 virtual void OpenSettings() = 0; 125 126 // Open the help UI. 127 virtual void OpenHelp() = 0; 128 129 // Open the feedback UI. 130 virtual void OpenFeedback() = 0; 131 132 // Invoked to toggle the status of speech recognition. 133 virtual void ToggleSpeechRecognition() = 0; 134 135 // Shows the app list for the profile specified by |profile_path|. 136 virtual void ShowForProfileByPath(const base::FilePath& profile_path) = 0; 137 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; 142 143 // Creates the web views for the user-specified custom pages. The caller takes 144 // ownership of the returned views. 145 virtual std::vector<views::View*> CreateCustomPageWebViews( 146 const gfx::Size& size) = 0; 147 #endif 148 149 // Returns true if the delegate supports speech recognition. 150 virtual bool IsSpeechRecognitionEnabled() = 0; 151 152 // Returns the list of users (for AppListMenu). 153 virtual const Users& GetUsers() const = 0; 154 155 // Returns true if the app list should be centered and in landscape mode. 156 virtual bool ShouldCenterWindow() const = 0; 157 158 // Adds/removes an observer for profile changes. 159 virtual void AddObserver(AppListViewDelegateObserver* observer) {} 160 virtual void RemoveObserver(AppListViewDelegateObserver* observer) {} 161 }; 162 163 } // namespace app_list 164 165 #endif // UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ 166