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/webstore_standalone_installer.h" | 5 #include "chrome/browser/extensions/webstore_standalone_installer.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "base/version.h" | 8 #include "base/version.h" |
9 #include "chrome/browser/extensions/crx_installer.h" | 9 #include "chrome/browser/extensions/crx_installer.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 webstore_install::Result result, | 125 webstore_install::Result result, |
126 const std::string& error) { | 126 const std::string& error) { |
127 scoped_active_install_.reset(); | 127 scoped_active_install_.reset(); |
128 if (!callback_.is_null()) | 128 if (!callback_.is_null()) |
129 callback_.Run(result == webstore_install::SUCCESS, error, result); | 129 callback_.Run(result == webstore_install::SUCCESS, error, result); |
130 Release(); // Matches the AddRef in BeginInstall. | 130 Release(); // Matches the AddRef in BeginInstall. |
131 } | 131 } |
132 | 132 |
133 void WebstoreStandaloneInstaller::ProceedWithInstallPrompt() { | 133 void WebstoreStandaloneInstaller::ProceedWithInstallPrompt() { |
134 install_prompt_ = CreateInstallPrompt(); | 134 install_prompt_ = CreateInstallPrompt(); |
135 if (install_prompt_) { | 135 if (install_prompt_.get()) { |
136 ShowInstallUI(); | 136 ShowInstallUI(); |
137 // Control flow finishes up in InstallUIProceed or InstallUIAbort. | 137 // Control flow finishes up in InstallUIProceed or InstallUIAbort. |
138 } else { | 138 } else { |
139 InstallUIProceed(); | 139 InstallUIProceed(); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 scoped_refptr<const Extension> | 143 scoped_refptr<const Extension> |
144 WebstoreStandaloneInstaller::GetLocalizedExtensionForDisplay() { | 144 WebstoreStandaloneInstaller::GetLocalizedExtensionForDisplay() { |
145 if (!localized_extension_for_display_.get()) { | 145 if (!localized_extension_for_display_.get()) { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 | 342 |
343 if (ExtensionPrefs::Get(profile_)->IsExtensionBlacklisted(id_)) { | 343 if (ExtensionPrefs::Get(profile_)->IsExtensionBlacklisted(id_)) { |
344 // Don't install a blacklisted extension. | 344 // Don't install a blacklisted extension. |
345 install_result = webstore_install::BLACKLISTED; | 345 install_result = webstore_install::BLACKLISTED; |
346 install_message = kExtensionIsBlacklisted; | 346 install_message = kExtensionIsBlacklisted; |
347 } else if (util::IsEphemeralApp(installed_extension->id(), profile_) && | 347 } else if (util::IsEphemeralApp(installed_extension->id(), profile_) && |
348 !approval->is_ephemeral) { | 348 !approval->is_ephemeral) { |
349 // If the target extension has already been installed ephemerally and is | 349 // If the target extension has already been installed ephemerally and is |
350 // up to date, it can be promoted to a regular installed extension and | 350 // up to date, it can be promoted to a regular installed extension and |
351 // downloading from the Web Store is not necessary. | 351 // downloading from the Web Store is not necessary. |
352 const Extension* extension_to_install = GetLocalizedExtensionForDisplay(); | 352 scoped_refptr<const Extension> extension_to_install = |
dcheng
2014/08/26 01:30:17
Note: I missed this in my original overview of the
| |
353 GetLocalizedExtensionForDisplay(); | |
353 if (!extension_to_install) { | 354 if (!extension_to_install) { |
354 CompleteInstall(webstore_install::INVALID_MANIFEST, | 355 CompleteInstall(webstore_install::INVALID_MANIFEST, |
355 kInvalidManifestError); | 356 kInvalidManifestError); |
356 return; | 357 return; |
357 } | 358 } |
358 | 359 |
359 if (installed_extension->version()->CompareTo( | 360 if (installed_extension->version()->CompareTo( |
360 *extension_to_install->version()) < 0) { | 361 *extension_to_install->version()) < 0) { |
361 // If the existing extension is out of date, proceed with the install | 362 // If the existing extension is out of date, proceed with the install |
362 // to update the extension. | 363 // to update the extension. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 install_result = webstore_install::MISSING_DEPENDENCIES; | 415 install_result = webstore_install::MISSING_DEPENDENCIES; |
415 break; | 416 break; |
416 default: | 417 default: |
417 break; | 418 break; |
418 } | 419 } |
419 | 420 |
420 CompleteInstall(install_result, error); | 421 CompleteInstall(install_result, error); |
421 } | 422 } |
422 | 423 |
423 void WebstoreStandaloneInstaller::ShowInstallUI() { | 424 void WebstoreStandaloneInstaller::ShowInstallUI() { |
424 const Extension* localized_extension = GetLocalizedExtensionForDisplay(); | 425 scoped_refptr<const Extension> localized_extension = |
426 GetLocalizedExtensionForDisplay(); | |
425 if (!localized_extension) { | 427 if (!localized_extension) { |
426 CompleteInstall(webstore_install::INVALID_MANIFEST, kInvalidManifestError); | 428 CompleteInstall(webstore_install::INVALID_MANIFEST, kInvalidManifestError); |
427 return; | 429 return; |
428 } | 430 } |
429 | 431 |
430 install_ui_ = CreateInstallUI(); | 432 install_ui_ = CreateInstallUI(); |
431 install_ui_->ConfirmStandaloneInstall( | 433 install_ui_->ConfirmStandaloneInstall( |
432 this, localized_extension, &icon_, install_prompt_); | 434 this, localized_extension, &icon_, install_prompt_); |
433 } | 435 } |
434 | 436 |
435 void WebstoreStandaloneInstaller::OnWebStoreDataFetcherDone() { | 437 void WebstoreStandaloneInstaller::OnWebStoreDataFetcherDone() { |
436 // An instance of this class is passed in as a delegate for the | 438 // An instance of this class is passed in as a delegate for the |
437 // WebstoreInstallHelper, ExtensionInstallPrompt and WebstoreInstaller, and | 439 // WebstoreInstallHelper, ExtensionInstallPrompt and WebstoreInstaller, and |
438 // therefore needs to remain alive until they are done. Clear the webstore | 440 // therefore needs to remain alive until they are done. Clear the webstore |
439 // data fetcher to avoid calling Release in AbortInstall while any of these | 441 // data fetcher to avoid calling Release in AbortInstall while any of these |
440 // operations are in progress. | 442 // operations are in progress. |
441 webstore_data_fetcher_.reset(); | 443 webstore_data_fetcher_.reset(); |
442 } | 444 } |
443 | 445 |
444 } // namespace extensions | 446 } // namespace extensions |
OLD | NEW |