app_list_view_delegate.h revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
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 "chrome/browser/profiles/profile_info_cache_observer.h" 15#include "chrome/browser/ui/app_list/chrome_signin_delegate.h" 16#include "content/public/browser/notification_observer.h" 17#include "content/public/browser/notification_registrar.h" 18#include "ui/app_list/app_list_view_delegate.h" 19 20class AppListControllerDelegate; 21class ExtensionAppModelBuilder; 22class Profile; 23 24namespace app_list { 25class SearchController; 26} 27 28namespace base { 29class FilePath; 30} 31 32namespace content { 33class NotificationDetails; 34class NotificationSource; 35} 36 37namespace gfx { 38class ImageSkia; 39} 40 41#if defined(USE_ASH) 42class AppSyncUIStateWatcher; 43#endif 44 45class AppListViewDelegate : public app_list::AppListViewDelegate, 46 public content::NotificationObserver, 47 public ProfileInfoCacheObserver { 48 public: 49 // The delegate will take ownership of the controller. 50 AppListViewDelegate(AppListControllerDelegate* controller, Profile* profile); 51 virtual ~AppListViewDelegate(); 52 53 private: 54 // Registers the current profile for notifications. 55 void RegisterForNotifications(); 56 // Updates the app list's current profile and ProfileMenuItems. 57 void OnProfileChanged(); 58 59 // Overridden from app_list::AppListViewDelegate: 60 virtual void SetProfileByPath(const base::FilePath& profile_path) OVERRIDE; 61 virtual void InitModel(app_list::AppListModel* model) OVERRIDE; 62 virtual app_list::SigninDelegate* GetSigninDelegate() OVERRIDE; 63 virtual void GetShortcutPathForApp( 64 const std::string& app_id, 65 const base::Callback<void(const base::FilePath&)>& callback) OVERRIDE; 66 virtual void StartSearch() OVERRIDE; 67 virtual void StopSearch() OVERRIDE; 68 virtual void OpenSearchResult(app_list::SearchResult* result, 69 int event_flags) OVERRIDE; 70 virtual void InvokeSearchResultAction(app_list::SearchResult* result, 71 int action_index, 72 int event_flags) OVERRIDE; 73 virtual void Dismiss() OVERRIDE; 74 virtual void ViewClosing() OVERRIDE; 75 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; 76 virtual void OpenSettings() OVERRIDE; 77 virtual void OpenHelp() OVERRIDE; 78 virtual void OpenFeedback() OVERRIDE; 79 virtual void ShowForProfileByPath( 80 const base::FilePath& profile_path) OVERRIDE; 81 virtual content::WebContents* GetStartPageContents() OVERRIDE; 82 83 // Overridden from content::NotificationObserver: 84 virtual void Observe(int type, 85 const content::NotificationSource& source, 86 const content::NotificationDetails& details) OVERRIDE; 87 88 // Overridden from ProfileInfoCacheObserver: 89 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; 90 virtual void OnProfileWasRemoved(const base::FilePath& profile_path, 91 const base::string16& profile_name) OVERRIDE; 92 virtual void OnProfileNameChanged( 93 const base::FilePath& profile_path, 94 const base::string16& old_profile_name) OVERRIDE; 95 96 scoped_ptr<ExtensionAppModelBuilder> apps_builder_; 97 scoped_ptr<app_list::SearchController> search_controller_; 98 scoped_ptr<AppListControllerDelegate> controller_; 99 Profile* profile_; 100 app_list::AppListModel* model_; // Weak. Owned by AppListView. 101 102 content::NotificationRegistrar registrar_; 103 ChromeSigninDelegate signin_delegate_; 104#if defined(USE_ASH) 105 scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_; 106#endif 107 108 DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate); 109}; 110 111#endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ 112