| Index: chrome/browser/extensions/external_provider_impl.cc
|
| diff --git a/chrome/browser/extensions/external_provider_impl.cc b/chrome/browser/extensions/external_provider_impl.cc
|
| index 9b62f0f43c3d092d0295db9f60867bb8f8e6b31c..3eff33cad83ba58b095b25b90f4aedac1c0d34cb 100644
|
| --- a/chrome/browser/extensions/external_provider_impl.cc
|
| +++ b/chrome/browser/extensions/external_provider_impl.cc
|
| @@ -39,6 +39,7 @@
|
| #include "components/crx_file/id_util.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "extensions/browser/extension_system.h"
|
| +#include "extensions/browser/external_install_info.h"
|
| #include "extensions/browser/external_provider_interface.h"
|
| #include "extensions/common/extension.h"
|
| #include "extensions/common/manifest.h"
|
| @@ -120,10 +121,63 @@ void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
|
| prefs_.reset(prefs);
|
| ready_ = true; // Queries for extensions are allowed from this point.
|
|
|
| + ScopedVector<ExternalInstallInfoUpdateUrl> external_update_url_extensions;
|
| + ScopedVector<ExternalInstallInfoFile> external_file_extensions;
|
| +
|
| + RetrieveExtensionsFromPrefs(&external_update_url_extensions,
|
| + &external_file_extensions);
|
| + for (const auto& extension : external_update_url_extensions)
|
| + service_->OnExternalExtensionUpdateUrlFound(*extension, true);
|
| +
|
| + for (const auto& extension : external_file_extensions)
|
| + service_->OnExternalExtensionFileFound(*extension);
|
| +
|
| + service_->OnExternalProviderReady(this);
|
| +}
|
| +
|
| +void ExternalProviderImpl::UpdatePrefs(base::DictionaryValue* prefs) {
|
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + // We only expect updates from windows registry.
|
| + CHECK(crx_location_ == Manifest::EXTERNAL_REGISTRY);
|
| +
|
| + // Check if the service is still alive. It is possible that it went
|
| + // away while |loader_| was working on the FILE thread.
|
| + if (!service_)
|
| + return;
|
| +
|
| + std::set<std::string> removed_extensions;
|
| + // Find extensions that were removed by this ExternalProvider.
|
| + for (base::DictionaryValue::Iterator i(*prefs_); !i.IsAtEnd(); i.Advance()) {
|
| + const std::string& extension_id = i.key();
|
| + // Don't bother about invalid ids.
|
| + if (!crx_file::id_util::IdIsValid(extension_id))
|
| + continue;
|
| + if (!prefs->HasKey(extension_id))
|
| + removed_extensions.insert(extension_id);
|
| + }
|
| +
|
| + prefs_.reset(prefs);
|
| +
|
| + ScopedVector<ExternalInstallInfoUpdateUrl> external_update_url_extensions;
|
| + ScopedVector<ExternalInstallInfoFile> external_file_extensions;
|
| + RetrieveExtensionsFromPrefs(&external_update_url_extensions,
|
| + &external_file_extensions);
|
| +
|
| + // Notify ExtensionService about completion of finding incremental updates
|
| + // from this provider.
|
| + // Provide the list of added and removed extensions.
|
| + service_->OnExternalProviderUpdateComplete(
|
| + this, external_update_url_extensions, external_file_extensions,
|
| + removed_extensions);
|
| +}
|
| +
|
| +void ExternalProviderImpl::RetrieveExtensionsFromPrefs(
|
| + ScopedVector<ExternalInstallInfoUpdateUrl>* external_update_url_extensions,
|
| + ScopedVector<ExternalInstallInfoFile>* external_file_extensions) {
|
| // Set of unsupported extensions that need to be deleted from prefs_.
|
| std::set<std::string> unsupported_extensions;
|
|
|
| - // Notify ExtensionService about all the extensions this provider has.
|
| + // Discover all the extensions this provider has.
|
| for (base::DictionaryValue::Iterator i(*prefs_); !i.IsAtEnd(); i.Advance()) {
|
| const std::string& extension_id = i.key();
|
| const base::DictionaryValue* extension = NULL;
|
| @@ -289,17 +343,16 @@ void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
|
| path = base_path.Append(external_crx);
|
| }
|
|
|
| - Version version(external_version);
|
| - if (!version.IsValid()) {
|
| + scoped_ptr<Version> version(new Version(external_version));
|
| + if (!version->IsValid()) {
|
| LOG(WARNING) << "Malformed extension dictionary for extension: "
|
| << extension_id.c_str() << ". Invalid version string \""
|
| << external_version << "\".";
|
| continue;
|
| }
|
| - service_->OnExternalExtensionFileFound(extension_id, &version, path,
|
| - crx_location_, creation_flags,
|
| - auto_acknowledge_,
|
| - install_immediately_);
|
| + external_file_extensions->push_back(new ExternalInstallInfoFile(
|
| + extension_id, std::move(version), path, crx_location_, creation_flags,
|
| + auto_acknowledge_, install_immediately_));
|
| } else { // if (has_external_update_url)
|
| CHECK(has_external_update_url); // Checking of keys above ensures this.
|
| if (download_location_ == Manifest::INVALID_LOCATION) {
|
| @@ -307,20 +360,18 @@ void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
|
| << "extensions from update URLs.";
|
| continue;
|
| }
|
| - GURL update_url(external_update_url);
|
| - if (!update_url.is_valid()) {
|
| + scoped_ptr<GURL> update_url(new GURL(external_update_url));
|
| + if (!update_url->is_valid()) {
|
| LOG(WARNING) << "Malformed extension dictionary for extension: "
|
| << extension_id.c_str() << ". Key " << kExternalUpdateUrl
|
| << " has value \"" << external_update_url
|
| << "\", which is not a valid URL.";
|
| continue;
|
| }
|
| - service_->OnExternalExtensionUpdateUrlFound(extension_id,
|
| - install_parameter,
|
| - update_url,
|
| - download_location_,
|
| - creation_flags,
|
| - auto_acknowledge_);
|
| + external_update_url_extensions->push_back(
|
| + new ExternalInstallInfoUpdateUrl(
|
| + extension_id, install_parameter, std::move(update_url),
|
| + download_location_, creation_flags, auto_acknowledge_));
|
| }
|
| }
|
|
|
| @@ -330,8 +381,6 @@ void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
|
| // will be uninstalled later because provider doesn't provide it anymore.
|
| prefs_->Remove(*it, NULL);
|
| }
|
| -
|
| - service_->OnExternalProviderReady(this);
|
| }
|
|
|
| void ExternalProviderImpl::ServiceShutdown() {
|
|
|