summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 08:41:19 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 08:41:19 +0000
commit017ec4bd5f21cc7cf052c417a69318a1cd43b4e0 (patch)
tree111660562c89946fe18b7b7dbc1700ef09773379
parent427a09387bc17b2925d42294b930fe598667ef26 (diff)
downloadchromium_src-017ec4bd5f21cc7cf052c417a69318a1cd43b4e0.zip
chromium_src-017ec4bd5f21cc7cf052c417a69318a1cd43b4e0.tar.gz
chromium_src-017ec4bd5f21cc7cf052c417a69318a1cd43b4e0.tar.bz2
Added constants, strings, protos for app sync.
BUG=51225 TEST=none needed Review URL: http://codereview.chromium.org/3072022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55201 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/engine/syncapi.cc19
-rw-r--r--chrome/browser/sync/engine/syncapi.h11
-rw-r--r--chrome/browser/sync/protocol/app_specifics.proto30
-rw-r--r--chrome/browser/sync/protocol/sync_proto.gyp1
-rw-r--r--chrome/browser/sync/syncable/model_type.cc16
-rw-r--r--chrome/browser/sync/syncable/model_type.h4
-rw-r--r--chrome/chrome.gyp2
-rw-r--r--chrome/common/chrome_switches.cc6
-rw-r--r--chrome/common/chrome_switches.h2
-rw-r--r--chrome/common/pref_names.cc1
-rw-r--r--chrome/common/pref_names.h1
11 files changed, 92 insertions, 1 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index ac724c6..44424e3 100644
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -34,6 +34,7 @@
#include "chrome/browser/sync/engine/syncer.h"
#include "chrome/browser/sync/engine/syncer_thread.h"
#include "chrome/browser/sync/notifier/server_notifier_thread.h"
+#include "chrome/browser/sync/protocol/app_specifics.pb.h"
#include "chrome/browser/sync/protocol/autofill_specifics.pb.h"
#include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
#include "chrome/browser/sync/protocol/extension_specifics.pb.h"
@@ -253,6 +254,11 @@ int64 BaseNode::GetExternalId() const {
return GetEntry()->Get(syncable::LOCAL_EXTERNAL_ID);
}
+const sync_pb::AppSpecifics& BaseNode::GetAppSpecifics() const {
+ DCHECK(GetModelType() == syncable::APPS);
+ return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::app);
+}
+
const sync_pb::AutofillSpecifics& BaseNode::GetAutofillSpecifics() const {
DCHECK(GetModelType() == syncable::AUTOFILL);
return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::autofill);
@@ -327,6 +333,12 @@ void WriteNode::SetURL(const GURL& url) {
SetBookmarkSpecifics(new_value);
}
+void WriteNode::SetAppSpecifics(
+ const sync_pb::AppSpecifics& new_value) {
+ DCHECK(GetModelType() == syncable::APPS);
+ PutAppSpecificsAndMarkForSyncing(new_value);
+}
+
void WriteNode::SetAutofillSpecifics(
const sync_pb::AutofillSpecifics& new_value) {
DCHECK(GetModelType() == syncable::AUTOFILL);
@@ -418,6 +430,13 @@ void WriteNode::SetExtensionSpecifics(
PutExtensionSpecificsAndMarkForSyncing(new_value);
}
+void WriteNode::PutAppSpecificsAndMarkForSyncing(
+ const sync_pb::AppSpecifics& new_value) {
+ sync_pb::EntitySpecifics entity_specifics;
+ entity_specifics.MutableExtension(sync_pb::app)->CopyFrom(new_value);
+ PutSpecificsAndMarkForSyncing(entity_specifics);
+}
+
void WriteNode::PutThemeSpecificsAndMarkForSyncing(
const sync_pb::ThemeSpecifics& new_value) {
sync_pb::EntitySpecifics entity_specifics;
diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h
index 6587207..8c52233 100644
--- a/chrome/browser/sync/engine/syncapi.h
+++ b/chrome/browser/sync/engine/syncapi.h
@@ -74,6 +74,7 @@ class WriteTransaction;
}
namespace sync_pb {
+class AppSpecifics;
class AutofillSpecifics;
class BookmarkSpecifics;
class EntitySpecifics;
@@ -175,6 +176,10 @@ class BaseNode {
// TODO(ncarter): Remove this datatype-specific accessor.
void GetFaviconBytes(std::vector<unsigned char>* output) const;
+ // Getter specific to the APPS datatype. Returns protobuf
+ // data. Can only be called if GetModelType() == APPS.
+ const sync_pb::AppSpecifics& GetAppSpecifics() const;
+
// Getter specific to the AUTOFILL datatype. Returns protobuf
// data. Can only be called if GetModelType() == AUTOFILL.
const sync_pb::AutofillSpecifics& GetAutofillSpecifics() const;
@@ -316,6 +321,10 @@ class WriteNode : public BaseNode {
void SetURL(const GURL& url);
void SetFaviconBytes(const std::vector<unsigned char>& bytes);
+ // Set the app specifics (id, update url, enabled state, etc).
+ // Should only be called if GetModelType() == APPS.
+ void SetAppSpecifics(const sync_pb::AppSpecifics& specifics);
+
// Set the autofill specifics (name and value).
// Should only be called if GetModelType() == AUTOFILL.
void SetAutofillSpecifics(const sync_pb::AutofillSpecifics& specifics);
@@ -363,6 +372,8 @@ class WriteNode : public BaseNode {
// for internal initialization (you can use them to set the modeltype).
// Additionally, they will mark for syncing if the underlying value
// changes.
+ void PutAppSpecificsAndMarkForSyncing(
+ const sync_pb::AppSpecifics& new_value);
void PutAutofillSpecificsAndMarkForSyncing(
const sync_pb::AutofillSpecifics& new_value);
void PutBookmarkSpecificsAndMarkForSyncing(
diff --git a/chrome/browser/sync/protocol/app_specifics.proto b/chrome/browser/sync/protocol/app_specifics.proto
new file mode 100644
index 0000000..e3206f0
--- /dev/null
+++ b/chrome/browser/sync/protocol/app_specifics.proto
@@ -0,0 +1,30 @@
+// 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.
+//
+// Sync protocol datatype extension for apps.
+
+syntax = "proto2";
+
+// TODO(akalin): Re-enable this once LITE_RUNTIME supports preserving
+// unknown fields.
+
+// option optimize_for = LITE_RUNTIME;
+
+package sync_pb;
+
+import "sync.proto";
+import "extension_specifics.proto";
+
+// Properties of app sync objects.
+//
+// For now, an app is just an extension. We keep the two data types
+// separate for future-proofing purposes.
+message AppSpecifics {
+ // Extension data.
+ optional ExtensionSpecifics extension = 1;
+}
+
+extend EntitySpecifics {
+ optional AppSpecifics app = 48364;
+}
diff --git a/chrome/browser/sync/protocol/sync_proto.gyp b/chrome/browser/sync/protocol/sync_proto.gyp
index 5f381cd..8d8582e 100644
--- a/chrome/browser/sync/protocol/sync_proto.gyp
+++ b/chrome/browser/sync/protocol/sync_proto.gyp
@@ -15,6 +15,7 @@
'sources': [
'sync.proto',
'encryption.proto',
+ 'app_specifics.proto',
'autofill_specifics.proto',
'bookmark_specifics.proto',
'extension_specifics.proto',
diff --git a/chrome/browser/sync/syncable/model_type.cc b/chrome/browser/sync/syncable/model_type.cc
index 4c40498..a7b07c2 100644
--- a/chrome/browser/sync/syncable/model_type.cc
+++ b/chrome/browser/sync/syncable/model_type.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/engine/syncproto.h"
+#include "chrome/browser/sync/protocol/app_specifics.pb.h"
#include "chrome/browser/sync/protocol/autofill_specifics.pb.h"
#include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
#include "chrome/browser/sync/protocol/extension_specifics.pb.h"
@@ -44,6 +45,9 @@ void AddDefaultExtensionValue(syncable::ModelType datatype,
case NIGORI:
specifics->MutableExtension(sync_pb::nigori);
break;
+ case APPS:
+ specifics->MutableExtension(sync_pb::app);
+ break;
default:
NOTREACHED() << "No known extension for model type.";
}
@@ -105,6 +109,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) {
if (specifics.HasExtension(sync_pb::nigori))
return NIGORI;
+ if (specifics.HasExtension(sync_pb::app))
+ return APPS;
+
return UNSPECIFIED;
}
@@ -126,6 +133,8 @@ std::string ModelTypeToString(ModelType model_type) {
return "Extensions";
case NIGORI:
return "Encryption keys";
+ case APPS:
+ return "Apps";
default:
NOTREACHED() << "No known extension for model type.";
return "INVALID";
@@ -143,6 +152,7 @@ const char kThemeNotificationType[] = "THEME";
const char kTypedUrlNotificationType[] = "TYPED_URL";
const char kExtensionNotificationType[] = "EXTENSION";
const char kNigoriNotificationType[] = "NIGORI";
+const char kAppNotificationType[] = "APP";
} // namespace
bool RealModelTypeToNotificationType(ModelType model_type,
@@ -172,6 +182,9 @@ bool RealModelTypeToNotificationType(ModelType model_type,
case NIGORI:
*notification_type = kNigoriNotificationType;
return true;
+ case APPS:
+ *notification_type = kAppNotificationType;
+ return true;
default:
break;
}
@@ -205,6 +218,9 @@ bool NotificationTypeToRealModelType(const std::string& notification_type,
} else if (notification_type == kNigoriNotificationType) {
*model_type = NIGORI;
return true;
+ } else if (notification_type == kAppNotificationType) {
+ *model_type = APPS;
+ return true;
}
*model_type = UNSPECIFIED;
return false;
diff --git a/chrome/browser/sync/syncable/model_type.h b/chrome/browser/sync/syncable/model_type.h
index 613615e..4295d58 100644
--- a/chrome/browser/sync/syncable/model_type.h
+++ b/chrome/browser/sync/syncable/model_type.h
@@ -54,10 +54,12 @@ enum ModelType {
THEMES,
// A typed_url folder or a typed_url object.
TYPED_URLS,
- // A extension folder or a extension object.
+ // An extension folder or an extension object.
EXTENSIONS,
// An object represeting a set of Nigori keys.
NIGORI,
+ // An app folder or an app object.
+ APPS,
MODEL_TYPE_COUNT,
};
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 89f2882..5cb1a8a 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -848,6 +848,8 @@
'<(protoc_out_dir)/chrome/browser/sync/protocol/sync.pb.h',
'<(protoc_out_dir)/chrome/browser/sync/protocol/encryption.pb.cc',
'<(protoc_out_dir)/chrome/browser/sync/protocol/encryption.pb.h',
+ '<(protoc_out_dir)/chrome/browser/sync/protocol/app_specifics.pb.cc',
+ '<(protoc_out_dir)/chrome/browser/sync/protocol/app_specifics.pb.h',
'<(protoc_out_dir)/chrome/browser/sync/protocol/autofill_specifics.pb.cc',
'<(protoc_out_dir)/chrome/browser/sync/protocol/autofill_specifics.pb.h',
'<(protoc_out_dir)/chrome/browser/sync/protocol/bookmark_specifics.pb.cc',
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 97ef576..454fffd 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -219,6 +219,9 @@ const char kDisableSiteSpecificQuirks[] = "disable-site-specific-quirks";
// Disable syncing browser data to a Google Account.
const char kDisableSync[] = "disable-sync";
+// Disable syncing of apps.
+const char kDisableSyncApps[] = "disable-sync-apps";
+
// Disable syncing of autofill.
const char kDisableSyncAutofill[] = "disable-sync-autofill";
@@ -404,6 +407,9 @@ const char kEnableStatsTable[] = "enable-stats-table";
// Enable syncing browser data to a Google Account.
const char kEnableSync[] = "enable-sync";
+// Enable syncing browser apps.
+const char kEnableSyncApps[] = "enable-sync-apps";
+
// Enable syncing browser autofill.
const char kEnableSyncAutofill[] = "enable-sync-autofill";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 50f75d4..cc69770 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -76,6 +76,7 @@ extern const char kDisableSessionStorage[];
extern const char kDisableSharedWorkers[];
extern const char kDisableSiteSpecificQuirks[];
extern const char kDisableSync[];
+extern const char kDisableSyncApps[];
extern const char kDisableSyncAutofill[];
extern const char kDisableSyncBookmarks[];
extern const char kDisableSyncExtensions[];
@@ -129,6 +130,7 @@ extern const char kEnableSearchProviderApiV2[];
extern const char kEnableSpeechInput[];
extern const char kEnableStatsTable[];
extern const char kEnableSync[];
+extern const char kEnableSyncApps[];
extern const char kEnableSyncAutofill[];
extern const char kEnableSyncBookmarks[];
extern const char kEnableSyncExtensions[];
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 72bb0c5..5759678 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -883,6 +883,7 @@ const wchar_t kKeepEverythingSynced[] = L"sync.keep_everything_synced";
const wchar_t kSyncBookmarks[] = L"sync.bookmarks";
const wchar_t kSyncPasswords[] = L"sync.passwords";
const wchar_t kSyncPreferences[] = L"sync.preferences";
+const wchar_t kSyncApps[] = L"sync.apps";
const wchar_t kSyncAutofill[] = L"sync.autofill";
const wchar_t kSyncThemes[] = L"sync.themes";
const wchar_t kSyncTypedUrls[] = L"sync.typed_urls";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 44fbfdb..a522c34 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -318,6 +318,7 @@ extern const wchar_t kKeepEverythingSynced[];
extern const wchar_t kSyncBookmarks[];
extern const wchar_t kSyncPasswords[];
extern const wchar_t kSyncPreferences[];
+extern const wchar_t kSyncApps[];
extern const wchar_t kSyncAutofill[];
extern const wchar_t kSyncThemes[];
extern const wchar_t kSyncTypedUrls[];