| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 kFeatureDisabledError); | 125 kFeatureDisabledError); |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Check whether the app already exists in extension system before downloading | 129 // Check whether the app already exists in extension system before downloading |
| 130 // from the webstore. | 130 // from the webstore. |
| 131 const Extension* extension = | 131 const Extension* extension = |
| 132 ExtensionRegistry::Get(profile()) | 132 ExtensionRegistry::Get(profile()) |
| 133 ->GetExtensionById(id(), ExtensionRegistry::EVERYTHING); | 133 ->GetExtensionById(id(), ExtensionRegistry::EVERYTHING); |
| 134 if (extension) { | 134 if (extension) { |
| 135 webstore_install::Result result = webstore_install::UNKNOWN_ERROR; | 135 webstore_install::Result result = webstore_install::OTHER_ERROR; |
| 136 std::string error; | 136 std::string error; |
| 137 if (!CanLaunchInstalledApp(extension, &result, &error)) { | 137 if (!CanLaunchInstalledApp(extension, &result, &error)) { |
| 138 InvokeCallback(result, error); | 138 InvokeCallback(result, error); |
| 139 return; | 139 return; |
| 140 } | 140 } |
| 141 | 141 |
| 142 if (extensions::util::IsAppLaunchableWithoutEnabling(extension->id(), | 142 if (extensions::util::IsAppLaunchableWithoutEnabling(extension->id(), |
| 143 profile())) { | 143 profile())) { |
| 144 LaunchApp(extension); | 144 LaunchApp(extension); |
| 145 InvokeCallback(webstore_install::SUCCESS, std::string()); | 145 InvokeCallback(webstore_install::SUCCESS, std::string()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 *reason = webstore_install::REQUIREMENT_VIOLATIONS; | 218 *reason = webstore_install::REQUIREMENT_VIOLATIONS; |
| 219 *error = kRequirementsError; | 219 *error = kRequirementsError; |
| 220 return false; | 220 return false; |
| 221 } | 221 } |
| 222 | 222 |
| 223 return true; | 223 return true; |
| 224 } | 224 } |
| 225 | 225 |
| 226 void EphemeralAppLauncher::EnableInstalledApp(const Extension* extension) { | 226 void EphemeralAppLauncher::EnableInstalledApp(const Extension* extension) { |
| 227 // Check whether an install is already in progress. | 227 // Check whether an install is already in progress. |
| 228 webstore_install::Result result = webstore_install::UNKNOWN_ERROR; | 228 webstore_install::Result result = webstore_install::OTHER_ERROR; |
| 229 std::string error; | 229 std::string error; |
| 230 if (!EnsureUniqueInstall(&result, &error)) { | 230 if (!EnsureUniqueInstall(&result, &error)) { |
| 231 InvokeCallback(result, error); | 231 InvokeCallback(result, error); |
| 232 return; | 232 return; |
| 233 } | 233 } |
| 234 | 234 |
| 235 // Keep this object alive until the enable flow is complete. Either | 235 // Keep this object alive until the enable flow is complete. Either |
| 236 // ExtensionEnableFlowFinished() or ExtensionEnableFlowAborted() will be | 236 // ExtensionEnableFlowFinished() or ExtensionEnableFlowAborted() will be |
| 237 // called. | 237 // called. |
| 238 AddRef(); | 238 AddRef(); |
| 239 | 239 |
| 240 extension_enable_flow_.reset( | 240 extension_enable_flow_.reset( |
| 241 new ExtensionEnableFlow(profile(), extension->id(), this)); | 241 new ExtensionEnableFlow(profile(), extension->id(), this)); |
| 242 if (web_contents()) | 242 if (web_contents()) |
| 243 extension_enable_flow_->StartForWebContents(web_contents()); | 243 extension_enable_flow_->StartForWebContents(web_contents()); |
| 244 else | 244 else |
| 245 extension_enable_flow_->StartForNativeWindow(parent_window_); | 245 extension_enable_flow_->StartForNativeWindow(parent_window_); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void EphemeralAppLauncher::MaybeLaunchApp() { | 248 void EphemeralAppLauncher::MaybeLaunchApp() { |
| 249 webstore_install::Result result = webstore_install::UNKNOWN_ERROR; | 249 webstore_install::Result result = webstore_install::OTHER_ERROR; |
| 250 std::string error; | 250 std::string error; |
| 251 | 251 |
| 252 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 252 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 253 const Extension* extension = | 253 const Extension* extension = |
| 254 registry->GetExtensionById(id(), ExtensionRegistry::EVERYTHING); | 254 registry->GetExtensionById(id(), ExtensionRegistry::EVERYTHING); |
| 255 if (extension) { | 255 if (extension) { |
| 256 // Although the installation was successful, the app may not be | 256 // Although the installation was successful, the app may not be |
| 257 // launchable. | 257 // launchable. |
| 258 if (registry->enabled_extensions().Contains(extension->id())) { | 258 if (registry->enabled_extensions().Contains(extension->id())) { |
| 259 result = webstore_install::SUCCESS; | 259 result = webstore_install::SUCCESS; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 install_checker_->set_extension(extension); | 322 install_checker_->set_extension(extension); |
| 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::UNKNOWN_ERROR, std::string()); | 332 AbortLaunch(webstore_install::OTHER_ERROR, std::string()); |
| 333 return; | 333 return; |
| 334 } | 334 } |
| 335 | 335 |
| 336 if (install_checker_->blacklist_state() == extensions::BLACKLISTED_MALWARE) { | 336 if (install_checker_->blacklist_state() == extensions::BLACKLISTED_MALWARE) { |
| 337 AbortLaunch(webstore_install::BLACKLISTED, kBlacklistedError); | 337 AbortLaunch(webstore_install::BLACKLISTED, kBlacklistedError); |
| 338 return; | 338 return; |
| 339 } | 339 } |
| 340 | 340 |
| 341 if (!install_checker_->requirement_errors().empty()) { | 341 if (!install_checker_->requirement_errors().empty()) { |
| 342 AbortLaunch(webstore_install::REQUIREMENT_VIOLATIONS, | 342 AbortLaunch(webstore_install::REQUIREMENT_VIOLATIONS, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 return true; | 403 return true; |
| 404 } | 404 } |
| 405 | 405 |
| 406 void EphemeralAppLauncher::OnManifestParsed() { | 406 void EphemeralAppLauncher::OnManifestParsed() { |
| 407 const Extension* extension = GetLocalizedExtensionForDisplay(); | 407 const Extension* extension = GetLocalizedExtensionForDisplay(); |
| 408 if (!extension) { | 408 if (!extension) { |
| 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::UNKNOWN_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, &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; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |