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/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.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/scoped_temp_dir.h" | 16 #include "base/scoped_temp_dir.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
19 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
20 #include "base/time.h" | 20 #include "base/time.h" |
21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
22 #include "base/version.h" | 22 #include "base/version.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.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/default_apps_trial.h" | 26 #include "chrome/browser/extensions/default_apps_trial.h" |
27 #include "chrome/browser/extensions/extension_error_reporter.h" | 27 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 28 #include "chrome/browser/extensions/extension_install_dialog.h" |
28 #include "chrome/browser/extensions/extension_install_ui.h" | 29 #include "chrome/browser/extensions/extension_install_ui.h" |
29 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
30 #include "chrome/browser/extensions/extension_system.h" | 31 #include "chrome/browser/extensions/extension_system.h" |
31 #include "chrome/browser/extensions/permissions_updater.h" | 32 #include "chrome/browser/extensions/permissions_updater.h" |
32 #include "chrome/browser/extensions/requirements_checker.h" | 33 #include "chrome/browser/extensions/requirements_checker.h" |
33 #include "chrome/browser/extensions/webstore_installer.h" | 34 #include "chrome/browser/extensions/webstore_installer.h" |
34 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
35 #include "chrome/browser/shell_integration.h" | 36 #include "chrome/browser/shell_integration.h" |
36 #include "chrome/browser/web_applications/web_app.h" | 37 #include "chrome/browser/web_applications/web_app.h" |
37 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 118 } |
118 | 119 |
119 if (approval->skip_install_dialog) { | 120 if (approval->skip_install_dialog) { |
120 // Mark the extension as approved, but save the expected manifest and ID | 121 // Mark the extension as approved, but save the expected manifest and ID |
121 // so we can check that they match the CRX's. | 122 // so we can check that they match the CRX's. |
122 approved_ = true; | 123 approved_ = true; |
123 expected_manifest_.reset(approval->parsed_manifest->DeepCopy()); | 124 expected_manifest_.reset(approval->parsed_manifest->DeepCopy()); |
124 expected_id_ = approval->extension_id; | 125 expected_id_ = approval->extension_id; |
125 record_oauth2_grant_ = approval->record_oauth2_grant; | 126 record_oauth2_grant_ = approval->record_oauth2_grant; |
126 } | 127 } |
| 128 |
| 129 dialog_ = approval->dialog_; |
| 130 if (!dialog_.get()) |
| 131 dialog_ = ExtensionInstallDialog::CreateDefaultImpl(); |
127 } | 132 } |
128 | 133 |
129 CrxInstaller::~CrxInstaller() { | 134 CrxInstaller::~CrxInstaller() { |
130 // Delete the temp directory and crx file as necessary. Note that the | 135 // Delete the temp directory and crx file as necessary. Note that the |
131 // destructor might be called on any thread, so we post a task to the file | 136 // destructor might be called on any thread, so we post a task to the file |
132 // thread to make sure the delete happens there. This is a best effort | 137 // thread to make sure the delete happens there. This is a best effort |
133 // operation since the browser can be shutting down so there might not | 138 // operation since the browser can be shutting down so there might not |
134 // be a file thread to post to. | 139 // be a file thread to post to. |
135 if (!temp_dir_.value().empty()) { | 140 if (!temp_dir_.value().empty()) { |
136 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 141 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 IDS_EXTENSION_OVERLAPPING_WEB_EXTENT, | 451 IDS_EXTENSION_OVERLAPPING_WEB_EXTENT, |
447 UTF8ToUTF16(overlapping_extension->name())))); | 452 UTF8ToUTF16(overlapping_extension->name())))); |
448 return; | 453 return; |
449 } | 454 } |
450 | 455 |
451 current_version_ = | 456 current_version_ = |
452 frontend_weak_->extension_prefs()->GetVersionString(extension_->id()); | 457 frontend_weak_->extension_prefs()->GetVersionString(extension_->id()); |
453 | 458 |
454 if (client_ && (!allow_silent_install_ || !approved_)) { | 459 if (client_ && (!allow_silent_install_ || !approved_)) { |
455 AddRef(); // Balanced in Proceed() and Abort(). | 460 AddRef(); // Balanced in Proceed() and Abort(). |
456 client_->ConfirmInstall(this, extension_.get()); | 461 client_->ConfirmInstall(this, extension_.get(), dialog_); |
457 } else { | 462 } else { |
458 if (!BrowserThread::PostTask( | 463 if (!BrowserThread::PostTask( |
459 BrowserThread::FILE, FROM_HERE, | 464 BrowserThread::FILE, FROM_HERE, |
460 base::Bind(&CrxInstaller::CompleteInstall, this))) | 465 base::Bind(&CrxInstaller::CompleteInstall, this))) |
461 NOTREACHED(); | 466 NOTREACHED(); |
462 } | 467 } |
463 return; | 468 return; |
464 } | 469 } |
465 | 470 |
466 void CrxInstaller::InstallUIProceed() { | 471 void CrxInstaller::InstallUIProceed() { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 // is problematic because they don't know anything about the | 655 // is problematic because they don't know anything about the |
651 // extension before it is unpacked, so they cannot filter based | 656 // extension before it is unpacked, so they cannot filter based |
652 // on the extension. | 657 // on the extension. |
653 content::NotificationService::current()->Notify( | 658 content::NotificationService::current()->Notify( |
654 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 659 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
655 content::Source<CrxInstaller>(this), | 660 content::Source<CrxInstaller>(this), |
656 content::Details<const Extension>(extension)); | 661 content::Details<const Extension>(extension)); |
657 } | 662 } |
658 | 663 |
659 } // namespace extensions | 664 } // namespace extensions |
OLD | NEW |