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/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"
20 class AppListControllerDelegate;
24 class SearchController;
37 class AppSyncUIStateWatcher;
40 class AppListViewDelegate : public app_list::AppListViewDelegate,
41 public app_list::StartPageObserver,
43 public ProfileInfoCacheObserver {
45 AppListViewDelegate(Profile* profile,
46 AppListControllerDelegate* controller);
47 virtual ~AppListViewDelegate();
50 // Updates the app list's current profile and ProfileMenuItems.
51 void OnProfileChanged();
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,
65 int event_flags) OVERRIDE;
66 virtual void InvokeSearchResultAction(app_list::SearchResult* result,
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;
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;
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;
99 // Overridden from HotwordClient:
100 virtual void OnHotwordStateChanged(bool started) OVERRIDE;
101 virtual void OnHotwordRecognized() OVERRIDE;
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;
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
117 // Unowned pointer to the model owned by AppListSyncableService. Will change
118 // if |profile_| changes.
119 app_list::AppListModel* model_;
121 scoped_ptr<app_list::SpeechUIModel> speech_ui_;
123 base::TimeDelta auto_launch_timeout_;
128 scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_;
131 ObserverList<app_list::AppListViewDelegateObserver> observers_;
133 DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate);
136 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_