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/crx_installer.h" | 5 #include "chrome/browser/extensions/crx_installer.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 #include "content/public/browser/notification_service.h" | 44 #include "content/public/browser/notification_service.h" |
45 #include "content/public/browser/resource_dispatcher_host.h" | 45 #include "content/public/browser/resource_dispatcher_host.h" |
46 #include "content/public/browser/user_metrics.h" | 46 #include "content/public/browser/user_metrics.h" |
47 #include "grit/chromium_strings.h" | 47 #include "grit/chromium_strings.h" |
48 #include "grit/generated_resources.h" | 48 #include "grit/generated_resources.h" |
49 #include "grit/theme_resources.h" | 49 #include "grit/theme_resources.h" |
50 #include "third_party/skia/include/core/SkBitmap.h" | 50 #include "third_party/skia/include/core/SkBitmap.h" |
51 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
52 #include "ui/base/resource/resource_bundle.h" | 52 #include "ui/base/resource/resource_bundle.h" |
53 | 53 |
54 #if defined(OS_WIN) | |
55 #include "chrome/browser/extensions/app_host_installer_win.h" | |
56 #endif | |
57 | |
54 using content::BrowserThread; | 58 using content::BrowserThread; |
55 using content::UserMetricsAction; | 59 using content::UserMetricsAction; |
56 | 60 |
57 namespace extensions { | 61 namespace extensions { |
58 | 62 |
59 namespace { | 63 namespace { |
60 | 64 |
61 // Used in histograms; do not change order. | 65 // Used in histograms; do not change order. |
62 enum OffStoreInstallDecision { | 66 enum OffStoreInstallDecision { |
63 OnStoreInstall, | 67 OnStoreInstall, |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
501 Version current_version(current_version_); | 505 Version current_version(current_version_); |
502 if (current_version.CompareTo(*(extension_->version())) > 0) { | 506 if (current_version.CompareTo(*(extension_->version())) > 0) { |
503 ReportFailureFromFileThread( | 507 ReportFailureFromFileThread( |
504 CrxInstallerError( | 508 CrxInstallerError( |
505 l10n_util::GetStringUTF16(extension_->is_app() ? | 509 l10n_util::GetStringUTF16(extension_->is_app() ? |
506 IDS_APP_CANT_DOWNGRADE_VERSION : | 510 IDS_APP_CANT_DOWNGRADE_VERSION : |
507 IDS_EXTENSION_CANT_DOWNGRADE_VERSION))); | 511 IDS_EXTENSION_CANT_DOWNGRADE_VERSION))); |
508 return; | 512 return; |
509 } | 513 } |
510 } | 514 } |
515 #if defined(OS_WIN) | |
benwells
2012/10/03 05:08:43
This part of the codebase is platform independent.
huangs
2012/10/03 20:09:47
Done.
| |
516 if (extension_->is_platform_app()) { | |
517 // Ensures that App Host is present. | |
518 // Will call CompleteExtensionInstall() after. | |
519 // TODO(huangs): Should this be Unretained, or not? | |
520 app_host_installer_.EnsureAppHostPresentAndCall( | |
521 base::Bind(&CrxInstaller::CompleteExtensionInstall, | |
522 base::Unretained(this)), | |
523 base::Bind(&CrxInstaller::OnAppHostInstallFailure, | |
524 base::Unretained(this))); | |
525 } else { | |
526 CompleteExtensionInstall(); | |
527 } | |
511 | 528 |
529 #else | |
530 CompleteExtensionInstall(); | |
531 #endif | |
532 } | |
533 | |
534 void CrxInstaller::CompleteExtensionInstall() { | |
512 // See how long extension install paths are. This is important on | 535 // See how long extension install paths are. This is important on |
513 // windows, because file operations may fail if the path to a file | 536 // windows, because file operations may fail if the path to a file |
514 // exceeds a small constant. See crbug.com/69693 . | 537 // exceeds a small constant. See crbug.com/69693 . |
515 UMA_HISTOGRAM_CUSTOM_COUNTS( | 538 UMA_HISTOGRAM_CUSTOM_COUNTS( |
516 "Extensions.CrxInstallDirPathLength", | 539 "Extensions.CrxInstallDirPathLength", |
517 install_directory_.value().length(), 0, 500, 100); | 540 install_directory_.value().length(), 0, 500, 100); |
518 | 541 |
519 FilePath version_dir = extension_file_util::InstallExtension( | 542 FilePath version_dir = extension_file_util::InstallExtension( |
520 unpacked_extension_root_, | 543 unpacked_extension_root_, |
521 extension_->id(), | 544 extension_->id(), |
(...skipping 24 matching lines...) Expand all Loading... | |
546 | 569 |
547 if (extension_) { | 570 if (extension_) { |
548 ReportSuccessFromFileThread(); | 571 ReportSuccessFromFileThread(); |
549 } else { | 572 } else { |
550 LOG(ERROR) << error << " " << extension_id << " " << download_url_.spec(); | 573 LOG(ERROR) << error << " " << extension_id << " " << download_url_.spec(); |
551 ReportFailureFromFileThread(CrxInstallerError(UTF8ToUTF16(error))); | 574 ReportFailureFromFileThread(CrxInstallerError(UTF8ToUTF16(error))); |
552 } | 575 } |
553 | 576 |
554 } | 577 } |
555 | 578 |
579 #if defined(OS_WIN) | |
580 void CrxInstaller::OnAppHostInstallFailure() { | |
581 string16 error = L"Some random error message"; | |
benwells
2012/10/03 05:08:43
Ah, you did say work in progress....
huangs
2012/10/03 20:09:47
Yup. I moved this routine.
| |
582 ReportFailureFromFileThread(CrxInstallerError(error)); | |
583 } | |
584 #endif | |
585 | |
556 void CrxInstaller::ReportFailureFromFileThread(const CrxInstallerError& error) { | 586 void CrxInstaller::ReportFailureFromFileThread(const CrxInstallerError& error) { |
557 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 587 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
558 if (!BrowserThread::PostTask( | 588 if (!BrowserThread::PostTask( |
559 BrowserThread::UI, FROM_HERE, | 589 BrowserThread::UI, FROM_HERE, |
560 base::Bind(&CrxInstaller::ReportFailureFromUIThread, this, error))) { | 590 base::Bind(&CrxInstaller::ReportFailureFromUIThread, this, error))) { |
561 NOTREACHED(); | 591 NOTREACHED(); |
562 } | 592 } |
563 } | 593 } |
564 | 594 |
565 void CrxInstaller::ReportFailureFromUIThread(const CrxInstallerError& error) { | 595 void CrxInstaller::ReportFailureFromUIThread(const CrxInstallerError& error) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 // is problematic because they don't know anything about the | 681 // is problematic because they don't know anything about the |
652 // extension before it is unpacked, so they cannot filter based | 682 // extension before it is unpacked, so they cannot filter based |
653 // on the extension. | 683 // on the extension. |
654 content::NotificationService::current()->Notify( | 684 content::NotificationService::current()->Notify( |
655 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 685 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
656 content::Source<CrxInstaller>(this), | 686 content::Source<CrxInstaller>(this), |
657 content::Details<const Extension>(extension)); | 687 content::Details<const Extension>(extension)); |
658 } | 688 } |
659 | 689 |
660 } // namespace extensions | 690 } // namespace extensions |
OLD | NEW |