| OLD | NEW |
| 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 #include "chrome/browser/extensions/webstore_installer.h" | 5 #include "chrome/browser/extensions/webstore_installer.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 delegate_(delegate), | 283 delegate_(delegate), |
| 284 id_(id), | 284 id_(id), |
| 285 install_source_(source), | 285 install_source_(source), |
| 286 download_item_(NULL), | 286 download_item_(NULL), |
| 287 approval_(approval.release()), | 287 approval_(approval.release()), |
| 288 total_modules_(0), | 288 total_modules_(0), |
| 289 download_started_(false) { | 289 download_started_(false) { |
| 290 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 290 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 291 DCHECK(web_contents); | 291 DCHECK(web_contents); |
| 292 | 292 |
| 293 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 293 registrar_.Add(this, |
| 294 extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 294 content::Source<CrxInstaller>(NULL)); | 295 content::Source<CrxInstaller>(NULL)); |
| 295 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); | 296 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); |
| 296 } | 297 } |
| 297 | 298 |
| 298 void WebstoreInstaller::Start() { | 299 void WebstoreInstaller::Start() { |
| 299 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 300 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 300 AddRef(); // Balanced in ReportSuccess and ReportFailure. | 301 AddRef(); // Balanced in ReportSuccess and ReportFailure. |
| 301 | 302 |
| 302 if (!Extension::IdIsValid(id_)) { | 303 if (!Extension::IdIsValid(id_)) { |
| 303 ReportFailure(kInvalidIdError, FAILURE_REASON_OTHER); | 304 ReportFailure(kInvalidIdError, FAILURE_REASON_OTHER); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 354 |
| 354 // TODO(crbug.com/305343): Query manifest of dependencies before | 355 // TODO(crbug.com/305343): Query manifest of dependencies before |
| 355 // downloading & installing those dependencies. | 356 // downloading & installing those dependencies. |
| 356 DownloadNextPendingModule(); | 357 DownloadNextPendingModule(); |
| 357 } | 358 } |
| 358 | 359 |
| 359 void WebstoreInstaller::Observe(int type, | 360 void WebstoreInstaller::Observe(int type, |
| 360 const content::NotificationSource& source, | 361 const content::NotificationSource& source, |
| 361 const content::NotificationDetails& details) { | 362 const content::NotificationDetails& details) { |
| 362 switch (type) { | 363 switch (type) { |
| 363 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: { | 364 case extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR: { |
| 364 CrxInstaller* crx_installer = content::Source<CrxInstaller>(source).ptr(); | 365 CrxInstaller* crx_installer = content::Source<CrxInstaller>(source).ptr(); |
| 365 CHECK(crx_installer); | 366 CHECK(crx_installer); |
| 366 if (crx_installer != crx_installer_.get()) | 367 if (crx_installer != crx_installer_.get()) |
| 367 return; | 368 return; |
| 368 | 369 |
| 369 // TODO(rdevlin.cronin): Continue removing std::string errors and | 370 // TODO(rdevlin.cronin): Continue removing std::string errors and |
| 370 // replacing with base::string16. See crbug.com/71980. | 371 // replacing with base::string16. See crbug.com/71980. |
| 371 const base::string16* error = | 372 const base::string16* error = |
| 372 content::Details<const base::string16>(details).ptr(); | 373 content::Details<const base::string16>(details).ptr(); |
| 373 const std::string utf8_error = base::UTF16ToUTF8(*error); | 374 const std::string utf8_error = base::UTF16ToUTF8(*error); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 1, | 744 1, |
| 744 kMaxSizeKb, | 745 kMaxSizeKb, |
| 745 kNumBuckets); | 746 kNumBuckets); |
| 746 } | 747 } |
| 747 UMA_HISTOGRAM_BOOLEAN( | 748 UMA_HISTOGRAM_BOOLEAN( |
| 748 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", | 749 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", |
| 749 total_bytes <= 0); | 750 total_bytes <= 0); |
| 750 } | 751 } |
| 751 | 752 |
| 752 } // namespace extensions | 753 } // namespace extensions |
| OLD | NEW |