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/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"
22 class AppListControllerDelegate;
26 class SearchController;
35 class NotificationDetails;
36 class NotificationSource;
44 class AppSyncUIStateWatcher;
47 class AppListViewDelegate : public app_list::AppListViewDelegate,
48 public app_list::StartPageObserver,
49 public content::NotificationObserver,
50 public ProfileInfoCacheObserver {
52 AppListViewDelegate(Profile* profile,
53 AppListControllerDelegate* controller);
54 virtual ~AppListViewDelegate();
57 // Registers the current profile for notifications.
58 void RegisterForNotifications();
59 // Updates the app list's current profile and ProfileMenuItems.
60 void OnProfileChanged();
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,
75 int event_flags) OVERRIDE;
76 virtual void InvokeSearchResultAction(app_list::SearchResult* result,
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;
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;
106 // Overridden from content::NotificationObserver:
107 virtual void Observe(int type,
108 const content::NotificationSource& source,
109 const content::NotificationDetails& details) OVERRIDE;
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;
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
125 // Unowned pointer to the model owned by AppListSyncableService. Will change
126 // if |profile_| changes.
127 app_list::AppListModel* model_;
129 scoped_ptr<app_list::SpeechUIModel> speech_ui_;
131 base::TimeDelta auto_launch_timeout_;
135 content::NotificationRegistrar registrar_;
136 ChromeSigninDelegate signin_delegate_;
138 scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_;
141 ObserverList<app_list::AppListViewDelegateObserver> observers_;
143 DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate);
146 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_