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

Unified Diff: chrome/browser/sync/glue/extension_util.cc

Issue 3110008: Massive refactoring of extensions sync code (Closed) Base URL: 76.121.192.83:~/projects/chromium/src
Patch Set: Fixed compile error Created 10 years, 4 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
« no previous file with comments | « chrome/browser/sync/glue/extension_util.h ('k') | chrome/browser/sync/glue/extension_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/extension_util.cc
diff --git a/chrome/browser/sync/glue/extension_util.cc b/chrome/browser/sync/glue/extension_util.cc
index 1fad37e1d3be6fccf8517a39976dd1518bd0f9d8..4ad0f9f8994c0fe2b58094fc83d614d225bed671 100644
--- a/chrome/browser/sync/glue/extension_util.cc
+++ b/chrome/browser/sync/glue/extension_util.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/scoped_ptr.h"
+#include "base/stl_util-inl.h"
#include "base/version.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/sync/protocol/extension_specifics.pb.h"
@@ -17,17 +18,25 @@
namespace browser_sync {
-bool IsExtensionSyncable(const Extension& extension) {
+ExtensionType GetExtensionType(const Extension& extension) {
if (extension.is_theme()) {
- return false;
+ return THEME;
}
// TODO(akalin): Add Extensions::is_app().
if (!extension.GetFullLaunchURL().is_empty()) {
- // We have an app.
- return false;
+ return APP;
+ }
+
+ if (extension.converted_from_user_script()) {
+ return USER_SCRIPT;
}
+ // Otherwise, we just have a regular extension.
+ return EXTENSION;
+}
+
+bool IsExtensionValid(const Extension& extension) {
// TODO(akalin): Figure out if we need to allow some other types.
if (extension.location() != Extension::INTERNAL) {
// We have a non-standard location.
@@ -57,6 +66,13 @@ bool IsExtensionSyncable(const Extension& extension) {
return true;
}
+bool IsExtensionValidAndSyncable(const Extension& extension,
+ const ExtensionTypeSet& allowed_types) {
+ return
+ IsExtensionValid(extension) &&
+ ContainsKey(allowed_types, GetExtensionType(extension));
+}
+
std::string ExtensionSpecificsToString(
const sync_pb::ExtensionSpecifics& specifics) {
std::stringstream ss;
@@ -167,7 +183,7 @@ void GetExtensionSpecifics(const Extension& extension,
void GetExtensionSpecificsHelper(const Extension& extension,
bool enabled, bool incognito_enabled,
sync_pb::ExtensionSpecifics* specifics) {
- DCHECK(IsExtensionSyncable(extension));
+ DCHECK(IsExtensionValid(extension));
const std::string& id = extension.id();
specifics->set_id(id);
specifics->set_version(extension.VersionString());
@@ -180,7 +196,7 @@ void GetExtensionSpecificsHelper(const Extension& extension,
bool IsExtensionOutdated(const Extension& extension,
const sync_pb::ExtensionSpecifics& specifics) {
- DCHECK(IsExtensionSyncable(extension));
+ DCHECK(IsExtensionValid(extension));
DcheckIsExtensionSpecificsValid(specifics);
scoped_ptr<Version> specifics_version(
Version::GetVersionFromString(specifics.version()));
@@ -197,7 +213,7 @@ void SetExtensionProperties(
DcheckIsExtensionSpecificsValid(specifics);
CHECK(extensions_service);
CHECK(extension);
- DCHECK(IsExtensionSyncable(*extension));
+ DCHECK(IsExtensionValid(*extension));
const std::string& id = extension->id();
GURL update_url(specifics.update_url());
if (update_url != extension->update_url()) {
« no previous file with comments | « chrome/browser/sync/glue/extension_util.h ('k') | chrome/browser/sync/glue/extension_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698