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

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

Issue 6852029: [Sync] Move some extension-sync-related logic to ExtensionService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac compile error Created 9 years, 8 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/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 877a803eefce3feba912f52a2c4d1d09faa76562..c10b8e514226fb965f08e2ddd8d10b69f4ceea07 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -38,6 +38,7 @@
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_processes_api.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
+#include "chrome/browser/extensions/extension_sync_data.h"
#include "chrome/browser/extensions/extension_updater.h"
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/extensions/extension_webnavigation_api.h"
@@ -1188,6 +1189,64 @@ void ExtensionService::CheckForUpdatesSoon() {
}
}
+void ExtensionService::ProcessSyncData(
+ const ExtensionSyncData& extension_sync_data,
+ PendingExtensionInfo::ShouldAllowInstallPredicate
+ should_allow_install) {
asargent_no_longer_on_chrome 2011/04/15 18:42:30 Nit: consider just calling this "allow" or somethi
akalin 2011/04/15 21:19:39 Done.
+ const std::string& id = extension_sync_data.id;
+
+ // Handle uninstalls first.
+ if (extension_sync_data.uninstalled) {
+ std::string error;
+ if (!UninstallExtensionHelper(this, id)) {
+ LOG(WARNING) << "Could not uninstall extension " << id
+ << " for sync";
+ }
+ return;
+ }
+
+ const Extension* extension = GetExtensionByIdInternal(id, true, true);
+ // TODO(akalin): Figure out what to do with terminated extensions.
+
+ // Handle already-installed extensions (just update settings).
+ //
+ // TODO(akalin): Ideally, we should be able to set prefs for an
+ // extension regardless of whether or not it's installed (and have
+ // it automatially apply on install).
+ if (extension) {
+ if (extension_sync_data.enabled) {
+ EnableExtension(id);
+ } else {
+ DisableExtension(id);
+ }
+ SetIsIncognitoEnabled(id, extension_sync_data.incognito_enabled);
+ int result = extension->version()->CompareTo(extension_sync_data.version);
+ if (result < 0) {
+ // Extension is outdated.
+ CheckForUpdatesSoon();
+ } else if (result > 0) {
+ // Sync version is outdated. Do nothing for now, as sync code
+ // in other places will eventually update the sync data.
+ //
+ // TODO(akalin): Move that code here.
+ }
+ return;
+ }
+
+ // Handle not-yet-installed extensions.
+ //
+ // TODO(akalin): Replace silent update with a list of enabled
+ // permissions.
+ pending_extension_manager()->AddFromSync(
+ id,
+ extension_sync_data.update_url,
+ should_allow_install,
+ true, // install_silently
+ extension_sync_data.enabled,
+ extension_sync_data.incognito_enabled);
+ CheckForUpdatesSoon();
+}
+
bool ExtensionService::IsIncognitoEnabled(
const std::string& extension_id) const {
// If this is an existing component extension we always allow it to

Powered by Google App Engine
This is Rietveld 408576698