summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorrouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 00:37:09 +0000
committerrouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 00:37:09 +0000
commitbd5bf9243fa692f4372e094fb89c6183a7390592 (patch)
tree683fb0f39314b3a41885cefd0c27066875e6b26a /sync
parentfdc89089cb4909236140019ad190458821ca4f85 (diff)
downloadchromium_src-bd5bf9243fa692f4372e094fb89c6183a7390592.zip
chromium_src-bd5bf9243fa692f4372e094fb89c6183a7390592.tar.gz
chromium_src-bd5bf9243fa692f4372e094fb89c6183a7390592.tar.bz2
Sync user's custom spellcheck dictionary
This CL is initial work for for syncing user dictionary across multiple computers. The sync is hidden behind --enable-sync-dictionary flag for now. Do not flip this flag unless your are connected to a sync server that supports dictionary sync. If you don't know whether your sync server supports dictionary sync, then most likely it does not. BUG=51636 Review URL: https://chromiumcodereview.appspot.com/11445002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178178 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/internal_api/public/base/model_type.h4
-rw-r--r--sync/protocol/dictionary_specifics.proto18
-rw-r--r--sync/protocol/nigori_specifics.proto4
-rw-r--r--sync/protocol/proto_value_conversions.cc10
-rw-r--r--sync/protocol/proto_value_conversions.h4
-rw-r--r--sync/protocol/proto_value_conversions_unittest.cc9
-rw-r--r--sync/protocol/sync.proto2
-rw-r--r--sync/protocol/sync_proto.gyp1
-rw-r--r--sync/syncable/model_type.cc23
-rw-r--r--sync/syncable/nigori_util.cc3
-rw-r--r--sync/tools/testserver/chromiumsync.py9
-rw-r--r--sync/util/data_type_histogram.h3
12 files changed, 85 insertions, 5 deletions
diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h
index d8a5348..773cde5 100644
--- a/sync/internal_api/public/base/model_type.h
+++ b/sync/internal_api/public/base/model_type.h
@@ -85,7 +85,9 @@ enum ModelType {
HISTORY_DELETE_DIRECTIVES,
// Synced push notifications.
SYNCED_NOTIFICATIONS,
- LAST_USER_MODEL_TYPE = SYNCED_NOTIFICATIONS,
+ // Custom spelling dictionary.
+ DICTIONARY,
+ LAST_USER_MODEL_TYPE = DICTIONARY,
// An object representing a set of Nigori keys.
NIGORI,
diff --git a/sync/protocol/dictionary_specifics.proto b/sync/protocol/dictionary_specifics.proto
new file mode 100644
index 0000000..46e49e8
--- /dev/null
+++ b/sync/protocol/dictionary_specifics.proto
@@ -0,0 +1,18 @@
+// Copyright (c) 2012 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 the dictionary.
+
+syntax = "proto2";
+
+option optimize_for = LITE_RUNTIME;
+option retain_unknown_fields = true;
+
+package sync_pb;
+
+// Properties of Dictionary objects.
+message DictionarySpecifics {
+ // A spelling which when typed is treated as a correctly spelled word.
+ optional string word = 1;
+}
diff --git a/sync/protocol/nigori_specifics.proto b/sync/protocol/nigori_specifics.proto
index e591408..a5aadb8 100644
--- a/sync/protocol/nigori_specifics.proto
+++ b/sync/protocol/nigori_specifics.proto
@@ -112,5 +112,9 @@ message NigoriSpecifics {
// Note: this field may not be set if the custom passphrase was applied before
// this field was introduced.
optional int64 custom_passphrase_time = 33;
+
+ // Boolean corresponding to whether custom spelling dictionary should be
+ // encrypted.
+ optional bool encrypt_dictionary = 34;
}
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index f0ddf21..fb5f568 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -16,6 +16,7 @@
#include "sync/protocol/app_specifics.pb.h"
#include "sync/protocol/autofill_specifics.pb.h"
#include "sync/protocol/bookmark_specifics.pb.h"
+#include "sync/protocol/dictionary_specifics.pb.h"
#include "sync/protocol/encryption.pb.h"
#include "sync/protocol/experiments_specifics.pb.h"
#include "sync/protocol/extension_setting_specifics.pb.h"
@@ -319,6 +320,13 @@ DictionaryValue* DeviceInfoSpecificsToValue(
return value;
}
+base::DictionaryValue* DictionarySpecificsToValue(
+ const sync_pb::DictionarySpecifics& proto) {
+ DictionaryValue* value = new DictionaryValue();
+ SET_STR(word);
+ return value;
+}
+
DictionaryValue* ExperimentsSpecificsToValue(
const sync_pb::ExperimentsSpecifics& proto) {
DictionaryValue* value = new DictionaryValue();
@@ -372,6 +380,7 @@ DictionaryValue* NigoriSpecificsToValue(
SET_BOOL(encrypt_app_settings);
SET_BOOL(encrypt_apps);
SET_BOOL(encrypt_search_engines);
+ SET_BOOL(encrypt_dictionary);
SET_BOOL(encrypt_everything);
SET_BOOL(sync_tab_favicons);
SET_ENUM(passphrase_type, PassphraseTypeString);
@@ -468,6 +477,7 @@ DictionaryValue* EntitySpecificsToValue(
SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue);
SET_FIELD(bookmark, BookmarkSpecificsToValue);
SET_FIELD(device_info, DeviceInfoSpecificsToValue);
+ SET_FIELD(dictionary, DictionarySpecificsToValue);
SET_FIELD(experiments, ExperimentsSpecificsToValue);
SET_FIELD(extension, ExtensionSpecificsToValue);
SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue);
diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h
index b3f3737..26eadbd0 100644
--- a/sync/protocol/proto_value_conversions.h
+++ b/sync/protocol/proto_value_conversions.h
@@ -29,6 +29,7 @@ class DebugEventInfo;
class DebugInfo;
class DeviceInfoSpecifics;
class DeviceInformation;
+class DictionarySpecifics;
class EncryptedData;
class EntitySpecifics;
class EverythingDirective;
@@ -140,6 +141,9 @@ SYNC_EXPORT_PRIVATE base::DictionaryValue* BookmarkSpecificsToValue(
SYNC_EXPORT_PRIVATE base::DictionaryValue* DeviceInfoSpecificsToValue(
const sync_pb::DeviceInfoSpecifics& device_info_specifics);
+SYNC_EXPORT_PRIVATE base::DictionaryValue* DictionarySpecificsToValue(
+ const sync_pb::DictionarySpecifics& dictionary_specifics);
+
SYNC_EXPORT_PRIVATE base::DictionaryValue* ExperimentsSpecificsToValue(
const sync_pb::ExperimentsSpecifics& proto);
diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc
index 2bac903..74ae4f2 100644
--- a/sync/protocol/proto_value_conversions_unittest.cc
+++ b/sync/protocol/proto_value_conversions_unittest.cc
@@ -50,7 +50,7 @@ TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) {
// If this number changes, that means we added or removed a data
// type. Don't forget to add a unit test for {New
// type}SpecificsToValue below.
- EXPECT_EQ(22, MODEL_TYPE_COUNT);
+ EXPECT_EQ(23, MODEL_TYPE_COUNT);
// We'd also like to check if we changed any field in our messages.
// However, that's hard to do: sizeof could work, but it's
@@ -195,6 +195,10 @@ TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) {
TestSpecificsToValue(TypedUrlSpecificsToValue);
}
+TEST_F(ProtoValueConversionsTest, DictionarySpecificsToValue) {
+ TestSpecificsToValue(DictionarySpecificsToValue);
+}
+
// TODO(akalin): Figure out how to better test EntitySpecificsToValue.
TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) {
@@ -209,13 +213,14 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) {
SET_FIELD(autofill);
SET_FIELD(autofill_profile);
SET_FIELD(bookmark);
+ SET_FIELD(device_info);
+ SET_FIELD(dictionary);
SET_FIELD(experiments);
SET_FIELD(extension);
SET_FIELD(extension_setting);
SET_FIELD(history_delete_directive);
SET_FIELD(nigori);
SET_FIELD(password);
- SET_FIELD(device_info);
SET_FIELD(preference);
SET_FIELD(priority_preference);
SET_FIELD(search_engine);
diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto
index 1c4f23c..44dd5908 100644
--- a/sync/protocol/sync.proto
+++ b/sync/protocol/sync.proto
@@ -22,6 +22,7 @@ import "bookmark_specifics.proto";
import "client_commands.proto";
import "client_debug_info.proto";
import "device_info_specifics.proto";
+import "dictionary_specifics.proto";
import "encryption.proto";
import "experiments_specifics.proto";
import "extension_setting_specifics.proto";
@@ -108,6 +109,7 @@ message EntitySpecifics {
optional DeviceInfoSpecifics device_info = 154522;
optional ExperimentsSpecifics experiments = 161496;
optional PriorityPreferenceSpecifics priority_preference = 163425;
+ optional DictionarySpecifics dictionary = 170540;
}
message SyncEntity {
diff --git a/sync/protocol/sync_proto.gyp b/sync/protocol/sync_proto.gyp
index 31d717f..edcb897 100644
--- a/sync/protocol/sync_proto.gyp
+++ b/sync/protocol/sync_proto.gyp
@@ -19,6 +19,7 @@
'client_commands.proto',
'client_debug_info.proto',
'device_info_specifics.proto',
+ 'dictionary_specifics.proto',
'encryption.proto',
'experiments_specifics.proto',
'extension_setting_specifics.proto',
diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc
index 1b0bee4..f6e5cee 100644
--- a/sync/syncable/model_type.cc
+++ b/sync/syncable/model_type.cc
@@ -88,6 +88,9 @@ void AddDefaultFieldValue(ModelType datatype,
case PRIORITY_PREFERENCES:
specifics->mutable_priority_preference();
break;
+ case DICTIONARY:
+ specifics->mutable_dictionary();
+ break;
default:
NOTREACHED() << "No known extension for model type.";
}
@@ -162,6 +165,9 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) {
case PRIORITY_PREFERENCES:
return sync_pb::EntitySpecifics::kPriorityPreferenceFieldNumber;
break;
+ case DICTIONARY:
+ return sync_pb::EntitySpecifics::kDictionaryFieldNumber;
+ break;
default:
NOTREACHED() << "No known extension for model type.";
return 0;
@@ -269,6 +275,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) {
if (specifics.has_priority_preference())
return PRIORITY_PREFERENCES;
+ if (specifics.has_dictionary())
+ return DICTIONARY;
+
return UNSPECIFIED;
}
@@ -358,6 +367,8 @@ const char* ModelTypeToString(ModelType model_type) {
return "Experiments";
case PRIORITY_PREFERENCES:
return "Priority Preferences";
+ case DICTIONARY:
+ return "Dictionary";
default:
break;
}
@@ -433,6 +444,8 @@ ModelType ModelTypeFromString(const std::string& model_type_string) {
return EXPERIMENTS;
else if (model_type_string == "Priority Preferences")
return PRIORITY_PREFERENCES;
+ else if (model_type_string == "Dictionary")
+ return DICTIONARY;
else
NOTREACHED() << "No known model type corresponding to "
<< model_type_string << ".";
@@ -511,6 +524,8 @@ std::string ModelTypeToRootTag(ModelType type) {
return "google_chrome_experiments";
case PRIORITY_PREFERENCES:
return "google_chrome_priority_preferences";
+ case DICTIONARY:
+ return "google_chrome_dictionary";
default:
break;
}
@@ -542,6 +557,7 @@ const char kSyncedNotificationType[] = "SYNCED_NOTIFICATION";
const char kDeviceInfoNotificationType[] = "DEVICE_INFO";
const char kExperimentsNotificationType[] = "EXPERIMENTS";
const char kPriorityPreferenceNotificationType[] = "PRIORITY_PREFERENCE";
+const char kDictionaryNotificationType[] = "DICTIONARY";
} // namespace
bool RealModelTypeToNotificationType(ModelType model_type,
@@ -604,6 +620,10 @@ bool RealModelTypeToNotificationType(ModelType model_type,
return true;
case PRIORITY_PREFERENCES:
*notification_type = kPriorityPreferenceNotificationType;
+ return true;
+ case DICTIONARY:
+ *notification_type = kDictionaryNotificationType;
+ return true;
default:
break;
}
@@ -668,6 +688,9 @@ bool NotificationTypeToRealModelType(const std::string& notification_type,
} else if (notification_type == kPriorityPreferenceNotificationType) {
*model_type = PRIORITY_PREFERENCES;
return true;
+ } else if (notification_type == kDictionaryNotificationType) {
+ *model_type = DICTIONARY;
+ return true;
}
*model_type = UNSPECIFIED;
return false;
diff --git a/sync/syncable/nigori_util.cc b/sync/syncable/nigori_util.cc
index 584adff..ffa2599 100644
--- a/sync/syncable/nigori_util.cc
+++ b/sync/syncable/nigori_util.cc
@@ -275,6 +275,7 @@ void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types,
nigori->set_encrypt_apps(encrypted_types.Has(APPS));
nigori->set_encrypt_app_notifications(
encrypted_types.Has(APP_NOTIFICATIONS));
+ nigori->set_encrypt_dictionary(encrypted_types.Has(DICTIONARY));
}
ModelTypeSet GetEncryptedTypesFromNigori(
@@ -310,6 +311,8 @@ ModelTypeSet GetEncryptedTypesFromNigori(
encrypted_types.Put(APPS);
if (nigori.encrypt_app_notifications())
encrypted_types.Put(APP_NOTIFICATIONS);
+ if (nigori.encrypt_dictionary())
+ encrypted_types.Put(DICTIONARY);
return encrypted_types;
}
diff --git a/sync/tools/testserver/chromiumsync.py b/sync/tools/testserver/chromiumsync.py
index eb631c2..f6636ae 100644
--- a/sync/tools/testserver/chromiumsync.py
+++ b/sync/tools/testserver/chromiumsync.py
@@ -24,6 +24,7 @@ import app_setting_specifics_pb2
import app_specifics_pb2
import autofill_specifics_pb2
import bookmark_specifics_pb2
+import dictionary_specifics_pb2
import get_updates_caller_info_pb2
import extension_setting_specifics_pb2
import extension_specifics_pb2
@@ -52,6 +53,7 @@ ALL_TYPES = (
AUTOFILL_PROFILE,
BOOKMARK,
DEVICE_INFO,
+ DICTIONARY,
EXPERIMENTS,
EXTENSIONS,
HISTORY_DELETE_DIRECTIVE,
@@ -63,9 +65,9 @@ ALL_TYPES = (
SYNCED_NOTIFICATION,
THEME,
TYPED_URL,
- EXTENSION_SETTINGS) = range(20)
+ EXTENSION_SETTINGS) = range(21)
-# An eumeration on the frequency at which the server should send errors
+# An enumeration on the frequency at which the server should send errors
# to the client. This would be specified by the url that triggers the error.
# Note: This enum should be kept in the same order as the enum in sync_test.h.
SYNC_ERROR_FREQUENCY = (
@@ -87,6 +89,7 @@ SYNC_TYPE_TO_DESCRIPTOR = {
AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'],
BOOKMARK: SYNC_TYPE_FIELDS['bookmark'],
DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'],
+ DICTIONARY: SYNC_TYPE_FIELDS['dictionary'],
EXPERIMENTS: SYNC_TYPE_FIELDS['experiments'],
EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'],
EXTENSIONS: SYNC_TYPE_FIELDS['extension'],
@@ -481,6 +484,8 @@ class SyncDataModel(object):
parent_tag=ROOT_ID, sync_type=THEME),
PermanentItem('google_chrome_typed_urls', name='Typed URLs',
parent_tag=ROOT_ID, sync_type=TYPED_URL),
+ PermanentItem('google_chrome_dictionary', name='Dictionary',
+ parent_tag=ROOT_ID, sync_type=DICTIONARY),
]
def __init__(self):
diff --git a/sync/util/data_type_histogram.h b/sync/util/data_type_histogram.h
index 7b69cf8..e72cebb 100644
--- a/sync/util/data_type_histogram.h
+++ b/sync/util/data_type_histogram.h
@@ -96,6 +96,9 @@
case ::syncer::PRIORITY_PREFERENCES :\
PER_DATA_TYPE_MACRO("PriorityPreferences"); \
break; \
+ case ::syncer::DICTIONARY: \
+ PER_DATA_TYPE_MACRO("Dictionary"); \
+ break; \
default: \
NOTREACHED() << "Unknown datatype " \
<< ::syncer::ModelTypeToString(datatype); \