c9847e4c8f2f138829154f6560829751b394222c
[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/observer_list.h"
15 #include "chrome/browser/profiles/profile_info_cache_observer.h"
16 #include "chrome/browser/ui/app_list/chrome_signin_delegate.h"
17 #include "chrome/browser/ui/app_list/start_page_observer.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
20 #include "ui/app_list/app_list_view_delegate.h"
21
22 class AppListControllerDelegate;
23 class Profile;
24
25 namespace app_list {
26 class SearchController;
27 class SpeechUIModel;
28 }
29
30 namespace base {
31 class FilePath;
32 }
33
34 namespace content {
35 class NotificationDetails;
36 class NotificationSource;
37 }
38
39 namespace gfx {
40 class ImageSkia;
41 }
42
43 #if defined(USE_ASH)
44 class AppSyncUIStateWatcher;
45 #endif
46
47 class AppListViewDelegate : public app_list::AppListViewDelegate,
48                             public app_list::StartPageObserver,
49                             public content::NotificationObserver,
50                             public ProfileInfoCacheObserver {
51  public:
52   AppListViewDelegate(Profile* profile,
53                       AppListControllerDelegate* controller);
54   virtual ~AppListViewDelegate();
55
56  private:
57   // Registers the current profile for notifications.
58   void RegisterForNotifications();
59   // Updates the app list's current profile and ProfileMenuItems.
60   void OnProfileChanged();
61
62   // Overridden from app_list::AppListViewDelegate:
63   virtual bool ForceNativeDesktop() const OVERRIDE;
64   virtual void SetProfileByPath(const base::FilePath& profile_path) OVERRIDE;
65   virtual app_list::AppListModel* GetModel() OVERRIDE;
66   virtual app_list::SigninDelegate* GetSigninDelegate() 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   virtual content::WebContents* GetStartPageContents() OVERRIDE;
92   virtual content::WebContents* GetSpeechRecognitionContents() OVERRIDE;
93   virtual const Users& GetUsers() const OVERRIDE;
94   virtual void AddObserver(
95       app_list::AppListViewDelegateObserver* observer) OVERRIDE;
96   virtual void RemoveObserver(
97       app_list::AppListViewDelegateObserver* observer) OVERRIDE;
98
99   // Overridden from app_list::StartPageObserver:
100   virtual void OnSpeechResult(const base::string16& result,
101                               bool is_final) OVERRIDE;
102   virtual void OnSpeechSoundLevelChanged(int16 level) OVERRIDE;
103   virtual void OnSpeechRecognitionStateChanged(
104       app_list::SpeechRecognitionState new_state) OVERRIDE;
105
106   // Overridden from content::NotificationObserver:
107   virtual void Observe(int type,
108                        const content::NotificationSource& source,
109                        const content::NotificationDetails& details) 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   content::NotificationRegistrar registrar_;
136   ChromeSigninDelegate signin_delegate_;
137 #if defined(USE_ASH)
138   scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_;
139 #endif
140
141   ObserverList<app_list::AppListViewDelegateObserver> observers_;
142
143   DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate);
144 };
145
146 #endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_