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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), | 128 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), |
129 creation_flags_(Extension::NO_FLAGS), | 129 creation_flags_(Extension::NO_FLAGS), |
130 off_store_install_allow_reason_(OffStoreInstallDisallowed), | 130 off_store_install_allow_reason_(OffStoreInstallDisallowed), |
131 did_handle_successfully_(true), | 131 did_handle_successfully_(true), |
132 error_on_unsupported_requirements_(false), | 132 error_on_unsupported_requirements_(false), |
133 has_requirement_errors_(false), | 133 has_requirement_errors_(false), |
134 blacklist_state_(extensions::NOT_BLACKLISTED), | 134 blacklist_state_(extensions::NOT_BLACKLISTED), |
135 install_wait_for_idle_(true), | 135 install_wait_for_idle_(true), |
136 update_from_settings_page_(false), | 136 update_from_settings_page_(false), |
137 is_ephemeral_(false), | 137 is_ephemeral_(false), |
| 138 is_syncable_(true), |
138 installer_(service_weak->profile()) { | 139 installer_(service_weak->profile()) { |
139 installer_task_runner_ = service_weak->GetFileTaskRunner(); | 140 installer_task_runner_ = service_weak->GetFileTaskRunner(); |
140 if (!approval) | 141 if (!approval) |
141 return; | 142 return; |
142 | 143 |
143 CHECK(profile()->IsSameProfile(approval->profile)); | 144 CHECK(profile()->IsSameProfile(approval->profile)); |
144 if (client_) { | 145 if (client_) { |
145 client_->install_ui()->SetUseAppInstalledBubble( | 146 client_->install_ui()->SetUseAppInstalledBubble( |
146 approval->use_app_installed_bubble); | 147 approval->use_app_installed_bubble); |
147 client_->install_ui()->set_skip_post_install_ui( | 148 client_->install_ui()->set_skip_post_install_ui( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 return; | 223 return; |
223 } | 224 } |
224 | 225 |
225 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension.get(), | 226 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension.get(), |
226 SkBitmap()); | 227 SkBitmap()); |
227 } | 228 } |
228 | 229 |
229 void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) { | 230 void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) { |
230 NotifyCrxInstallBegin(); | 231 NotifyCrxInstallBegin(); |
231 | 232 |
| 233 // Web apps can only ever be converted to bookmark apps. |
| 234 DCHECK(creation_flags_ & Extension::FROM_BOOKMARK); |
232 if (!installer_task_runner_->PostTask( | 235 if (!installer_task_runner_->PostTask( |
233 FROM_HERE, | 236 FROM_HERE, |
234 base::Bind(&CrxInstaller::ConvertWebAppOnFileThread, | 237 base::Bind(&CrxInstaller::ConvertWebAppOnFileThread, this, web_app))) |
235 this, | |
236 web_app, | |
237 install_directory_))) | |
238 NOTREACHED(); | 238 NOTREACHED(); |
239 } | 239 } |
240 | 240 |
241 void CrxInstaller::ConvertWebAppOnFileThread( | 241 void CrxInstaller::ConvertWebAppOnFileThread( |
242 const WebApplicationInfo& web_app, | 242 const WebApplicationInfo& web_app) { |
243 const base::FilePath& install_directory) { | 243 scoped_refptr<Extension> extension(ConvertWebAppToExtension( |
244 base::string16 error; | 244 web_app, base::Time::Now(), creation_flags_, install_directory_)); |
245 scoped_refptr<Extension> extension( | |
246 ConvertWebAppToExtension(web_app, base::Time::Now(), install_directory)); | |
247 if (!extension.get()) { | 245 if (!extension.get()) { |
248 // Validation should have stopped any potential errors before getting here. | 246 // Validation should have stopped any potential errors before getting here. |
249 NOTREACHED() << "Could not convert web app to extension."; | 247 NOTREACHED() << "Could not convert web app to extension."; |
250 return; | 248 return; |
251 } | 249 } |
252 | 250 |
253 // TODO(aa): conversion data gets lost here :( | 251 // TODO(aa): conversion data gets lost here :( |
254 | 252 |
255 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension.get(), | 253 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension.get(), |
256 SkBitmap()); | 254 SkBitmap()); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 | 718 |
721 // This is lame, but we must reload the extension because absolute paths | 719 // This is lame, but we must reload the extension because absolute paths |
722 // inside the content scripts are established inside InitFromValue() and we | 720 // inside the content scripts are established inside InitFromValue() and we |
723 // just moved the extension. | 721 // just moved the extension. |
724 // TODO(aa): All paths to resources inside extensions should be created | 722 // TODO(aa): All paths to resources inside extensions should be created |
725 // lazily and based on the Extension's root path at that moment. | 723 // lazily and based on the Extension's root path at that moment. |
726 // TODO(rdevlin.cronin): Continue removing std::string errors and replacing | 724 // TODO(rdevlin.cronin): Continue removing std::string errors and replacing |
727 // with base::string16 | 725 // with base::string16 |
728 std::string extension_id = extension()->id(); | 726 std::string extension_id = extension()->id(); |
729 std::string error; | 727 std::string error; |
730 installer_.set_extension( | 728 scoped_refptr<Extension> mutable_extension = |
731 file_util::LoadExtension( | 729 file_util::LoadExtension( |
732 version_dir, | 730 version_dir, |
733 install_source_, | 731 install_source_, |
734 extension()->creation_flags() | Extension::REQUIRE_KEY, | 732 extension()->creation_flags() | Extension::REQUIRE_KEY, |
735 &error).get()); | 733 &error).get(); |
| 734 if (mutable_extension) |
| 735 mutable_extension->set_is_syncable(is_syncable_); |
| 736 |
| 737 installer_.set_extension(mutable_extension); |
736 | 738 |
737 if (extension()) { | 739 if (extension()) { |
738 ReportSuccessFromFileThread(); | 740 ReportSuccessFromFileThread(); |
739 } else { | 741 } else { |
740 LOG(ERROR) << error << " " << extension_id << " " << download_url_; | 742 LOG(ERROR) << error << " " << extension_id << " " << download_url_; |
741 ReportFailureFromFileThread(CrxInstallerError(base::UTF8ToUTF16(error))); | 743 ReportFailureFromFileThread(CrxInstallerError(base::UTF8ToUTF16(error))); |
742 } | 744 } |
743 } | 745 } |
744 | 746 |
745 void CrxInstaller::ReportFailureFromFileThread(const CrxInstallerError& error) { | 747 void CrxInstaller::ReportFailureFromFileThread(const CrxInstallerError& error) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) | 909 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) |
908 return; | 910 return; |
909 | 911 |
910 if (client_) { | 912 if (client_) { |
911 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). | 913 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). |
912 client_->ConfirmReEnable(this, extension()); | 914 client_->ConfirmReEnable(this, extension()); |
913 } | 915 } |
914 } | 916 } |
915 | 917 |
916 } // namespace extensions | 918 } // namespace extensions |
OLD | NEW |