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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 return; | 349 return; |
350 SharedModuleInfo::ImportInfo info = pending_modules_.front(); | 350 SharedModuleInfo::ImportInfo info = pending_modules_.front(); |
351 if (extension->id() != info.extension_id) | 351 if (extension->id() != info.extension_id) |
352 return; | 352 return; |
353 pending_modules_.pop_front(); | 353 pending_modules_.pop_front(); |
354 | 354 |
355 if (pending_modules_.empty()) { | 355 if (pending_modules_.empty()) { |
356 CHECK_EQ(extension->id(), id_); | 356 CHECK_EQ(extension->id(), id_); |
357 ReportSuccess(); | 357 ReportSuccess(); |
358 } else { | 358 } else { |
359 const base::Version version_required(info.minimum_version); | 359 const Version version_required(info.minimum_version); |
360 if (version_required.IsValid() && | 360 if (version_required.IsValid() && |
361 extension->version()->CompareTo(version_required) < 0) { | 361 extension->version()->CompareTo(version_required) < 0) { |
362 // It should not happen, CrxInstaller will make sure the version is | 362 // It should not happen, CrxInstaller will make sure the version is |
363 // equal or newer than version_required. | 363 // equal or newer than version_required. |
364 ReportFailure(kDependencyNotFoundError, | 364 ReportFailure(kDependencyNotFoundError, |
365 FAILURE_REASON_DEPENDENCY_NOT_FOUND); | 365 FAILURE_REASON_DEPENDENCY_NOT_FOUND); |
366 } else if (!SharedModuleInfo::IsSharedModule(extension)) { | 366 } else if (!SharedModuleInfo::IsSharedModule(extension)) { |
367 // It should not happen, CrxInstaller will make sure it is a shared | 367 // It should not happen, CrxInstaller will make sure it is a shared |
368 // module. | 368 // module. |
369 ReportFailure(kDependencyNotSharedModuleError, | 369 ReportFailure(kDependencyNotSharedModuleError, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 423 |
424 DCHECK_EQ(net::OK, error); | 424 DCHECK_EQ(net::OK, error); |
425 DCHECK(!pending_modules_.empty()); | 425 DCHECK(!pending_modules_.empty()); |
426 download_item_ = item; | 426 download_item_ = item; |
427 download_item_->AddObserver(this); | 427 download_item_->AddObserver(this); |
428 if (pending_modules_.size() > 1) { | 428 if (pending_modules_.size() > 1) { |
429 // We are downloading a shared module. We need create an approval for it. | 429 // We are downloading a shared module. We need create an approval for it. |
430 scoped_ptr<Approval> approval = Approval::CreateForSharedModule(profile_); | 430 scoped_ptr<Approval> approval = Approval::CreateForSharedModule(profile_); |
431 const SharedModuleInfo::ImportInfo& info = pending_modules_.front(); | 431 const SharedModuleInfo::ImportInfo& info = pending_modules_.front(); |
432 approval->extension_id = info.extension_id; | 432 approval->extension_id = info.extension_id; |
433 const base::Version version_required(info.minimum_version); | 433 const Version version_required(info.minimum_version); |
434 | 434 |
435 if (version_required.IsValid()) { | 435 if (version_required.IsValid()) { |
436 approval->minimum_version.reset( | 436 approval->minimum_version.reset( |
437 new base::Version(version_required)); | 437 new Version(version_required)); |
438 } | 438 } |
439 download_item_->SetUserData(kApprovalKey, approval.release()); | 439 download_item_->SetUserData(kApprovalKey, approval.release()); |
440 } else { | 440 } else { |
441 // It is for the main module of the extension. We should use the provided | 441 // It is for the main module of the extension. We should use the provided |
442 // |approval_|. | 442 // |approval_|. |
443 if (approval_) | 443 if (approval_) |
444 download_item_->SetUserData(kApprovalKey, approval_.release()); | 444 download_item_->SetUserData(kApprovalKey, approval_.release()); |
445 } | 445 } |
446 | 446 |
447 if (!download_started_) { | 447 if (!download_started_) { |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 1, | 659 1, |
660 kMaxSizeKb, | 660 kMaxSizeKb, |
661 kNumBuckets); | 661 kNumBuckets); |
662 } | 662 } |
663 UMA_HISTOGRAM_BOOLEAN( | 663 UMA_HISTOGRAM_BOOLEAN( |
664 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", | 664 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", |
665 total_bytes <= 0); | 665 total_bytes <= 0); |
666 } | 666 } |
667 | 667 |
668 } // namespace extensions | 668 } // namespace extensions |
OLD | NEW |