Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1212)

Unified Diff: chrome/browser/extensions/external_provider_impl.cc

Issue 1495403002: Observe adding external extensions via windows registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from asargent and devlin Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8c31e2a2ba8ab3e2cd958ddc09839eb1cb9178da 100644
--- a/chrome/browser/extensions/external_provider_impl.cc
+++ b/chrome/browser/extensions/external_provider_impl.cc
@@ -119,7 +119,44 @@ void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
prefs_.reset(prefs);
ready_ = true; // Queries for extensions are allowed from this point.
+ NotifyExtensionsFromPrefs(true);
+ 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);
+
+ // Notify ExtensionService about all the extension this provider has found
+ // "updates" for.
+ // For each update found, this will end up calling
+ // OnExternalExtensionUpdateUrlFound() or OnExternalExtensionFileFound().
+ NotifyExtensionsFromPrefs(false);
+ // Then notify about the completion of update, with list of extensions that
+ // were removed.
+ service_->OnExternalProviderUpdateComplete(this, removed_extensions);
+}
+
+void ExternalProviderImpl::NotifyExtensionsFromPrefs(bool is_initial_load) {
// Set of unsupported extensions that need to be deleted from prefs_.
std::set<std::string> unsupported_extensions;
@@ -320,7 +357,8 @@ void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
update_url,
download_location_,
creation_flags,
- auto_acknowledge_);
+ auto_acknowledge_,
+ is_initial_load);
}
}
@@ -330,8 +368,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() {

Powered by Google App Engine
This is Rietveld 408576698