Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: chrome/browser/extensions/webstore_installer.h

Issue 175263003: Add chrome.webstore API methods to allow sites to see progress of installation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/supports_user_data.h" 14 #include "base/supports_user_data.h"
15 #include "base/timer/timer.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "base/version.h" 17 #include "base/version.h"
17 #include "chrome/browser/extensions/extension_install_prompt.h" 18 #include "chrome/browser/extensions/extension_install_prompt.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/download_interrupt_reasons.h" 20 #include "content/public/browser/download_interrupt_reasons.h"
20 #include "content/public/browser/download_item.h" 21 #include "content/public/browser/download_item.h"
21 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/web_contents_observer.h" 24 #include "content/public/browser/web_contents_observer.h"
24 #include "extensions/common/manifest_handlers/shared_module_info.h" 25 #include "extensions/common/manifest_handlers/shared_module_info.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Downloads next pending module in |pending_modules_|. 218 // Downloads next pending module in |pending_modules_|.
218 void DownloadNextPendingModule(); 219 void DownloadNextPendingModule();
219 220
220 // Downloads and installs a single Crx with the given |extension_id|. 221 // Downloads and installs a single Crx with the given |extension_id|.
221 // This function is used for both the extension Crx and dependences. 222 // This function is used for both the extension Crx and dependences.
222 void DownloadCrx(const std::string& extension_id, InstallSource source); 223 void DownloadCrx(const std::string& extension_id, InstallSource source);
223 224
224 // Starts downloading the extension to |file_path|. 225 // Starts downloading the extension to |file_path|.
225 void StartDownload(const base::FilePath& file_path); 226 void StartDownload(const base::FilePath& file_path);
226 227
228 // Updates the InstallTracker with the latest download progress.
229 void UpdateDownloadProgress();
230
227 // Reports an install |error| to the delegate for the given extension if this 231 // Reports an install |error| to the delegate for the given extension if this
228 // managed its installation. This also removes the associated PendingInstall. 232 // managed its installation. This also removes the associated PendingInstall.
229 void ReportFailure(const std::string& error, FailureReason reason); 233 void ReportFailure(const std::string& error, FailureReason reason);
230 234
231 // Reports a successful install to the delegate for the given extension if 235 // Reports a successful install to the delegate for the given extension if
232 // this managed its installation. This also removes the associated 236 // this managed its installation. This also removes the associated
233 // PendingInstall. 237 // PendingInstall.
234 void ReportSuccess(); 238 void ReportSuccess();
235 239
236 // Records stats regarding an interrupted webstore download item. 240 // Records stats regarding an interrupted webstore download item.
237 void RecordInterrupt(const content::DownloadItem* download) const; 241 void RecordInterrupt(const content::DownloadItem* download) const;
238 242
239 content::NotificationRegistrar registrar_; 243 content::NotificationRegistrar registrar_;
240 Profile* profile_; 244 Profile* profile_;
241 Delegate* delegate_; 245 Delegate* delegate_;
242 std::string id_; 246 std::string id_;
243 InstallSource install_source_; 247 InstallSource install_source_;
244 // The DownloadItem is owned by the DownloadManager and is valid from when 248 // The DownloadItem is owned by the DownloadManager and is valid from when
245 // OnDownloadStarted is called (with no error) until OnDownloadDestroyed(). 249 // OnDownloadStarted is called (with no error) until OnDownloadDestroyed().
246 content::DownloadItem* download_item_; 250 content::DownloadItem* download_item_;
251 // Used to periodically update the extension's download status. This will
252 // trigger at least every second, though sometimes more frequently (depending
253 // on number of modules, etc).
254 base::OneShotTimer<WebstoreInstaller> download_progress_timer_;
247 scoped_ptr<Approval> approval_; 255 scoped_ptr<Approval> approval_;
248 GURL download_url_; 256 GURL download_url_;
249 257
250 // Pending modules. 258 // Pending modules.
251 std::list<SharedModuleInfo::ImportInfo> pending_modules_; 259 std::list<SharedModuleInfo::ImportInfo> pending_modules_;
252 // Total extension modules we need download and install (the main module and 260 // Total extension modules we need download and install (the main module and
253 // depedences). 261 // depedences).
254 int total_modules_; 262 int total_modules_;
255 bool download_started_; 263 bool download_started_;
256 }; 264 };
257 265
258 } // namespace extensions 266 } // namespace extensions
259 267
260 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ 268 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_inline_installer_browsertest.cc ('k') | chrome/browser/extensions/webstore_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698