Home | History | Annotate | Download | only in extensions
      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_EXTENSIONS_INSTALL_TRACKER_H_
      6 #define CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_
      7 
      8 #include "base/observer_list.h"
      9 #include "base/prefs/pref_change_registrar.h"
     10 #include "chrome/browser/extensions/install_observer.h"
     11 #include "components/keyed_service/core/keyed_service.h"
     12 #include "content/public/browser/notification_observer.h"
     13 #include "content/public/browser/notification_registrar.h"
     14 
     15 class Profile;
     16 
     17 namespace content {
     18 class BrowserContext;
     19 }
     20 
     21 namespace extensions {
     22 
     23 class ExtensionPrefs;
     24 
     25 class InstallTracker : public KeyedService,
     26                        public content::NotificationObserver {
     27  public:
     28   InstallTracker(Profile* profile,
     29                  extensions::ExtensionPrefs* prefs);
     30   virtual ~InstallTracker();
     31 
     32   static InstallTracker* Get(content::BrowserContext* context);
     33 
     34   void AddObserver(InstallObserver* observer);
     35   void RemoveObserver(InstallObserver* observer);
     36 
     37   void OnBeginExtensionInstall(
     38       const InstallObserver::ExtensionInstallParams& params);
     39   void OnBeginExtensionDownload(const std::string& extension_id);
     40   void OnDownloadProgress(const std::string& extension_id,
     41                           int percent_downloaded);
     42   void OnBeginCrxInstall(const std::string& extension_id);
     43   void OnFinishCrxInstall(const std::string& extension_id, bool success);
     44   void OnInstallFailure(const std::string& extension_id);
     45 
     46   // NOTE(limasdf): For extension [un]load and [un]installed, use
     47   //                ExtensionRegistryObserver.
     48 
     49   // Overriddes for KeyedService.
     50   virtual void Shutdown() OVERRIDE;
     51 
     52  private:
     53   void OnAppsReordered();
     54 
     55   // content::NotificationObserver implementation.
     56   virtual void Observe(int type,
     57                        const content::NotificationSource& source,
     58                        const content::NotificationDetails& details) OVERRIDE;
     59 
     60   ObserverList<InstallObserver> observers_;
     61   content::NotificationRegistrar registrar_;
     62   PrefChangeRegistrar pref_change_registrar_;
     63 
     64   DISALLOW_COPY_AND_ASSIGN(InstallTracker);
     65 };
     66 
     67 }  // namespace extensions
     68 
     69 #endif  // CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_
     70