| 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 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 void CrxInstaller::ConvertUserScriptOnFileThread() { | 209 void CrxInstaller::ConvertUserScriptOnFileThread() { |
| 210 base::string16 error; | 210 base::string16 error; |
| 211 scoped_refptr<Extension> extension = ConvertUserScriptToExtension( | 211 scoped_refptr<Extension> extension = ConvertUserScriptToExtension( |
| 212 source_file_, download_url_, install_directory_, &error); | 212 source_file_, download_url_, install_directory_, &error); |
| 213 if (!extension.get()) { | 213 if (!extension.get()) { |
| 214 ReportFailureFromFileThread(CrxInstallError(error)); | 214 ReportFailureFromFileThread(CrxInstallError(error)); |
| 215 return; | 215 return; |
| 216 } | 216 } |
| 217 | 217 |
| 218 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension.get(), | 218 OnUnpackSuccess(extension->path(), extension->path(), nullptr, |
| 219 SkBitmap()); | 219 extension.get(), SkBitmap()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) { | 222 void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) { |
| 223 NotifyCrxInstallBegin(); | 223 NotifyCrxInstallBegin(); |
| 224 | 224 |
| 225 if (!installer_task_runner_->PostTask( | 225 if (!installer_task_runner_->PostTask( |
| 226 FROM_HERE, | 226 FROM_HERE, |
| 227 base::Bind(&CrxInstaller::ConvertWebAppOnFileThread, this, web_app))) | 227 base::Bind(&CrxInstaller::ConvertWebAppOnFileThread, this, web_app))) |
| 228 NOTREACHED(); | 228 NOTREACHED(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void CrxInstaller::ConvertWebAppOnFileThread( | 231 void CrxInstaller::ConvertWebAppOnFileThread( |
| 232 const WebApplicationInfo& web_app) { | 232 const WebApplicationInfo& web_app) { |
| 233 scoped_refptr<Extension> extension(ConvertWebAppToExtension( | 233 scoped_refptr<Extension> extension(ConvertWebAppToExtension( |
| 234 web_app, base::Time::Now(), install_directory_)); | 234 web_app, base::Time::Now(), install_directory_)); |
| 235 if (!extension.get()) { | 235 if (!extension.get()) { |
| 236 // Validation should have stopped any potential errors before getting here. | 236 // Validation should have stopped any potential errors before getting here. |
| 237 NOTREACHED() << "Could not convert web app to extension."; | 237 NOTREACHED() << "Could not convert web app to extension."; |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 | 240 |
| 241 // TODO(aa): conversion data gets lost here :( | 241 // TODO(aa): conversion data gets lost here :( |
| 242 | 242 |
| 243 OnUnpackSuccess(extension->path(), extension->path(), NULL, extension.get(), | 243 OnUnpackSuccess(extension->path(), extension->path(), nullptr, |
| 244 SkBitmap()); | 244 extension.get(), SkBitmap()); |
| 245 } | 245 } |
| 246 | 246 |
| 247 CrxInstallError CrxInstaller::AllowInstall(const Extension* extension) { | 247 CrxInstallError CrxInstaller::AllowInstall(const Extension* extension) { |
| 248 DCHECK(installer_task_runner_->RunsTasksOnCurrentThread()); | 248 DCHECK(installer_task_runner_->RunsTasksOnCurrentThread()); |
| 249 | 249 |
| 250 // Make sure the expected ID matches if one was supplied or if we want to | 250 // Make sure the expected ID matches if one was supplied or if we want to |
| 251 // bypass the prompt. | 251 // bypass the prompt. |
| 252 if ((approved_ || !expected_id_.empty()) && | 252 if ((approved_ || !expected_id_.empty()) && |
| 253 expected_id_ != extension->id()) { | 253 expected_id_ != extension->id()) { |
| 254 return CrxInstallError(l10n_util::GetStringFUTF16( | 254 return CrxInstallError(l10n_util::GetStringFUTF16( |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 UMA_HISTOGRAM_ENUMERATION("Extensions.UnpackFailureInstallCause", | 411 UMA_HISTOGRAM_ENUMERATION("Extensions.UnpackFailureInstallCause", |
| 412 install_cause(), | 412 install_cause(), |
| 413 extension_misc::NUM_INSTALL_CAUSES); | 413 extension_misc::NUM_INSTALL_CAUSES); |
| 414 | 414 |
| 415 ReportFailureFromFileThread(error); | 415 ReportFailureFromFileThread(error); |
| 416 } | 416 } |
| 417 | 417 |
| 418 void CrxInstaller::OnUnpackSuccess( | 418 void CrxInstaller::OnUnpackSuccess( |
| 419 const base::FilePath& temp_dir, | 419 const base::FilePath& temp_dir, |
| 420 const base::FilePath& extension_dir, | 420 const base::FilePath& extension_dir, |
| 421 const base::DictionaryValue* original_manifest, | 421 std::unique_ptr<base::DictionaryValue> original_manifest, |
| 422 const Extension* extension, | 422 const Extension* extension, |
| 423 const SkBitmap& install_icon) { | 423 const SkBitmap& install_icon) { |
| 424 DCHECK(installer_task_runner_->RunsTasksOnCurrentThread()); | 424 DCHECK(installer_task_runner_->RunsTasksOnCurrentThread()); |
| 425 | 425 |
| 426 UMA_HISTOGRAM_ENUMERATION("Extensions.UnpackSuccessInstallSource", | 426 UMA_HISTOGRAM_ENUMERATION("Extensions.UnpackSuccessInstallSource", |
| 427 install_source(), Manifest::NUM_LOCATIONS); | 427 install_source(), Manifest::NUM_LOCATIONS); |
| 428 | 428 |
| 429 | 429 |
| 430 UMA_HISTOGRAM_ENUMERATION("Extensions.UnpackSuccessInstallCause", | 430 UMA_HISTOGRAM_ENUMERATION("Extensions.UnpackSuccessInstallCause", |
| 431 install_cause(), | 431 install_cause(), |
| 432 extension_misc::NUM_INSTALL_CAUSES); | 432 extension_misc::NUM_INSTALL_CAUSES); |
| 433 | 433 |
| 434 extension_ = extension; | 434 extension_ = extension; |
| 435 temp_dir_ = temp_dir; | 435 temp_dir_ = temp_dir; |
| 436 if (!install_icon.empty()) | 436 if (!install_icon.empty()) |
| 437 install_icon_.reset(new SkBitmap(install_icon)); | 437 install_icon_.reset(new SkBitmap(install_icon)); |
| 438 | 438 |
| 439 if (original_manifest) | 439 if (original_manifest) { |
| 440 original_manifest_.reset(new Manifest( | 440 original_manifest_.reset( |
| 441 Manifest::INVALID_LOCATION, | 441 new Manifest(Manifest::INVALID_LOCATION, std::move(original_manifest))); |
| 442 std::unique_ptr<base::DictionaryValue>(original_manifest->DeepCopy()))); | 442 } |
| 443 | 443 |
| 444 // We don't have to delete the unpack dir explicity since it is a child of | 444 // We don't have to delete the unpack dir explicity since it is a child of |
| 445 // the temp dir. | 445 // the temp dir. |
| 446 unpacked_extension_root_ = extension_dir; | 446 unpacked_extension_root_ = extension_dir; |
| 447 | 447 |
| 448 CrxInstallError error = AllowInstall(extension); | 448 CrxInstallError error = AllowInstall(extension); |
| 449 if (error.type() != CrxInstallError::ERROR_NONE) { | 449 if (error.type() != CrxInstallError::ERROR_NONE) { |
| 450 ReportFailureFromFileThread(error); | 450 ReportFailureFromFileThread(error); |
| 451 return; | 451 return; |
| 452 } | 452 } |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 ExtensionInstallPrompt::GetReEnablePromptTypeForExtension( | 907 ExtensionInstallPrompt::GetReEnablePromptTypeForExtension( |
| 908 service->profile(), extension()); | 908 service->profile(), extension()); |
| 909 client_->ShowDialog(base::Bind(&CrxInstaller::OnInstallPromptDone, this), | 909 client_->ShowDialog(base::Bind(&CrxInstaller::OnInstallPromptDone, this), |
| 910 extension(), nullptr, | 910 extension(), nullptr, |
| 911 base::MakeUnique<ExtensionInstallPrompt::Prompt>(type), | 911 base::MakeUnique<ExtensionInstallPrompt::Prompt>(type), |
| 912 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); | 912 ExtensionInstallPrompt::GetDefaultShowDialogCallback()); |
| 913 } | 913 } |
| 914 } | 914 } |
| 915 | 915 |
| 916 } // namespace extensions | 916 } // namespace extensions |
| OLD | NEW |