| 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/files/file_util.h" | 11 #include "base/files/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/extensions/convert_user_script.h" | 24 #include "chrome/browser/extensions/convert_user_script.h" |
| 25 #include "chrome/browser/extensions/convert_web_app.h" | 25 #include "chrome/browser/extensions/convert_web_app.h" |
| 26 #include "chrome/browser/extensions/crx_installer_error.h" | |
| 27 #include "chrome/browser/extensions/extension_assets_manager.h" | 26 #include "chrome/browser/extensions/extension_assets_manager.h" |
| 28 #include "chrome/browser/extensions/extension_error_reporter.h" | 27 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 29 #include "chrome/browser/extensions/extension_install_ui.h" | |
| 30 #include "chrome/browser/extensions/extension_service.h" | 28 #include "chrome/browser/extensions/extension_service.h" |
| 31 #include "chrome/browser/extensions/install_tracker.h" | 29 #include "chrome/browser/extensions/install_tracker.h" |
| 32 #include "chrome/browser/extensions/install_tracker_factory.h" | 30 #include "chrome/browser/extensions/install_tracker_factory.h" |
| 33 #include "chrome/browser/extensions/permissions_updater.h" | 31 #include "chrome/browser/extensions/permissions_updater.h" |
| 34 #include "chrome/browser/extensions/webstore_installer.h" | 32 #include "chrome/browser/extensions/webstore_installer.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/web_applications/web_app.h" | 34 #include "chrome/browser/web_applications/web_app.h" |
| 37 #include "chrome/common/chrome_paths.h" | 35 #include "chrome/common/chrome_paths.h" |
| 38 #include "chrome/common/extensions/extension_constants.h" | 36 #include "chrome/common/extensions/extension_constants.h" |
| 39 #include "chrome/common/extensions/manifest_url_handler.h" | 37 #include "chrome/common/extensions/manifest_url_handler.h" |
| 40 #include "chrome/grit/generated_resources.h" | 38 #include "chrome/grit/generated_resources.h" |
| 41 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 42 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
| 43 #include "content/public/browser/resource_dispatcher_host.h" | 41 #include "content/public/browser/resource_dispatcher_host.h" |
| 44 #include "content/public/browser/user_metrics.h" | 42 #include "content/public/browser/user_metrics.h" |
| 45 #include "extensions/browser/extension_prefs.h" | 43 #include "extensions/browser/extension_prefs.h" |
| 46 #include "extensions/browser/extension_system.h" | 44 #include "extensions/browser/extension_system.h" |
| 45 #include "extensions/browser/install/crx_installer_error.h" |
| 46 #include "extensions/browser/install/extension_install_ui.h" |
| 47 #include "extensions/browser/install_flag.h" | 47 #include "extensions/browser/install_flag.h" |
| 48 #include "extensions/browser/notification_types.h" | 48 #include "extensions/browser/notification_types.h" |
| 49 #include "extensions/common/extension_icon_set.h" | 49 #include "extensions/common/extension_icon_set.h" |
| 50 #include "extensions/common/feature_switch.h" | 50 #include "extensions/common/feature_switch.h" |
| 51 #include "extensions/common/file_util.h" | 51 #include "extensions/common/file_util.h" |
| 52 #include "extensions/common/manifest.h" | 52 #include "extensions/common/manifest.h" |
| 53 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" | 53 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" |
| 54 #include "extensions/common/manifest_handlers/shared_module_info.h" | 54 #include "extensions/common/manifest_handlers/shared_module_info.h" |
| 55 #include "extensions/common/permissions/permission_message_provider.h" | 55 #include "extensions/common/permissions/permission_message_provider.h" |
| 56 #include "extensions/common/permissions/permission_set.h" | 56 #include "extensions/common/permissions/permission_set.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 install_flags_(kInstallFlagNone), | 132 install_flags_(kInstallFlagNone), |
| 133 install_checker_(service_weak->profile()) { | 133 install_checker_(service_weak->profile()) { |
| 134 installer_task_runner_ = service_weak->GetFileTaskRunner(); | 134 installer_task_runner_ = service_weak->GetFileTaskRunner(); |
| 135 if (!approval) | 135 if (!approval) |
| 136 return; | 136 return; |
| 137 | 137 |
| 138 CHECK(profile()->IsSameProfile(approval->profile)); | 138 CHECK(profile()->IsSameProfile(approval->profile)); |
| 139 if (client_) { | 139 if (client_) { |
| 140 client_->install_ui()->SetUseAppInstalledBubble( | 140 client_->install_ui()->SetUseAppInstalledBubble( |
| 141 approval->use_app_installed_bubble); | 141 approval->use_app_installed_bubble); |
| 142 client_->install_ui()->set_skip_post_install_ui( | 142 client_->install_ui()->SetSkipPostInstallUI( |
| 143 approval->skip_post_install_ui); | 143 approval->skip_post_install_ui); |
| 144 } | 144 } |
| 145 | 145 |
| 146 if (approval->skip_install_dialog) { | 146 if (approval->skip_install_dialog) { |
| 147 // Mark the extension as approved, but save the expected manifest and ID | 147 // Mark the extension as approved, but save the expected manifest and ID |
| 148 // so we can check that they match the CRX's. | 148 // so we can check that they match the CRX's. |
| 149 approved_ = true; | 149 approved_ = true; |
| 150 expected_manifest_check_level_ = approval->manifest_check_level; | 150 expected_manifest_check_level_ = approval->manifest_check_level; |
| 151 if (expected_manifest_check_level_ != | 151 if (expected_manifest_check_level_ != |
| 152 WebstoreInstaller::MANIFEST_CHECK_LEVEL_NONE) | 152 WebstoreInstaller::MANIFEST_CHECK_LEVEL_NONE) |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 // NOTE: extension may still be blacklisted, but we're forced to silently | 564 // NOTE: extension may still be blacklisted, but we're forced to silently |
| 565 // install it. In this case, ExtensionService::OnExtensionInstalled needs to | 565 // install it. In this case, ExtensionService::OnExtensionInstalled needs to |
| 566 // deal with it. | 566 // deal with it. |
| 567 | 567 |
| 568 // Check for policy errors. | 568 // Check for policy errors. |
| 569 if (!install_checker_.policy_error().empty()) { | 569 if (!install_checker_.policy_error().empty()) { |
| 570 // We don't want to show the error infobar for installs from the WebStore, | 570 // We don't want to show the error infobar for installs from the WebStore, |
| 571 // because the WebStore already shows an error dialog itself. | 571 // because the WebStore already shows an error dialog itself. |
| 572 // Note: |client_| can be NULL in unit_tests! | 572 // Note: |client_| can be NULL in unit_tests! |
| 573 if (extension()->from_webstore() && client_) | 573 if (extension()->from_webstore() && client_) |
| 574 client_->install_ui()->set_skip_post_install_ui(true); | 574 client_->install_ui()->SetSkipPostInstallUI(true); |
| 575 ReportFailureFromUIThread( | 575 ReportFailureFromUIThread( |
| 576 CrxInstallerError(base::UTF8ToUTF16(install_checker_.policy_error()))); | 576 CrxInstallerError(base::UTF8ToUTF16(install_checker_.policy_error()))); |
| 577 return; | 577 return; |
| 578 } | 578 } |
| 579 | 579 |
| 580 ConfirmInstall(); | 580 ConfirmInstall(); |
| 581 } | 581 } |
| 582 | 582 |
| 583 void CrxInstaller::ConfirmInstall() { | 583 void CrxInstaller::ConfirmInstall() { |
| 584 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 584 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) | 908 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) |
| 909 return; | 909 return; |
| 910 | 910 |
| 911 if (client_) { | 911 if (client_) { |
| 912 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). | 912 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). |
| 913 client_->ConfirmReEnable(this, extension()); | 913 client_->ConfirmReEnable(this, extension()); |
| 914 } | 914 } |
| 915 } | 915 } |
| 916 | 916 |
| 917 } // namespace extensions | 917 } // namespace extensions |
| OLD | NEW |