Add chrome.webstore API methods to allow sites to see progress of installation
Add two chrome.webstore API methods for progress updates:
  chrome.webstore.setInstallStageListener(function(string stage))
  - stage is either "downloading" or "installing"
  chrome.webstore.setDownloadProgressListener(function(int percent_downloaded))
Update InstallObserver to have methods for install stages.
Make WebstoreInstaller provide more frequent download updates (current consumers
like WebstoreResult imply this was intended from the start).
BUG=308634

Review URL: https://codereview.chromium.org/175263003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259483 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/webstore_installer.h b/chrome/browser/extensions/webstore_installer.h
index a8b6ce4..25b2181d 100644
--- a/chrome/browser/extensions/webstore_installer.h
+++ b/chrome/browser/extensions/webstore_installer.h
@@ -12,6 +12,7 @@
 #include "base/memory/ref_counted.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/supports_user_data.h"
+#include "base/timer/timer.h"
 #include "base/values.h"
 #include "base/version.h"
 #include "chrome/browser/extensions/extension_install_prompt.h"
@@ -224,6 +225,9 @@
   // Starts downloading the extension to |file_path|.
   void StartDownload(const base::FilePath& file_path);
 
+  // Updates the InstallTracker with the latest download progress.
+  void UpdateDownloadProgress();
+
   // Reports an install |error| to the delegate for the given extension if this
   // managed its installation. This also removes the associated PendingInstall.
   void ReportFailure(const std::string& error, FailureReason reason);
@@ -244,6 +248,10 @@
   // The DownloadItem is owned by the DownloadManager and is valid from when
   // OnDownloadStarted is called (with no error) until OnDownloadDestroyed().
   content::DownloadItem* download_item_;
+  // Used to periodically update the extension's download status. This will
+  // trigger at least every second, though sometimes more frequently (depending
+  // on number of modules, etc).
+  base::OneShotTimer<WebstoreInstaller> download_progress_timer_;
   scoped_ptr<Approval> approval_;
   GURL download_url_;