33fb0d5eb01ebea94db1c1fdc65ba9de89af5083
[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/search/hotword_client.h"
17 #include "chrome/browser/ui/app_list/start_page_observer.h"
18 #include "ui/app_list/app_list_view_delegate.h"
19
20 class AppListControllerDelegate;
21 class Profile;
22
23 namespace app_list {
24 class SearchController;
25 class SpeechUIModel;
26 }
27
28 namespace base {
29 class FilePath;
30 }
31
32 namespace gfx {
33 class ImageSkia;
34 }
35
36 #if defined(USE_ASH)
37 class AppSyncUIStateWatcher;
38 #endif
39
40 class AppListViewDelegate : public app_list::AppListViewDelegate,
41                             public app_list::StartPageObserver,
42                             public HotwordClient,
43                             public ProfileInfoCacheObserver {
44  public:
45   AppListViewDelegate(Profile* profile,
46                       AppListControllerDelegate* controller);
47   virtual ~AppListViewDelegate();
48
49  private:
50   // Updates the app list's current profile and ProfileMenuItems.
51   void OnProfileChanged();
52
53   // Overridden from app_list::AppListViewDelegate:
54   virtual bool ForceNativeDesktop() const OVERRIDE;
55   virtual void SetProfileByPath(const base::FilePath& profile_path) OVERRIDE;
56   virtual app_list::AppListModel* GetModel() OVERRIDE;
57   virtual app_list::SpeechUIModel* GetSpeechUI() OVERRIDE;
58   virtual void GetShortcutPathForApp(
59       const std::string& app_id,
60       const base::Callback<void(const base::FilePath&)>& callback) OVERRIDE;
61   virtual void StartSearch() OVERRIDE;
62   virtual void StopSearch() OVERRIDE;
63   virtual void OpenSearchResult(app_list::SearchResult* result,
64                                 bool auto_launch,
65                                 int event_flags) OVERRIDE;
66   virtual void InvokeSearchResultAction(app_list::SearchResult* result,
67                                         int action_index,
68                                         int event_flags) OVERRIDE;
69   virtual base::TimeDelta GetAutoLaunchTimeout() OVERRIDE;
70   virtual void AutoLaunchCanceled() OVERRIDE;
71   virtual void ViewInitialized() OVERRIDE;
72   virtual void Dismiss() OVERRIDE;
73   virtual void ViewClosing() OVERRIDE;
74   virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
75   virtual void OpenSettings() OVERRIDE;
76   virtual void OpenHelp() OVERRIDE;
77   virtual void OpenFeedback() OVERRIDE;
78   virtual void ToggleSpeechRecognition() OVERRIDE;
79   virtual void ShowForProfileByPath(
80       const base::FilePath& profile_path) OVERRIDE;
81 #if defined(TOOLKIT_VIEWS)
82   virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE;
83 #endif
84   virtual bool IsSpeechRecognitionEnabled() OVERRIDE;
85   virtual const Users& GetUsers() const OVERRIDE;
86   virtual bool ShouldCenterWindow() const OVERRIDE;
87   virtual void AddObserver(
88       app_list::AppListViewDelegateObserver* observer) OVERRIDE;
89   virtual void RemoveObserver(
90       app_list::AppListViewDelegateObserver* observer) OVERRIDE;
91
92   // Overridden from app_list::StartPageObserver:
93   virtual void OnSpeechResult(const base::string16& result,
94                               bool is_final) OVERRIDE;
95   virtual void OnSpeechSoundLevelChanged(int16 level) OVERRIDE;
96   virtual void OnSpeechRecognitionStateChanged(
97       app_list::SpeechRecognitionState new_state) OVERRIDE;
98
99   // Overridden from HotwordClient:
100   virtual void OnHotwordStateChanged(bool started) OVERRIDE;
101   virtual void OnHotwordRecognized() OVERRIDE;
102
103   // Overridden from ProfileInfoCacheObserver:
104   virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE;
105   virtual void OnProfileWasRemoved(const base::FilePath& profile_path,
106                                    const base::string16& profile_name) OVERRIDE;
107   virtual void OnProfileNameChanged(
108       const base::FilePath& profile_path,
109       const base::string16& old_profile_name) OVERRIDE;
110
111   scoped_ptr<app_list::SearchController> search_controller_;
112   // Unowned pointer to the controller.
113   AppListControllerDelegate* controller_;
114   // Unowned pointer to the associated profile. May change if SetProfileByPath
115   // is called.
116   Profile* profile_;
117   // Unowned pointer to the model owned by AppListSyncableService. Will change
118   // if |profile_| changes.
119   app_list::AppListModel* model_;
120
121   scoped_ptr<app_list::SpeechUIModel> speech_ui_;
122
123   base::TimeDelta auto_launch_timeout_;
124
125   Users users_;
126
127 #if defined(USE_ASH)
128   scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_;
129 #endif
130
131   ObserverList<app_list::AppListViewDelegateObserver> observers_;
132
133   DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate);
134 };
135
136 #endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_