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 CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h"
15 #include "base/observer_list.h"
16 #include "base/scoped_observer.h"
17 #include "chrome/browser/profiles/profile_info_cache_observer.h"
18 #include "chrome/browser/search/hotword_client.h"
19 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/browser/ui/app_list/start_page_observer.h"
21 #include "components/signin/core/browser/signin_manager_base.h"
22 #include "ui/app_list/app_list_view_delegate.h"
24 class AppListControllerDelegate;
28 class CustomLauncherPageContents;
32 class SearchController;
45 class AppSyncUIStateWatcher;
48 class AppListViewDelegate : public app_list::AppListViewDelegate,
49 public app_list::StartPageObserver,
51 public ProfileInfoCacheObserver,
52 public SigninManagerBase::Observer,
53 public SigninManagerFactory::Observer {
55 AppListViewDelegate(Profile* profile,
56 AppListControllerDelegate* controller);
57 virtual ~AppListViewDelegate();
60 // Updates the app list's current profile and ProfileMenuItems.
61 void OnProfileChanged();
63 // Overridden from app_list::AppListViewDelegate:
64 virtual bool ForceNativeDesktop() const OVERRIDE;
65 virtual void SetProfileByPath(const base::FilePath& profile_path) OVERRIDE;
66 virtual app_list::AppListModel* GetModel() OVERRIDE;
67 virtual app_list::SpeechUIModel* GetSpeechUI() OVERRIDE;
68 virtual void GetShortcutPathForApp(
69 const std::string& app_id,
70 const base::Callback<void(const base::FilePath&)>& callback) OVERRIDE;
71 virtual void StartSearch() OVERRIDE;
72 virtual void StopSearch() OVERRIDE;
73 virtual void OpenSearchResult(app_list::SearchResult* result,
75 int event_flags) OVERRIDE;
76 virtual void InvokeSearchResultAction(app_list::SearchResult* result,
78 int event_flags) OVERRIDE;
79 virtual base::TimeDelta GetAutoLaunchTimeout() OVERRIDE;
80 virtual void AutoLaunchCanceled() OVERRIDE;
81 virtual void ViewInitialized() OVERRIDE;
82 virtual void Dismiss() OVERRIDE;
83 virtual void ViewClosing() OVERRIDE;
84 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
85 virtual void OpenSettings() OVERRIDE;
86 virtual void OpenHelp() OVERRIDE;
87 virtual void OpenFeedback() OVERRIDE;
88 virtual void ToggleSpeechRecognition() OVERRIDE;
89 virtual void ShowForProfileByPath(
90 const base::FilePath& profile_path) OVERRIDE;
91 #if defined(TOOLKIT_VIEWS)
92 virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE;
93 virtual std::vector<views::View*> CreateCustomPageWebViews(
94 const gfx::Size& size) OVERRIDE;
96 virtual bool IsSpeechRecognitionEnabled() OVERRIDE;
97 virtual const Users& GetUsers() const OVERRIDE;
98 virtual bool ShouldCenterWindow() const OVERRIDE;
99 virtual void AddObserver(
100 app_list::AppListViewDelegateObserver* observer) OVERRIDE;
101 virtual void RemoveObserver(
102 app_list::AppListViewDelegateObserver* observer) OVERRIDE;
104 // Overridden from app_list::StartPageObserver:
105 virtual void OnSpeechResult(const base::string16& result,
106 bool is_final) OVERRIDE;
107 virtual void OnSpeechSoundLevelChanged(int16 level) OVERRIDE;
108 virtual void OnSpeechRecognitionStateChanged(
109 app_list::SpeechRecognitionState new_state) OVERRIDE;
111 // Overridden from HotwordClient:
112 virtual void OnHotwordStateChanged(bool started) OVERRIDE;
113 virtual void OnHotwordRecognized() OVERRIDE;
115 // Overridden from SigninManagerFactory::Observer:
116 virtual void SigninManagerCreated(SigninManagerBase* manager) OVERRIDE;
117 virtual void SigninManagerShutdown(SigninManagerBase* manager) OVERRIDE;
119 // Overridden from SigninManagerBase::Observer:
120 virtual void GoogleSigninFailed(const GoogleServiceAuthError& error) OVERRIDE;
121 virtual void GoogleSigninSucceeded(const std::string& username,
122 const std::string& password) OVERRIDE;
123 virtual void GoogleSignedOut(const std::string& username) OVERRIDE;
125 // Overridden from ProfileInfoCacheObserver:
126 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE;
127 virtual void OnProfileWasRemoved(const base::FilePath& profile_path,
128 const base::string16& profile_name) OVERRIDE;
129 virtual void OnProfileNameChanged(
130 const base::FilePath& profile_path,
131 const base::string16& old_profile_name) OVERRIDE;
133 scoped_ptr<app_list::SearchController> search_controller_;
134 // Unowned pointer to the controller.
135 AppListControllerDelegate* controller_;
136 // Unowned pointer to the associated profile. May change if SetProfileByPath
139 // Unowned pointer to the model owned by AppListSyncableService. Will change
140 // if |profile_| changes.
141 app_list::AppListModel* model_;
143 scoped_ptr<app_list::SpeechUIModel> speech_ui_;
145 base::TimeDelta auto_launch_timeout_;
150 scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_;
153 ObserverList<app_list::AppListViewDelegateObserver> observers_;
155 // Used to track the SigninManagers that this instance is observing so that
156 // this instance can be removed as an observer on its destruction.
157 ScopedObserver<SigninManagerBase, AppListViewDelegate> scoped_observer_;
159 // Window contents of additional custom launcher pages.
160 ScopedVector<apps::CustomLauncherPageContents> custom_page_contents_;
162 DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate);
165 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_