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/stl_util.h" | 17 #include "base/stl_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_ui.h" |
28 #include "chrome/browser/extensions/extension_service.h" | 29 #include "chrome/browser/extensions/extension_service.h" |
29 #include "chrome/browser/extensions/extension_system.h" | 30 #include "chrome/browser/extensions/extension_system.h" |
30 #include "chrome/browser/extensions/permissions_updater.h" | 31 #include "chrome/browser/extensions/permissions_updater.h" |
31 #include "chrome/browser/extensions/webstore_installer.h" | 32 #include "chrome/browser/extensions/webstore_installer.h" |
32 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/shell_integration.h" | 34 #include "chrome/browser/shell_integration.h" |
34 #include "chrome/browser/web_applications/web_app.h" | 35 #include "chrome/browser/web_applications/web_app.h" |
35 #include "chrome/common/chrome_notification_types.h" | 36 #include "chrome/common/chrome_notification_types.h" |
36 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
37 #include "chrome/common/extensions/extension_constants.h" | 38 #include "chrome/common/extensions/extension_constants.h" |
(...skipping 24 matching lines...) Expand all Loading... |
62 OffStoreInstallAllowed, | 63 OffStoreInstallAllowed, |
63 OffStoreInstallDisallowed, | 64 OffStoreInstallDisallowed, |
64 NumOffStoreInstallDecision | 65 NumOffStoreInstallDecision |
65 }; | 66 }; |
66 | 67 |
67 } // namespace | 68 } // namespace |
68 | 69 |
69 // static | 70 // static |
70 scoped_refptr<CrxInstaller> CrxInstaller::Create( | 71 scoped_refptr<CrxInstaller> CrxInstaller::Create( |
71 ExtensionService* frontend, | 72 ExtensionService* frontend, |
72 ExtensionInstallUI* client) { | 73 ExtensionInstallPrompt* client) { |
73 return new CrxInstaller(frontend->AsWeakPtr(), client, NULL); | 74 return new CrxInstaller(frontend->AsWeakPtr(), client, NULL); |
74 } | 75 } |
75 | 76 |
76 // static | 77 // static |
77 scoped_refptr<CrxInstaller> CrxInstaller::Create( | 78 scoped_refptr<CrxInstaller> CrxInstaller::Create( |
78 ExtensionService* frontend, | 79 ExtensionService* frontend, |
79 ExtensionInstallUI* client, | 80 ExtensionInstallPrompt* client, |
80 const WebstoreInstaller::Approval* approval) { | 81 const WebstoreInstaller::Approval* approval) { |
81 return new CrxInstaller(frontend->AsWeakPtr(), client, approval); | 82 return new CrxInstaller(frontend->AsWeakPtr(), client, approval); |
82 } | 83 } |
83 | 84 |
84 CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak, | 85 CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak, |
85 ExtensionInstallUI* client, | 86 ExtensionInstallPrompt* client, |
86 const WebstoreInstaller::Approval* approval) | 87 const WebstoreInstaller::Approval* approval) |
87 : install_directory_(frontend_weak->install_directory()), | 88 : install_directory_(frontend_weak->install_directory()), |
88 install_source_(Extension::INTERNAL), | 89 install_source_(Extension::INTERNAL), |
89 approved_(false), | 90 approved_(false), |
90 extensions_enabled_(frontend_weak->extensions_enabled()), | 91 extensions_enabled_(frontend_weak->extensions_enabled()), |
91 delete_source_(false), | 92 delete_source_(false), |
92 create_app_shortcut_(false), | 93 create_app_shortcut_(false), |
93 frontend_weak_(frontend_weak), | 94 frontend_weak_(frontend_weak), |
94 profile_(frontend_weak->profile()), | 95 profile_(frontend_weak->profile()), |
95 client_(client), | 96 client_(client), |
96 apps_require_extension_mime_type_(false), | 97 apps_require_extension_mime_type_(false), |
97 allow_silent_install_(false), | 98 allow_silent_install_(false), |
98 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), | 99 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), |
99 creation_flags_(Extension::NO_FLAGS), | 100 creation_flags_(Extension::NO_FLAGS), |
100 allow_off_store_install_(false) { | 101 allow_off_store_install_(false) { |
101 if (!approval) | 102 if (!approval) |
102 return; | 103 return; |
103 | 104 |
104 CHECK(profile_->IsSameProfile(approval->profile)); | 105 CHECK(profile_->IsSameProfile(approval->profile)); |
105 client_->set_use_app_installed_bubble(approval->use_app_installed_bubble); | 106 client_->install_ui()->SetUseAppInstalledBubble( |
106 client_->set_skip_post_install_ui(approval->skip_post_install_ui); | 107 approval->use_app_installed_bubble); |
| 108 client_->install_ui()->SetSkipPostInstallUI(approval->skip_post_install_ui); |
107 | 109 |
108 if (approval->skip_install_dialog) { | 110 if (approval->skip_install_dialog) { |
109 // Mark the extension as approved, but save the expected manifest and ID | 111 // Mark the extension as approved, but save the expected manifest and ID |
110 // so we can check that they match the CRX's. | 112 // so we can check that they match the CRX's. |
111 approved_ = true; | 113 approved_ = true; |
112 expected_manifest_.reset(approval->parsed_manifest->DeepCopy()); | 114 expected_manifest_.reset(approval->parsed_manifest->DeepCopy()); |
113 expected_id_ = approval->extension_id; | 115 expected_id_ = approval->extension_id; |
114 } | 116 } |
115 } | 117 } |
116 | 118 |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 NOTREACHED(); | 561 NOTREACHED(); |
560 } | 562 } |
561 | 563 |
562 void CrxInstaller::ReportSuccessFromUIThread() { | 564 void CrxInstaller::ReportSuccessFromUIThread() { |
563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
564 | 566 |
565 if (!frontend_weak_.get()) | 567 if (!frontend_weak_.get()) |
566 return; | 568 return; |
567 | 569 |
568 // If there is a client, tell the client about installation. | 570 // If there is a client, tell the client about installation. |
569 if (client_) | 571 if (client_) { |
570 client_->OnInstallSuccess(extension_.get(), install_icon_.get()); | 572 client_->OnInstallSuccess(extension_.get(), install_icon_.get()); |
| 573 } |
571 | 574 |
572 // We update the extension's granted permissions if the user already approved | 575 // We update the extension's granted permissions if the user already approved |
573 // the install (client_ is non NULL), or we are allowed to install this | 576 // the install (client_ is non NULL), or we are allowed to install this |
574 // silently. | 577 // silently. |
575 if (client_ || allow_silent_install_) { | 578 if (client_ || allow_silent_install_) { |
576 PermissionsUpdater perms_updater(profile()); | 579 PermissionsUpdater perms_updater(profile()); |
577 perms_updater.GrantActivePermissions(extension_); | 580 perms_updater.GrantActivePermissions(extension_); |
578 } | 581 } |
579 | 582 |
580 // Tell the frontend about the installation and hand off ownership of | 583 // Tell the frontend about the installation and hand off ownership of |
(...skipping 13 matching lines...) Expand all Loading... |
594 // Some users (such as the download shelf) need to know when a | 597 // Some users (such as the download shelf) need to know when a |
595 // CRXInstaller is done. Listening for the EXTENSION_* events | 598 // CRXInstaller is done. Listening for the EXTENSION_* events |
596 // is problematic because they don't know anything about the | 599 // is problematic because they don't know anything about the |
597 // extension before it is unpacked, so they cannot filter based | 600 // extension before it is unpacked, so they cannot filter based |
598 // on the extension. | 601 // on the extension. |
599 content::NotificationService::current()->Notify( | 602 content::NotificationService::current()->Notify( |
600 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 603 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
601 content::Source<CrxInstaller>(this), | 604 content::Source<CrxInstaller>(this), |
602 content::Details<const Extension>(extension)); | 605 content::Details<const Extension>(extension)); |
603 } | 606 } |
OLD | NEW |