OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/apps/ephemeral_app_launcher.h" | 5 #include "chrome/browser/apps/ephemeral_app_launcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/extension_install_checker.h" | 9 #include "chrome/browser/extensions/extension_install_checker.h" |
10 #include "chrome/browser/extensions/extension_install_prompt.h" | 10 #include "chrome/browser/extensions/extension_install_prompt.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 WebstoreStandaloneInstaller::CompleteInstall(result, error); | 312 WebstoreStandaloneInstaller::CompleteInstall(result, error); |
313 } | 313 } |
314 | 314 |
315 void EphemeralAppLauncher::CheckEphemeralInstallPermitted() { | 315 void EphemeralAppLauncher::CheckEphemeralInstallPermitted() { |
316 scoped_refptr<const Extension> extension = GetLocalizedExtensionForDisplay(); | 316 scoped_refptr<const Extension> extension = GetLocalizedExtensionForDisplay(); |
317 DCHECK(extension.get()); // Checked in OnManifestParsed(). | 317 DCHECK(extension.get()); // Checked in OnManifestParsed(). |
318 | 318 |
319 install_checker_ = CreateInstallChecker(); | 319 install_checker_ = CreateInstallChecker(); |
320 DCHECK(install_checker_.get()); | 320 DCHECK(install_checker_.get()); |
321 | 321 |
322 install_checker_->set_extension(extension); | 322 install_checker_->set_extension(extension.get()); |
323 install_checker_->Start(ExtensionInstallChecker::CHECK_BLACKLIST | | 323 install_checker_->Start(ExtensionInstallChecker::CHECK_BLACKLIST | |
324 ExtensionInstallChecker::CHECK_REQUIREMENTS, | 324 ExtensionInstallChecker::CHECK_REQUIREMENTS, |
325 true, | 325 true, |
326 base::Bind(&EphemeralAppLauncher::OnInstallChecked, | 326 base::Bind(&EphemeralAppLauncher::OnInstallChecked, |
327 base::Unretained(this))); | 327 base::Unretained(this))); |
328 } | 328 } |
329 | 329 |
330 void EphemeralAppLauncher::OnInstallChecked(int check_failures) { | 330 void EphemeralAppLauncher::OnInstallChecked(int check_failures) { |
331 if (!CheckRequestorAlive()) { | 331 if (!CheckRequestorAlive()) { |
332 AbortLaunch(webstore_install::OTHER_ERROR, std::string()); | 332 AbortLaunch(webstore_install::OTHER_ERROR, std::string()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 397 } |
398 | 398 |
399 bool EphemeralAppLauncher::CheckRequestorPermitted( | 399 bool EphemeralAppLauncher::CheckRequestorPermitted( |
400 const base::DictionaryValue& webstore_data, | 400 const base::DictionaryValue& webstore_data, |
401 std::string* error) const { | 401 std::string* error) const { |
402 *error = ""; | 402 *error = ""; |
403 return true; | 403 return true; |
404 } | 404 } |
405 | 405 |
406 void EphemeralAppLauncher::OnManifestParsed() { | 406 void EphemeralAppLauncher::OnManifestParsed() { |
407 const Extension* extension = GetLocalizedExtensionForDisplay(); | 407 scoped_refptr<const Extension> extension = GetLocalizedExtensionForDisplay(); |
408 if (!extension) { | 408 if (!extension.get()) { |
409 AbortLaunch(webstore_install::INVALID_MANIFEST, kInvalidManifestError); | 409 AbortLaunch(webstore_install::INVALID_MANIFEST, kInvalidManifestError); |
410 return; | 410 return; |
411 } | 411 } |
412 | 412 |
413 webstore_install::Result result = webstore_install::OTHER_ERROR; | 413 webstore_install::Result result = webstore_install::OTHER_ERROR; |
414 std::string error; | 414 std::string error; |
415 if (!CheckCommonLaunchCriteria(profile(), extension, &result, &error)) { | 415 if (!CheckCommonLaunchCriteria(profile(), extension.get(), &result, &error)) { |
416 AbortLaunch(result, error); | 416 AbortLaunch(result, error); |
417 return; | 417 return; |
418 } | 418 } |
419 | 419 |
420 if (extension->is_legacy_packaged_app()) { | 420 if (extension->is_legacy_packaged_app()) { |
421 AbortLaunch(webstore_install::LAUNCH_UNSUPPORTED_EXTENSION_TYPE, | 421 AbortLaunch(webstore_install::LAUNCH_UNSUPPORTED_EXTENSION_TYPE, |
422 kAppTypeError); | 422 kAppTypeError); |
423 return; | 423 return; |
424 } | 424 } |
425 | 425 |
426 if (extension->is_hosted_app()) { | 426 if (extension->is_hosted_app()) { |
427 // Hosted apps do not need to be installed ephemerally. Just navigate to | 427 // Hosted apps do not need to be installed ephemerally. Just navigate to |
428 // their launch url. | 428 // their launch url. |
429 if (LaunchHostedApp(extension)) | 429 if (LaunchHostedApp(extension.get())) |
430 AbortLaunch(webstore_install::SUCCESS, std::string()); | 430 AbortLaunch(webstore_install::SUCCESS, std::string()); |
431 else | 431 else |
432 AbortLaunch(webstore_install::INVALID_MANIFEST, kInvalidManifestError); | 432 AbortLaunch(webstore_install::INVALID_MANIFEST, kInvalidManifestError); |
433 return; | 433 return; |
434 } | 434 } |
435 | 435 |
436 CheckEphemeralInstallPermitted(); | 436 CheckEphemeralInstallPermitted(); |
437 } | 437 } |
438 | 438 |
439 void EphemeralAppLauncher::CompleteInstall(webstore_install::Result result, | 439 void EphemeralAppLauncher::CompleteInstall(webstore_install::Result result, |
(...skipping 16 matching lines...) Expand all Loading... |
456 | 456 |
457 // CompleteInstall will call Release. | 457 // CompleteInstall will call Release. |
458 WebstoreStandaloneInstaller::CompleteInstall(webstore_install::SUCCESS, | 458 WebstoreStandaloneInstaller::CompleteInstall(webstore_install::SUCCESS, |
459 std::string()); | 459 std::string()); |
460 } | 460 } |
461 | 461 |
462 void EphemeralAppLauncher::ExtensionEnableFlowAborted(bool user_initiated) { | 462 void EphemeralAppLauncher::ExtensionEnableFlowAborted(bool user_initiated) { |
463 // CompleteInstall will call Release. | 463 // CompleteInstall will call Release. |
464 CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError); | 464 CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError); |
465 } | 465 } |
OLD | NEW |