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

Unified Diff: chrome/browser/sync/glue/extension_sync_traits.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_sync_traits.h ('k') | chrome/browser/sync/glue/extension_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/extension_sync_traits.cc
diff --git a/chrome/browser/sync/glue/extension_sync_traits.cc b/chrome/browser/sync/glue/extension_sync_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..06739670ee2b2553f008720fd66b88c3340ae85b
--- /dev/null
+++ b/chrome/browser/sync/glue/extension_sync_traits.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/glue/extension_sync_traits.h"
+
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/sync/engine/syncapi.h"
+#include "chrome/browser/sync/protocol/extension_specifics.pb.h"
+
+namespace browser_sync {
+
+ExtensionSyncTraits::ExtensionSyncTraits(
+ syncable::ModelType model_type,
+ const char* root_node_tag,
+ const ExtensionTypeSet& allowed_extension_types,
+ ExtensionSpecificsGetter extension_specifics_getter,
+ ExtensionSpecificsSetter extension_specifics_setter,
+ ExtensionSpecificsEntityGetter extension_specifics_entity_getter)
+ : model_type(model_type),
+ root_node_tag(root_node_tag),
+ allowed_extension_types(allowed_extension_types),
+ extension_specifics_getter(extension_specifics_getter),
+ extension_specifics_setter(extension_specifics_setter),
+ extension_specifics_entity_getter(extension_specifics_entity_getter) {}
+
+namespace {
+
+const sync_pb::ExtensionSpecifics& GetExtensionSpecifics(
+ const sync_api::BaseNode& node) {
+ return node.GetExtensionSpecifics();
+}
+
+void SetExtensionSpecifics(
+ const sync_pb::ExtensionSpecifics& extension_specifics,
+ sync_api::WriteNode* node) {
+ node->SetTitle(UTF8ToWide(extension_specifics.name()));
+ node->SetExtensionSpecifics(extension_specifics);
+}
+
+bool GetExtensionSpecificsFromEntity(
+ const sync_pb::EntitySpecifics& entity_specifics,
+ sync_pb::ExtensionSpecifics* extension_specifics) {
+ if (!entity_specifics.HasExtension(sync_pb::extension)) {
+ return false;
+ }
+ *extension_specifics = entity_specifics.GetExtension(sync_pb::extension);
+ return true;
+}
+
+} // namespace
+
+ExtensionSyncTraits GetExtensionSyncTraits() {
+ ExtensionTypeSet allowed_extension_types;
+ allowed_extension_types.insert(EXTENSION);
+ // We allow user scripts since some of them are actually uploaded to
+ // the gallery as extensions (!).
+ allowed_extension_types.insert(USER_SCRIPT);
+ return ExtensionSyncTraits(syncable::EXTENSIONS,
+ "google_chrome_extensions",
+ allowed_extension_types,
+ &GetExtensionSpecifics,
+ &SetExtensionSpecifics,
+ &GetExtensionSpecificsFromEntity);
+}
+
+} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/glue/extension_sync_traits.h ('k') | chrome/browser/sync/glue/extension_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698