app_list_view_delegate.h revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
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#include "ui/app_list/speech_ui_model.h" 22 23class AppListControllerDelegate; 24class Profile; 25 26namespace app_list { 27class SearchController; 28} 29 30namespace base { 31class FilePath; 32} 33 34namespace content { 35class NotificationDetails; 36class NotificationSource; 37} 38 39namespace gfx { 40class ImageSkia; 41} 42 43#if defined(USE_ASH) 44class AppSyncUIStateWatcher; 45#endif 46 47class 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 int event_flags) OVERRIDE; 75 virtual void InvokeSearchResultAction(app_list::SearchResult* result, 76 int action_index, 77 int event_flags) OVERRIDE; 78 virtual void Dismiss() OVERRIDE; 79 virtual void ViewClosing() OVERRIDE; 80 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; 81 virtual void OpenSettings() OVERRIDE; 82 virtual void OpenHelp() OVERRIDE; 83 virtual void OpenFeedback() OVERRIDE; 84 virtual void ToggleSpeechRecognition() OVERRIDE; 85 virtual void ShowForProfileByPath( 86 const base::FilePath& profile_path) OVERRIDE; 87 virtual content::WebContents* GetStartPageContents() OVERRIDE; 88 virtual const Users& GetUsers() const OVERRIDE; 89 virtual void AddObserver( 90 app_list::AppListViewDelegateObserver* observer) OVERRIDE; 91 virtual void RemoveObserver( 92 app_list::AppListViewDelegateObserver* observer) OVERRIDE; 93 94 // Overridden from app_list::StartPageObserver: 95 virtual void OnSpeechResult(const base::string16& result, 96 bool is_final) OVERRIDE; 97 virtual void OnSpeechSoundLevelChanged(int16 level) OVERRIDE; 98 virtual void OnSpeechRecognitionStateChanged( 99 app_list::SpeechRecognitionState new_state) OVERRIDE; 100 101 // Overridden from content::NotificationObserver: 102 virtual void Observe(int type, 103 const content::NotificationSource& source, 104 const content::NotificationDetails& details) OVERRIDE; 105 106 // Overridden from ProfileInfoCacheObserver: 107 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; 108 virtual void OnProfileWasRemoved(const base::FilePath& profile_path, 109 const base::string16& profile_name) OVERRIDE; 110 virtual void OnProfileNameChanged( 111 const base::FilePath& profile_path, 112 const base::string16& old_profile_name) OVERRIDE; 113 114 scoped_ptr<app_list::SearchController> search_controller_; 115 // Unowned pointer to the controller. 116 AppListControllerDelegate* controller_; 117 // Unowned pointer to the associated profile. May change if SetProfileByPath 118 // is called. 119 Profile* profile_; 120 // Unowned pointer to the model owned by AppListSyncableService. Will change 121 // if |profile_| changes. 122 app_list::AppListModel* model_; 123 124 app_list::SpeechUIModel speech_ui_; 125 126 Users users_; 127 128 content::NotificationRegistrar registrar_; 129 ChromeSigninDelegate signin_delegate_; 130#if defined(USE_ASH) 131 scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_; 132#endif 133 134 ObserverList<app_list::AppListViewDelegateObserver> observers_; 135 136 DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate); 137}; 138 139#endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ 140