recommended_apps.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1// Copyright 2013 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_RECOMMENDED_APPS_H_ 6#define CHROME_BROWSER_UI_APP_LIST_RECOMMENDED_APPS_H_ 7 8#include <vector> 9 10#include "base/basictypes.h" 11#include "base/memory/ref_counted.h" 12#include "base/observer_list.h" 13#include "base/prefs/pref_change_registrar.h" 14#include "chrome/browser/extensions/install_observer.h" 15 16class Profile; 17 18namespace app_list { 19 20class RecommendedAppsObserver; 21 22// A class that maintains a list of recommended apps by watching changes 23// to app state. 24class RecommendedApps : public extensions::InstallObserver { 25 public: 26 typedef std::vector<scoped_refptr<const extensions::Extension> > Apps; 27 28 explicit RecommendedApps(Profile* profile); 29 virtual ~RecommendedApps(); 30 31 void AddObserver(RecommendedAppsObserver* observer); 32 void RemoveObserver(RecommendedAppsObserver* observer); 33 34 const Apps& apps() const { return apps_; } 35 36 private: 37 void Update(); 38 39 // extensions::InstallObserver overrides: 40 virtual void OnExtensionInstalled( 41 const extensions::Extension* extension) OVERRIDE; 42 virtual void OnExtensionLoaded( 43 const extensions::Extension* extension) OVERRIDE; 44 virtual void OnExtensionUnloaded( 45 const extensions::Extension* extension) OVERRIDE; 46 virtual void OnExtensionUninstalled( 47 const extensions::Extension* extension) OVERRIDE; 48 49 Profile* profile_; 50 PrefChangeRegistrar pref_change_registrar_; 51 52 Apps apps_; 53 ObserverList<RecommendedAppsObserver, true> observers_; 54 55 DISALLOW_COPY_AND_ASSIGN(RecommendedApps); 56}; 57 58} // namespace app_list 59 60#endif // CHROME_BROWSER_UI_APP_LIST_RECOMMENDED_APPS_H_ 61