app_list_view_delegate.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
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 CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
6#define CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
7
8#include <string>
9
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/observer_list.h"
15#include "base/scoped_observer.h"
16#include "chrome/browser/profiles/profile_info_cache_observer.h"
17#include "chrome/browser/signin/signin_manager_base.h"
18#include "chrome/browser/signin/signin_manager_factory.h"
19#include "chrome/browser/ui/app_list/chrome_signin_delegate.h"
20#include "chrome/browser/ui/app_list/start_page_observer.h"
21#include "ui/app_list/app_list_view_delegate.h"
22
23class AppListControllerDelegate;
24class Profile;
25
26namespace app_list {
27class SearchController;
28class SpeechUIModel;
29}
30
31namespace base {
32class FilePath;
33}
34
35namespace gfx {
36class ImageSkia;
37}
38
39#if defined(USE_ASH)
40class AppSyncUIStateWatcher;
41#endif
42
43class AppListViewDelegate : public app_list::AppListViewDelegate,
44                            public app_list::StartPageObserver,
45                            public ProfileInfoCacheObserver,
46                            public SigninManagerBase::Observer,
47                            public SigninManagerFactory::Observer {
48 public:
49  AppListViewDelegate(Profile* profile,
50                      AppListControllerDelegate* controller);
51  virtual ~AppListViewDelegate();
52
53 private:
54  // Updates the app list's current profile and ProfileMenuItems.
55  void OnProfileChanged();
56
57  // Overridden from app_list::AppListViewDelegate:
58  virtual bool ForceNativeDesktop() const OVERRIDE;
59  virtual void SetProfileByPath(const base::FilePath& profile_path) OVERRIDE;
60  virtual app_list::AppListModel* GetModel() OVERRIDE;
61  virtual app_list::SigninDelegate* GetSigninDelegate() OVERRIDE;
62  virtual app_list::SpeechUIModel* GetSpeechUI() OVERRIDE;
63  virtual void GetShortcutPathForApp(
64      const std::string& app_id,
65      const base::Callback<void(const base::FilePath&)>& callback) OVERRIDE;
66  virtual void StartSearch() OVERRIDE;
67  virtual void StopSearch() OVERRIDE;
68  virtual void OpenSearchResult(app_list::SearchResult* result,
69                                bool auto_launch,
70                                int event_flags) OVERRIDE;
71  virtual void InvokeSearchResultAction(app_list::SearchResult* result,
72                                        int action_index,
73                                        int event_flags) OVERRIDE;
74  virtual base::TimeDelta GetAutoLaunchTimeout() OVERRIDE;
75  virtual void AutoLaunchCanceled() OVERRIDE;
76  virtual void ViewInitialized() OVERRIDE;
77  virtual void Dismiss() OVERRIDE;
78  virtual void ViewClosing() OVERRIDE;
79  virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
80  virtual void OpenSettings() OVERRIDE;
81  virtual void OpenHelp() OVERRIDE;
82  virtual void OpenFeedback() OVERRIDE;
83  virtual void ToggleSpeechRecognition() OVERRIDE;
84  virtual void ShowForProfileByPath(
85      const base::FilePath& profile_path) OVERRIDE;
86  virtual content::WebContents* GetStartPageContents() OVERRIDE;
87  virtual content::WebContents* GetSpeechRecognitionContents() OVERRIDE;
88  virtual const Users& GetUsers() const OVERRIDE;
89  virtual void AddObserver(
90      app_list::AppListViewDelegateObserver* observer) OVERRIDE;
91  virtual void RemoveObserver(
92      app_list::AppListViewDelegateObserver* observer) OVERRIDE;
93
94  // Overridden from app_list::StartPageObserver:
95  virtual void OnSpeechResult(const base::string16& result,
96                              bool is_final) OVERRIDE;
97  virtual void OnSpeechSoundLevelChanged(int16 level) OVERRIDE;
98  virtual void OnSpeechRecognitionStateChanged(
99      app_list::SpeechRecognitionState new_state) OVERRIDE;
100
101  // Overridden from SigninManagerFactory::Observer:
102  virtual void SigninManagerCreated(SigninManagerBase* manager) OVERRIDE;
103  virtual void SigninManagerShutdown(SigninManagerBase* manager) OVERRIDE;
104
105  // Overridden from SigninManagerBase::Observer:
106  virtual void GoogleSigninFailed(const GoogleServiceAuthError& error) OVERRIDE;
107  virtual void GoogleSigninSucceeded(const std::string& username,
108                                     const std::string& password) OVERRIDE;
109  virtual void GoogleSignedOut(const std::string& username) OVERRIDE;
110
111  // Overridden from ProfileInfoCacheObserver:
112  virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE;
113  virtual void OnProfileWasRemoved(const base::FilePath& profile_path,
114                                   const base::string16& profile_name) OVERRIDE;
115  virtual void OnProfileNameChanged(
116      const base::FilePath& profile_path,
117      const base::string16& old_profile_name) OVERRIDE;
118
119  scoped_ptr<app_list::SearchController> search_controller_;
120  // Unowned pointer to the controller.
121  AppListControllerDelegate* controller_;
122  // Unowned pointer to the associated profile. May change if SetProfileByPath
123  // is called.
124  Profile* profile_;
125  // Unowned pointer to the model owned by AppListSyncableService. Will change
126  // if |profile_| changes.
127  app_list::AppListModel* model_;
128
129  scoped_ptr<app_list::SpeechUIModel> speech_ui_;
130
131  base::TimeDelta auto_launch_timeout_;
132
133  Users users_;
134
135  ChromeSigninDelegate signin_delegate_;
136#if defined(USE_ASH)
137  scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_;
138#endif
139
140  ObserverList<app_list::AppListViewDelegateObserver> observers_;
141
142  // Used to track the SigninManagers that this instance is observing so that
143  // this instance can be removed as an observer on its destruction.
144  ScopedObserver<SigninManagerBase, AppListViewDelegate> scoped_observer_;
145
146  DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate);
147};
148
149#endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
150