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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 // static | 100 // static |
101 scoped_refptr<CrxInstaller> CrxInstaller::Create( | 101 scoped_refptr<CrxInstaller> CrxInstaller::Create( |
102 ExtensionService* service, | 102 ExtensionService* service, |
103 scoped_ptr<ExtensionInstallPrompt> client, | 103 scoped_ptr<ExtensionInstallPrompt> client, |
104 const WebstoreInstaller::Approval* approval) { | 104 const WebstoreInstaller::Approval* approval) { |
105 return new CrxInstaller(service->AsWeakPtr(), client.Pass(), approval); | 105 return new CrxInstaller(service->AsWeakPtr(), client.Pass(), approval); |
106 } | 106 } |
107 | 107 |
108 CrxInstaller::CrxInstaller( | 108 CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> service_weak, |
109 base::WeakPtr<ExtensionService> service_weak, | 109 scoped_ptr<ExtensionInstallPrompt> client, |
110 scoped_ptr<ExtensionInstallPrompt> client, | 110 const WebstoreInstaller::Approval* approval) |
111 const WebstoreInstaller::Approval* approval) | |
112 : install_directory_(service_weak->install_directory()), | 111 : install_directory_(service_weak->install_directory()), |
113 install_source_(Manifest::INTERNAL), | 112 install_source_(Manifest::INTERNAL), |
114 approved_(false), | 113 approved_(false), |
115 expected_manifest_check_level_( | 114 expected_manifest_check_level_( |
116 WebstoreInstaller::MANIFEST_CHECK_LEVEL_STRICT), | 115 WebstoreInstaller::MANIFEST_CHECK_LEVEL_STRICT), |
117 expected_version_strict_checking_(false), | 116 expected_version_strict_checking_(false), |
118 extensions_enabled_(service_weak->extensions_enabled()), | 117 extensions_enabled_(service_weak->extensions_enabled()), |
119 delete_source_(false), | 118 delete_source_(false), |
120 create_app_shortcut_(false), | 119 create_app_shortcut_(false), |
121 service_weak_(service_weak), | 120 service_weak_(service_weak), |
122 // See header file comment on |client_| for why we use a raw pointer here. | 121 // See header file comment on |client_| for why we use a raw pointer here. |
123 client_(client.release()), | 122 client_(client.release()), |
124 apps_require_extension_mime_type_(false), | 123 apps_require_extension_mime_type_(false), |
125 allow_silent_install_(false), | 124 allow_silent_install_(false), |
| 125 grant_permissions_(true), |
126 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), | 126 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), |
127 creation_flags_(Extension::NO_FLAGS), | 127 creation_flags_(Extension::NO_FLAGS), |
128 off_store_install_allow_reason_(OffStoreInstallDisallowed), | 128 off_store_install_allow_reason_(OffStoreInstallDisallowed), |
129 did_handle_successfully_(true), | 129 did_handle_successfully_(true), |
130 error_on_unsupported_requirements_(false), | 130 error_on_unsupported_requirements_(false), |
131 has_requirement_errors_(false), | 131 has_requirement_errors_(false), |
132 blacklist_state_(extensions::NOT_BLACKLISTED), | 132 blacklist_state_(extensions::NOT_BLACKLISTED), |
133 install_wait_for_idle_(true), | 133 install_wait_for_idle_(true), |
134 update_from_settings_page_(false), | 134 update_from_settings_page_(false), |
135 installer_(service_weak->profile()) { | 135 installer_(service_weak->profile()) { |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 return; | 795 return; |
796 | 796 |
797 if (!update_from_settings_page_) { | 797 if (!update_from_settings_page_) { |
798 // If there is a client, tell the client about installation. | 798 // If there is a client, tell the client about installation. |
799 if (client_) | 799 if (client_) |
800 client_->OnInstallSuccess(extension(), install_icon_.get()); | 800 client_->OnInstallSuccess(extension(), install_icon_.get()); |
801 | 801 |
802 // We update the extension's granted permissions if the user already | 802 // We update the extension's granted permissions if the user already |
803 // approved the install (client_ is non NULL), or we are allowed to install | 803 // approved the install (client_ is non NULL), or we are allowed to install |
804 // this silently. | 804 // this silently. |
805 if (client_ || allow_silent_install_) { | 805 if ((client_ || allow_silent_install_) && grant_permissions_) { |
806 PermissionsUpdater perms_updater(profile()); | 806 PermissionsUpdater perms_updater(profile()); |
807 perms_updater.GrantActivePermissions(extension()); | 807 perms_updater.GrantActivePermissions(extension()); |
808 } | 808 } |
809 } | 809 } |
810 | 810 |
811 service_weak_->OnExtensionInstalled(extension(), | 811 service_weak_->OnExtensionInstalled(extension(), |
812 page_ordinal_, | 812 page_ordinal_, |
813 has_requirement_errors_, | 813 has_requirement_errors_, |
814 blacklist_state_, | 814 blacklist_state_, |
815 install_wait_for_idle_); | 815 install_wait_for_idle_); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) | 897 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) |
898 return; | 898 return; |
899 | 899 |
900 if (client_) { | 900 if (client_) { |
901 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). | 901 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). |
902 client_->ConfirmReEnable(this, extension()); | 902 client_->ConfirmReEnable(this, extension()); |
903 } | 903 } |
904 } | 904 } |
905 | 905 |
906 } // namespace extensions | 906 } // namespace extensions |
OLD | NEW |