ec67e7489a809580c637413c31ac2702db49a107
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / app_list / app_list_view_delegate.h
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/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"
23
24 class AppListControllerDelegate;
25 class Profile;
26
27 namespace apps {
28 class CustomLauncherPageContents;
29 }
30
31 namespace app_list {
32 class SearchController;
33 class SpeechUIModel;
34 }
35
36 namespace base {
37 class FilePath;
38 }
39
40 namespace gfx {
41 class ImageSkia;
42 }
43
44 #if defined(USE_ASH)
45 class AppSyncUIStateWatcher;
46 #endif
47
48 class AppListViewDelegate : public app_list::AppListViewDelegate,
49                             public app_list::StartPageObserver,
50                             public HotwordClient,
51                             public ProfileInfoCacheObserver,
52                             public SigninManagerBase::Observer,
53                             public SigninManagerFactory::Observer {
54  public:
55   AppListViewDelegate(Profile* profile,
56                       AppListControllerDelegate* controller);
57   virtual ~AppListViewDelegate();
58
59  private:
60   // Updates the app list's current profile and ProfileMenuItems.
61   void OnProfileChanged();
62
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,
74                                 bool auto_launch,
75                                 int event_flags) OVERRIDE;
76   virtual void InvokeSearchResultAction(app_list::SearchResult* result,
77                                         int action_index,
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;
95 #endif
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;
103
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;
110
111   // Overridden from HotwordClient:
112   virtual void OnHotwordStateChanged(bool started) OVERRIDE;
113   virtual void OnHotwordRecognized() OVERRIDE;
114
115   // Overridden from SigninManagerFactory::Observer:
116   virtual void SigninManagerCreated(SigninManagerBase* manager) OVERRIDE;
117   virtual void SigninManagerShutdown(SigninManagerBase* manager) OVERRIDE;
118
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;
124
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;
132
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
137   // is called.
138   Profile* profile_;
139   // Unowned pointer to the model owned by AppListSyncableService. Will change
140   // if |profile_| changes.
141   app_list::AppListModel* model_;
142
143   scoped_ptr<app_list::SpeechUIModel> speech_ui_;
144
145   base::TimeDelta auto_launch_timeout_;
146
147   Users users_;
148
149 #if defined(USE_ASH)
150   scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_;
151 #endif
152
153   ObserverList<app_list::AppListViewDelegateObserver> observers_;
154
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_;
158
159   // Window contents of additional custom launcher pages.
160   ScopedVector<apps::CustomLauncherPageContents> custom_page_contents_;
161
162   DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate);
163 };
164
165 #endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_