Chromium Code Reviews| 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..ee27c925169e60279fc32119b14ecf5581b4f544 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" |
| @@ -48,6 +49,8 @@ |
| #include "chrome/browser/prefs/pref_service.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/search_engines/template_url_model.h" |
| +// TODO(akalin): Remove dependency on this. |
| +#include "chrome/browser/sync/glue/extension_util.h" |
| #include "chrome/browser/themes/theme_service.h" |
| #include "chrome/browser/themes/theme_service_factory.h" |
| #include "chrome/browser/ui/webui/shown_sections_handler.h" |
| @@ -1188,6 +1191,74 @@ void ExtensionService::CheckForUpdatesSoon() { |
| } |
| } |
| +namespace { |
| + |
| +bool ShouldAllowInstallFromSync(const Extension& extension) { |
| + return |
| + browser_sync::IsValidAndSyncableExtension(extension) || |
| + browser_sync::IsValidAndSyncableApp(extension); |
|
asargent_no_longer_on_chrome
2011/04/14 23:32:14
I'm not crazy about seeing the ExtensionService us
akalin
2011/04/15 01:17:11
Done.
|
| +} |
| + |
| +} // namespace |
| + |
| +void ExtensionService::ProcessSyncData( |
| + const ExtensionSyncData& extension_sync_data) { |
| + 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) << "Sync tried to uninstall nonexistent extension " << id; |
|
asargent_no_longer_on_chrome
2011/04/14 23:32:14
Note that it's possible we couldn't uninstall beca
akalin
2011/04/15 01:17:11
Ah, okay. Fixed.
|
| + } |
| + 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. |
| + // |
| + // TODO(akalin): Use a different install predicate once we split |
| + // this function into one for extension sync and one for app sync. |
| + pending_extension_manager()->AddFromSync( |
| + id, |
| + extension_sync_data.update_url, |
| + &ShouldAllowInstallFromSync, |
| + 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 |