#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/scoped_observer.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
+#include "chrome/browser/extensions/updater/extension_downloader.h"
#include "chrome/browser/extensions/updater/extension_downloader_delegate.h"
#include "chrome/browser/extensions/updater/manifest_fetch_data.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "extensions/browser/extension_registry_observer.h"
#include "url/gurl.h"
class ExtensionServiceInterface;
class PrefService;
class Profile;
+namespace content {
+class BrowserContext;
+}
+
namespace extensions {
class ExtensionCache;
-class ExtensionDownloader;
class ExtensionPrefs;
+class ExtensionRegistry;
class ExtensionSet;
class ExtensionUpdaterTest;
// extension_prefs,
// pref_service,
// profile,
-// update_frequency_secs);
+// update_frequency_secs,
+// downloader_factory);
// updater->Start();
// ....
// updater->Stop();
class ExtensionUpdater : public ExtensionDownloaderDelegate,
+ public ExtensionRegistryObserver,
public content::NotificationObserver {
public:
typedef base::Closure FinishedCallback;
PrefService* prefs,
Profile* profile,
int frequency_seconds,
- ExtensionCache* cache);
+ ExtensionCache* cache,
+ const ExtensionDownloader::Factory& downloader_factory);
virtual ~ExtensionUpdater();
struct ThrottleInfo;
+ // Ensure that we have a valid ExtensionDownloader instance referenced by
+ // |downloader|.
+ void EnsureDownloaderCreated();
+
// Computes when to schedule the first update check.
base::TimeDelta DetermineFirstCheckDelay();
// Posted by CheckSoon().
void DoCheckSoon();
- // Implenentation of ExtensionDownloaderDelegate.
+ // Implementation of ExtensionDownloaderDelegate.
virtual void OnExtensionDownloadFailed(
const std::string& id,
Error error,
const PingResult& ping,
const std::set<int>& request_id) OVERRIDE;
+ // Implementation of ExtensionRegistryObserver.
+ virtual void OnExtensionWillBeInstalled(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ bool is_update,
+ bool from_ephemeral,
+ const std::string& old_name) OVERRIDE;
+
virtual bool GetPingDataForExtension(
const std::string& id,
ManifestFetchData::PingData* ping_data) OVERRIDE;
// Pointer back to the service that owns this ExtensionUpdater.
ExtensionServiceInterface* service_;
+ // A closure passed into the ExtensionUpdater to teach it how to construct
+ // new ExtensionDownloader instances.
+ const ExtensionDownloader::Factory downloader_factory_;
+
// Fetches the crx files for the extensions that have an available update.
scoped_ptr<ExtensionDownloader> downloader_;
// Observes CRX installs we initiate.
content::NotificationRegistrar registrar_;
+ ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+ extension_registry_observer_;
+
// True when a CrxInstaller is doing an install. Used in MaybeUpdateCrxFile()
// to keep more than one install from running at once.
bool crx_install_is_running_;