app_list_view_delegate.h revision 8bcbed890bc3ce4d7a057a8f32cab53fa534672e
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(scoped_ptr<AppListControllerDelegate> controller, 51 Profile* profile); 52 virtual ~AppListViewDelegate(); 53 54 private: 55 // Registers the current profile for notifications. 56 void RegisterForNotifications(); 57 // Updates the app list's current profile and ProfileMenuItems. 58 void OnProfileChanged(); 59 60 // Overridden from app_list::AppListViewDelegate: 61 virtual void SetProfileByPath(const base::FilePath& profile_path) OVERRIDE; 62 virtual void InitModel(app_list::AppListModel* model) OVERRIDE; 63 virtual app_list::SigninDelegate* GetSigninDelegate() OVERRIDE; 64 virtual void GetShortcutPathForApp( 65 const std::string& app_id, 66 const base::Callback<void(const base::FilePath&)>& callback) OVERRIDE; 67 virtual void StartSearch() OVERRIDE; 68 virtual void StopSearch() OVERRIDE; 69 virtual void OpenSearchResult(app_list::SearchResult* result, 70 int event_flags) OVERRIDE; 71 virtual void InvokeSearchResultAction(app_list::SearchResult* result, 72 int action_index, 73 int event_flags) OVERRIDE; 74 virtual void Dismiss() OVERRIDE; 75 virtual void ViewClosing() OVERRIDE; 76 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; 77 virtual void OpenSettings() OVERRIDE; 78 virtual void OpenHelp() OVERRIDE; 79 virtual void OpenFeedback() OVERRIDE; 80 virtual void ShowForProfileByPath( 81 const base::FilePath& profile_path) OVERRIDE; 82 virtual content::WebContents* GetStartPageContents() OVERRIDE; 83 84 // Overridden from content::NotificationObserver: 85 virtual void Observe(int type, 86 const content::NotificationSource& source, 87 const content::NotificationDetails& details) OVERRIDE; 88 89 // Overridden from ProfileInfoCacheObserver: 90 virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE; 91 virtual void OnProfileWasRemoved(const base::FilePath& profile_path, 92 const base::string16& profile_name) OVERRIDE; 93 virtual void OnProfileNameChanged( 94 const base::FilePath& profile_path, 95 const base::string16& old_profile_name) OVERRIDE; 96 97 scoped_ptr<ExtensionAppModelBuilder> apps_builder_; 98 scoped_ptr<app_list::SearchController> search_controller_; 99 scoped_ptr<AppListControllerDelegate> controller_; 100 Profile* profile_; 101 app_list::AppListModel* model_; // Weak. Owned by AppListView. 102 103 content::NotificationRegistrar registrar_; 104 ChromeSigninDelegate signin_delegate_; 105#if defined(USE_ASH) 106 scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_; 107#endif 108 109 DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate); 110}; 111 112#endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_ 113