summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/glue/extension_sync_traits.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/sync/glue/extension_sync_traits.cc')
-rw-r--r--chrome/browser/sync/glue/extension_sync_traits.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/chrome/browser/sync/glue/extension_sync_traits.cc b/chrome/browser/sync/glue/extension_sync_traits.cc
index 0673967..7ea54d3 100644
--- a/chrome/browser/sync/glue/extension_sync_traits.cc
+++ b/chrome/browser/sync/glue/extension_sync_traits.cc
@@ -6,6 +6,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/sync/engine/syncapi.h"
+#include "chrome/browser/sync/protocol/app_specifics.pb.h"
#include "chrome/browser/sync/protocol/extension_specifics.pb.h"
namespace browser_sync {
@@ -64,4 +65,44 @@ ExtensionSyncTraits GetExtensionSyncTraits() {
&GetExtensionSpecificsFromEntity);
}
+namespace {
+
+const sync_pb::ExtensionSpecifics& GetExtensionSpecificsOfApp(
+ const sync_api::BaseNode& node) {
+ return node.GetAppSpecifics().extension();
+}
+
+void SetExtensionSpecificsOfApp(
+ const sync_pb::ExtensionSpecifics& extension_specifics,
+ sync_api::WriteNode* node) {
+ node->SetTitle(UTF8ToWide(extension_specifics.name()));
+ sync_pb::AppSpecifics app_specifics;
+ *app_specifics.mutable_extension() = extension_specifics;
+ node->SetAppSpecifics(app_specifics);
+}
+
+bool GetExtensionSpecificsFromEntityOfApp(
+ const sync_pb::EntitySpecifics& entity_specifics,
+ sync_pb::ExtensionSpecifics* extension_specifics) {
+ if (!entity_specifics.HasExtension(sync_pb::app)) {
+ return false;
+ }
+ *extension_specifics =
+ entity_specifics.GetExtension(sync_pb::app).extension();
+ return true;
+}
+
+} // namespace
+
+ExtensionSyncTraits GetAppSyncTraits() {
+ ExtensionTypeSet allowed_extension_types;
+ allowed_extension_types.insert(APP);
+ return ExtensionSyncTraits(syncable::APPS,
+ "google_chrome_apps",
+ allowed_extension_types,
+ &GetExtensionSpecificsOfApp,
+ &SetExtensionSpecificsOfApp,
+ &GetExtensionSpecificsFromEntityOfApp);
+}
+
} // namespace browser_sync