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" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
21 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
23 #include "base/version.h" | 23 #include "base/version.h" |
24 #include "chrome/browser/chrome_notification_types.h" | |
25 #include "chrome/browser/extensions/convert_user_script.h" | 24 #include "chrome/browser/extensions/convert_user_script.h" |
26 #include "chrome/browser/extensions/convert_web_app.h" | 25 #include "chrome/browser/extensions/convert_web_app.h" |
27 #include "chrome/browser/extensions/crx_installer_error.h" | 26 #include "chrome/browser/extensions/crx_installer_error.h" |
28 #include "chrome/browser/extensions/extension_assets_manager.h" | 27 #include "chrome/browser/extensions/extension_assets_manager.h" |
29 #include "chrome/browser/extensions/extension_error_reporter.h" | 28 #include "chrome/browser/extensions/extension_error_reporter.h" |
30 #include "chrome/browser/extensions/extension_install_ui.h" | 29 #include "chrome/browser/extensions/extension_install_ui.h" |
31 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
32 #include "chrome/browser/extensions/install_tracker.h" | 31 #include "chrome/browser/extensions/install_tracker.h" |
33 #include "chrome/browser/extensions/install_tracker_factory.h" | 32 #include "chrome/browser/extensions/install_tracker_factory.h" |
34 #include "chrome/browser/extensions/permissions_updater.h" | 33 #include "chrome/browser/extensions/permissions_updater.h" |
35 #include "chrome/browser/extensions/webstore_installer.h" | 34 #include "chrome/browser/extensions/webstore_installer.h" |
36 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
37 #include "chrome/browser/web_applications/web_app.h" | 36 #include "chrome/browser/web_applications/web_app.h" |
38 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
39 #include "chrome/common/extensions/extension_constants.h" | 38 #include "chrome/common/extensions/extension_constants.h" |
40 #include "chrome/common/extensions/manifest_url_handler.h" | 39 #include "chrome/common/extensions/manifest_url_handler.h" |
41 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
43 #include "content/public/browser/resource_dispatcher_host.h" | 42 #include "content/public/browser/resource_dispatcher_host.h" |
44 #include "content/public/browser/user_metrics.h" | 43 #include "content/public/browser/user_metrics.h" |
45 #include "extensions/browser/extension_prefs.h" | 44 #include "extensions/browser/extension_prefs.h" |
46 #include "extensions/browser/extension_system.h" | 45 #include "extensions/browser/extension_system.h" |
47 #include "extensions/browser/install_flag.h" | 46 #include "extensions/browser/install_flag.h" |
| 47 #include "extensions/browser/notification_types.h" |
48 #include "extensions/common/extension_icon_set.h" | 48 #include "extensions/common/extension_icon_set.h" |
49 #include "extensions/common/feature_switch.h" | 49 #include "extensions/common/feature_switch.h" |
50 #include "extensions/common/file_util.h" | 50 #include "extensions/common/file_util.h" |
51 #include "extensions/common/manifest.h" | 51 #include "extensions/common/manifest.h" |
52 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" | 52 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" |
53 #include "extensions/common/manifest_handlers/shared_module_info.h" | 53 #include "extensions/common/manifest_handlers/shared_module_info.h" |
54 #include "extensions/common/permissions/permission_message_provider.h" | 54 #include "extensions/common/permissions/permission_message_provider.h" |
55 #include "extensions/common/permissions/permission_set.h" | 55 #include "extensions/common/permissions/permission_set.h" |
56 #include "extensions/common/permissions/permissions_data.h" | 56 #include "extensions/common/permissions/permissions_data.h" |
57 #include "extensions/common/user_script.h" | 57 #include "extensions/common/user_script.h" |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 } | 743 } |
744 | 744 |
745 void CrxInstaller::ReportFailureFromUIThread(const CrxInstallerError& error) { | 745 void CrxInstaller::ReportFailureFromUIThread(const CrxInstallerError& error) { |
746 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 746 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
747 | 747 |
748 if (!service_weak_.get() || service_weak_->browser_terminating()) | 748 if (!service_weak_.get() || service_weak_->browser_terminating()) |
749 return; | 749 return; |
750 | 750 |
751 content::NotificationService* service = | 751 content::NotificationService* service = |
752 content::NotificationService::current(); | 752 content::NotificationService::current(); |
753 service->Notify(chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 753 service->Notify(extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
754 content::Source<CrxInstaller>(this), | 754 content::Source<CrxInstaller>(this), |
755 content::Details<const base::string16>(&error.message())); | 755 content::Details<const base::string16>(&error.message())); |
756 | 756 |
757 // This isn't really necessary, it is only used because unit tests expect to | 757 // This isn't really necessary, it is only used because unit tests expect to |
758 // see errors get reported via this interface. | 758 // see errors get reported via this interface. |
759 // | 759 // |
760 // TODO(aa): Need to go through unit tests and clean them up too, probably get | 760 // TODO(aa): Need to go through unit tests and clean them up too, probably get |
761 // rid of this line. | 761 // rid of this line. |
762 ExtensionErrorReporter::GetInstance()->ReportError( | 762 ExtensionErrorReporter::GetInstance()->ReportError( |
763 error.message(), | 763 error.message(), |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 ->OnBeginCrxInstall(expected_id_); | 818 ->OnBeginCrxInstall(expected_id_); |
819 } | 819 } |
820 | 820 |
821 void CrxInstaller::NotifyCrxInstallComplete(bool success) { | 821 void CrxInstaller::NotifyCrxInstallComplete(bool success) { |
822 // Some users (such as the download shelf) need to know when a | 822 // Some users (such as the download shelf) need to know when a |
823 // CRXInstaller is done. Listening for the EXTENSION_* events | 823 // CRXInstaller is done. Listening for the EXTENSION_* events |
824 // is problematic because they don't know anything about the | 824 // is problematic because they don't know anything about the |
825 // extension before it is unpacked, so they cannot filter based | 825 // extension before it is unpacked, so they cannot filter based |
826 // on the extension. | 826 // on the extension. |
827 content::NotificationService::current()->Notify( | 827 content::NotificationService::current()->Notify( |
828 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 828 extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
829 content::Source<CrxInstaller>(this), | 829 content::Source<CrxInstaller>(this), |
830 content::Details<const Extension>( | 830 content::Details<const Extension>(success ? extension() : NULL)); |
831 success ? extension() : NULL)); | |
832 | 831 |
833 InstallTrackerFactory::GetForBrowserContext(profile()) | 832 InstallTrackerFactory::GetForBrowserContext(profile()) |
834 ->OnFinishCrxInstall(success ? extension()->id() : expected_id_, success); | 833 ->OnFinishCrxInstall(success ? extension()->id() : expected_id_, success); |
835 | 834 |
836 if (success) | 835 if (success) |
837 ConfirmReEnable(); | 836 ConfirmReEnable(); |
838 } | 837 } |
839 | 838 |
840 void CrxInstaller::CleanupTempFiles() { | 839 void CrxInstaller::CleanupTempFiles() { |
841 if (!installer_task_runner_->RunsTasksOnCurrentThread()) { | 840 if (!installer_task_runner_->RunsTasksOnCurrentThread()) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) | 893 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) |
895 return; | 894 return; |
896 | 895 |
897 if (client_) { | 896 if (client_) { |
898 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). | 897 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). |
899 client_->ConfirmReEnable(this, extension()); | 898 client_->ConfirmReEnable(this, extension()); |
900 } | 899 } |
901 } | 900 } |
902 | 901 |
903 } // namespace extensions | 902 } // namespace extensions |
OLD | NEW |