| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 18 #include "base/observer_list.h" | |
| 19 #include "base/scoped_observer.h" | |
| 20 #include "chrome/browser/profiles/profile_attributes_storage.h" | |
| 21 #include "chrome/browser/search/hotword_client.h" | 18 #include "chrome/browser/search/hotword_client.h" |
| 22 #include "chrome/browser/signin/signin_manager_factory.h" | |
| 23 #include "chrome/browser/ui/app_list/start_page_observer.h" | 19 #include "chrome/browser/ui/app_list/start_page_observer.h" |
| 24 #include "components/search_engines/template_url_service.h" | 20 #include "components/search_engines/template_url_service.h" |
| 25 #include "components/search_engines/template_url_service_observer.h" | 21 #include "components/search_engines/template_url_service_observer.h" |
| 26 #include "components/signin/core/browser/signin_manager_base.h" | |
| 27 #include "content/public/browser/notification_observer.h" | |
| 28 #include "content/public/browser/notification_registrar.h" | |
| 29 #include "ui/app_list/app_list_view_delegate.h" | 22 #include "ui/app_list/app_list_view_delegate.h" |
| 30 | 23 |
| 31 class AppListControllerDelegate; | 24 class AppListControllerDelegate; |
| 32 class Profile; | 25 class Profile; |
| 33 | 26 |
| 34 namespace apps { | 27 namespace apps { |
| 35 class CustomLauncherPageContents; | 28 class CustomLauncherPageContents; |
| 36 } | 29 } |
| 37 | 30 |
| 38 namespace app_list { | 31 namespace app_list { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 54 class ImageSkia; | 47 class ImageSkia; |
| 55 } | 48 } |
| 56 | 49 |
| 57 #if defined(USE_ASH) | 50 #if defined(USE_ASH) |
| 58 class AppSyncUIStateWatcher; | 51 class AppSyncUIStateWatcher; |
| 59 #endif | 52 #endif |
| 60 | 53 |
| 61 class AppListViewDelegate : public app_list::AppListViewDelegate, | 54 class AppListViewDelegate : public app_list::AppListViewDelegate, |
| 62 public app_list::StartPageObserver, | 55 public app_list::StartPageObserver, |
| 63 public HotwordClient, | 56 public HotwordClient, |
| 64 public ProfileAttributesStorage::Observer, | |
| 65 public SigninManagerBase::Observer, | |
| 66 public SigninManagerFactory::Observer, | |
| 67 public content::NotificationObserver, | |
| 68 public TemplateURLServiceObserver { | 57 public TemplateURLServiceObserver { |
| 69 public: | 58 public: |
| 70 // Constructs Chrome's AppListViewDelegate with a NULL Profile. | 59 // Constructs Chrome's AppListViewDelegate with a NULL Profile. |
| 71 // Does not take ownership of |controller|. TODO(tapted): It should. | 60 // Does not take ownership of |controller|. TODO(tapted): It should. |
| 72 explicit AppListViewDelegate(AppListControllerDelegate* controller); | 61 explicit AppListViewDelegate(AppListControllerDelegate* controller); |
| 73 ~AppListViewDelegate() override; | 62 ~AppListViewDelegate() override; |
| 74 | 63 |
| 75 // Configure the AppList for the given |profile|. | 64 // Configure the AppList for the given |profile|. |
| 76 void SetProfile(Profile* profile); | 65 void SetProfile(Profile* profile); |
| 77 Profile* profile() { return profile_; } | 66 Profile* profile() { return profile_; } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 94 bool auto_launch, | 83 bool auto_launch, |
| 95 int event_flags) override; | 84 int event_flags) override; |
| 96 void InvokeSearchResultAction(app_list::SearchResult* result, | 85 void InvokeSearchResultAction(app_list::SearchResult* result, |
| 97 int action_index, | 86 int action_index, |
| 98 int event_flags) override; | 87 int event_flags) override; |
| 99 base::TimeDelta GetAutoLaunchTimeout() override; | 88 base::TimeDelta GetAutoLaunchTimeout() override; |
| 100 void AutoLaunchCanceled() override; | 89 void AutoLaunchCanceled() override; |
| 101 void ViewInitialized() override; | 90 void ViewInitialized() override; |
| 102 void Dismiss() override; | 91 void Dismiss() override; |
| 103 void ViewClosing() override; | 92 void ViewClosing() override; |
| 104 void OpenHelp() override; | |
| 105 void OpenFeedback() override; | |
| 106 void StartSpeechRecognition() override; | 93 void StartSpeechRecognition() override; |
| 107 void StopSpeechRecognition() override; | 94 void StopSpeechRecognition() override; |
| 108 void ShowForProfileByPath(const base::FilePath& profile_path) override; | 95 void ShowForProfileByPath(const base::FilePath& profile_path) override; |
| 109 #if defined(TOOLKIT_VIEWS) | 96 #if defined(TOOLKIT_VIEWS) |
| 110 views::View* CreateStartPageWebView(const gfx::Size& size) override; | 97 views::View* CreateStartPageWebView(const gfx::Size& size) override; |
| 111 std::vector<views::View*> CreateCustomPageWebViews( | 98 std::vector<views::View*> CreateCustomPageWebViews( |
| 112 const gfx::Size& size) override; | 99 const gfx::Size& size) override; |
| 113 void CustomLauncherPageAnimationChanged(double progress) override; | 100 void CustomLauncherPageAnimationChanged(double progress) override; |
| 114 void CustomLauncherPagePopSubpage() override; | 101 void CustomLauncherPagePopSubpage() override; |
| 115 #endif | 102 #endif |
| 116 bool IsSpeechRecognitionEnabled() override; | 103 bool IsSpeechRecognitionEnabled() override; |
| 117 const Users& GetUsers() const override; | |
| 118 bool ShouldCenterWindow() const override; | 104 bool ShouldCenterWindow() const override; |
| 119 void AddObserver(app_list::AppListViewDelegateObserver* observer) override; | |
| 120 void RemoveObserver(app_list::AppListViewDelegateObserver* observer) override; | |
| 121 #if !defined(OS_CHROMEOS) | 105 #if !defined(OS_CHROMEOS) |
| 122 base::string16 GetMessageTitle() const override; | 106 base::string16 GetMessageTitle() const override; |
| 123 base::string16 GetMessageText(size_t* message_break) const override; | 107 base::string16 GetMessageText(size_t* message_break) const override; |
| 124 base::string16 GetAppsShortcutName() const override; | 108 base::string16 GetAppsShortcutName() const override; |
| 125 base::string16 GetLearnMoreText() const override; | 109 base::string16 GetLearnMoreText() const override; |
| 126 base::string16 GetLearnMoreLink() const override; | 110 base::string16 GetLearnMoreLink() const override; |
| 127 gfx::ImageSkia* GetAppsIcon() const override; | 111 gfx::ImageSkia* GetAppsIcon() const override; |
| 128 void OpenLearnMoreLink() override; | 112 void OpenLearnMoreLink() override; |
| 129 #endif | 113 #endif |
| 130 | 114 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 146 void OnSpeechSoundLevelChanged(int16_t level) override; | 130 void OnSpeechSoundLevelChanged(int16_t level) override; |
| 147 void OnSpeechRecognitionStateChanged( | 131 void OnSpeechRecognitionStateChanged( |
| 148 app_list::SpeechRecognitionState new_state) override; | 132 app_list::SpeechRecognitionState new_state) override; |
| 149 | 133 |
| 150 // Overridden from HotwordClient: | 134 // Overridden from HotwordClient: |
| 151 void OnHotwordStateChanged(bool started) override; | 135 void OnHotwordStateChanged(bool started) override; |
| 152 void OnHotwordRecognized( | 136 void OnHotwordRecognized( |
| 153 const scoped_refptr<content::SpeechRecognitionSessionPreamble>& preamble) | 137 const scoped_refptr<content::SpeechRecognitionSessionPreamble>& preamble) |
| 154 override; | 138 override; |
| 155 | 139 |
| 156 // Overridden from SigninManagerFactory::Observer: | |
| 157 void SigninManagerCreated(SigninManagerBase* manager) override; | |
| 158 void SigninManagerShutdown(SigninManagerBase* manager) override; | |
| 159 | |
| 160 // Overridden from SigninManagerBase::Observer: | |
| 161 void GoogleSigninFailed(const GoogleServiceAuthError& error) override; | |
| 162 void GoogleSigninSucceeded(const std::string& account_id, | |
| 163 const std::string& username, | |
| 164 const std::string& password) override; | |
| 165 void GoogleSignedOut(const std::string& account_id, | |
| 166 const std::string& username) override; | |
| 167 | |
| 168 // Overridden from ProfileAttributesStorage::Observer: | |
| 169 void OnProfileAdded(const base::FilePath& profile_path) override; | |
| 170 void OnProfileWasRemoved(const base::FilePath& profile_path, | |
| 171 const base::string16& profile_name) override; | |
| 172 void OnProfileNameChanged(const base::FilePath& profile_path, | |
| 173 const base::string16& old_profile_name) override; | |
| 174 | |
| 175 // Overridden from content::NotificationObserver: | 140 // Overridden from content::NotificationObserver: |
| 176 void Observe(int type, | 141 void Observe(int type, |
| 177 const content::NotificationSource& source, | 142 const content::NotificationSource& source, |
| 178 const content::NotificationDetails& details) override; | 143 const content::NotificationDetails& details) override; |
| 179 | 144 |
| 180 // Unowned pointer to the controller. | 145 // Unowned pointer to the controller. |
| 181 AppListControllerDelegate* controller_; | 146 AppListControllerDelegate* controller_; |
| 182 // Unowned pointer to the associated profile. May change if SetProfileByPath | 147 // Unowned pointer to the associated profile. May change if SetProfileByPath |
| 183 // is called. | 148 // is called. |
| 184 Profile* profile_; | 149 Profile* profile_; |
| 185 // Unowned pointer to the model owned by AppListSyncableService. Will change | 150 // Unowned pointer to the model owned by AppListSyncableService. Will change |
| 186 // if |profile_| changes. | 151 // if |profile_| changes. |
| 187 app_list::AppListModel* model_; | 152 app_list::AppListModel* model_; |
| 188 | 153 |
| 189 // Note: order ensures |search_resource_manager_| is destroyed before | 154 // Note: order ensures |search_resource_manager_| is destroyed before |
| 190 // |speech_ui_|. | 155 // |speech_ui_|. |
| 191 std::unique_ptr<app_list::SpeechUIModel> speech_ui_; | 156 std::unique_ptr<app_list::SpeechUIModel> speech_ui_; |
| 192 std::unique_ptr<app_list::SearchResourceManager> search_resource_manager_; | 157 std::unique_ptr<app_list::SearchResourceManager> search_resource_manager_; |
| 193 std::unique_ptr<app_list::SearchController> search_controller_; | 158 std::unique_ptr<app_list::SearchController> search_controller_; |
| 194 | 159 |
| 195 std::unique_ptr<app_list::LauncherPageEventDispatcher> | 160 std::unique_ptr<app_list::LauncherPageEventDispatcher> |
| 196 launcher_page_event_dispatcher_; | 161 launcher_page_event_dispatcher_; |
| 197 | 162 |
| 198 base::TimeDelta auto_launch_timeout_; | 163 base::TimeDelta auto_launch_timeout_; |
| 199 // Determines whether the current search was initiated by speech. | 164 // Determines whether the current search was initiated by speech. |
| 200 bool is_voice_query_; | 165 bool is_voice_query_; |
| 201 | 166 |
| 202 Users users_; | |
| 203 | |
| 204 #if defined(USE_ASH) | 167 #if defined(USE_ASH) |
| 205 std::unique_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_; | 168 std::unique_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_; |
| 206 #endif | 169 #endif |
| 207 | 170 |
| 208 base::ObserverList<app_list::AppListViewDelegateObserver> observers_; | |
| 209 | |
| 210 ScopedObserver<TemplateURLService, AppListViewDelegate> | 171 ScopedObserver<TemplateURLService, AppListViewDelegate> |
| 211 template_url_service_observer_; | 172 template_url_service_observer_; |
| 212 | 173 |
| 213 // Used to track the SigninManagers that this instance is observing so that | |
| 214 // this instance can be removed as an observer on its destruction. | |
| 215 ScopedObserver<SigninManagerBase, AppListViewDelegate> scoped_observer_; | |
| 216 | |
| 217 // Window contents of additional custom launcher pages. | 174 // Window contents of additional custom launcher pages. |
| 218 ScopedVector<apps::CustomLauncherPageContents> custom_page_contents_; | 175 ScopedVector<apps::CustomLauncherPageContents> custom_page_contents_; |
| 219 | 176 |
| 220 // Registers for NOTIFICATION_APP_TERMINATING to unload custom launcher pages. | |
| 221 content::NotificationRegistrar registrar_; | |
| 222 | |
| 223 DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate); | 177 DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate); |
| 224 }; | 178 }; |
| 225 | 179 |
| 226 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ | 180 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ |
| OLD | NEW |