summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 08:21:05 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 08:21:05 +0000
commit35296fe1812b50829b1efea29aa70d6d300f20f7 (patch)
treeb0db9f4604c903776191ea14ecb9da0ee6b883d3
parent74f566176e7b4b31c690ca039d1045d964dd9205 (diff)
downloadchromium_src-35296fe1812b50829b1efea29aa70d6d300f20f7.zip
chromium_src-35296fe1812b50829b1efea29aa70d6d300f20f7.tar.gz
chromium_src-35296fe1812b50829b1efea29aa70d6d300f20f7.tar.bz2
[Sync] Add history delete directive type
Add new HISTORY_DELETE_DIRECTIVE model type. Update everything that depends on model type. Rename SyncCryptographer test to Cryptographer (since it's already in sync_unit_tests). Add EncryptableUserTypes() function and use that instead of UserTypes() for encryption-related stuff. BUG=141245 TBR=jam@chromium.org Review URL: https://chromiumcodereview.appspot.com/10855037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162323 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/glue/model_association_manager.cc1
-rw-r--r--chrome/browser/sync/profile_sync_service.cc2
-rw-r--r--chrome/browser/sync/sync_prefs.cc6
-rw-r--r--chrome/common/pref_names.cc1
-rw-r--r--chrome/common/pref_names.h1
-rw-r--r--net/tools/testserver/chromiumsync.py9
-rw-r--r--sync/internal_api/public/base/model_type.h7
-rw-r--r--sync/internal_api/sync_encryption_handler_impl.cc16
-rw-r--r--sync/internal_api/sync_encryption_handler_impl_unittest.cc24
-rw-r--r--sync/internal_api/sync_manager_impl_unittest.cc20
-rw-r--r--sync/protocol/history_delete_directive_specifics.proto42
-rw-r--r--sync/protocol/nigori_specifics.proto2
-rw-r--r--sync/protocol/proto_value_conversions.cc25
-rw-r--r--sync/protocol/proto_value_conversions.h21
-rw-r--r--sync/protocol/proto_value_conversions_unittest.cc7
-rw-r--r--sync/protocol/sync.proto2
-rw-r--r--sync/protocol/sync_proto.gyp1
-rw-r--r--sync/syncable/model_type.cc34
-rw-r--r--sync/util/cryptographer_unittest.cc20
-rw-r--r--sync/util/data_type_histogram.h3
20 files changed, 199 insertions, 45 deletions
diff --git a/chrome/browser/sync/glue/model_association_manager.cc b/chrome/browser/sync/glue/model_association_manager.cc
index c3108f7..159c70b 100644
--- a/chrome/browser/sync/glue/model_association_manager.cc
+++ b/chrome/browser/sync/glue/model_association_manager.cc
@@ -52,6 +52,7 @@ static const syncer::ModelType kStartOrder[] = {
syncer::APP_SETTINGS,
syncer::TYPED_URLS,
syncer::PASSWORDS,
+ syncer::HISTORY_DELETE_DIRECTIVES,
};
COMPILE_ASSERT(arraysize(kStartOrder) ==
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index e501525..64b9422 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -1265,7 +1265,7 @@ void ProfileSyncService::UpdateSelectedTypesHistogram(
browser_sync::user_selectable_type::TYPED_URLS
};
- COMPILE_ASSERT(18 == syncer::MODEL_TYPE_COUNT, UpdateCustomConfigHistogram);
+ COMPILE_ASSERT(19 == syncer::MODEL_TYPE_COUNT, UpdateCustomConfigHistogram);
COMPILE_ASSERT(arraysize(model_types) ==
browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT,
UpdateCustomConfigHistogram);
diff --git a/chrome/browser/sync/sync_prefs.cc b/chrome/browser/sync/sync_prefs.cc
index e841eb3..ee9380c 100644
--- a/chrome/browser/sync/sync_prefs.cc
+++ b/chrome/browser/sync/sync_prefs.cc
@@ -120,6 +120,10 @@ void SyncPrefs::SetKeepEverythingSynced(bool keep_everything_synced) {
keep_everything_synced);
}
+// TODO(akalin): If encryption is turned on for all data types,
+// history delete directives are useless and so we shouldn't bother
+// enabling them.
+
syncer::ModelTypeSet SyncPrefs::GetPreferredDataTypes(
syncer::ModelTypeSet registered_types) const {
DCHECK(CalledOnValidThread());
@@ -222,6 +226,8 @@ const char* SyncPrefs::GetPrefNameForDataType(syncer::ModelType data_type) {
return prefs::kSyncSessions;
case syncer::APP_NOTIFICATIONS:
return prefs::kSyncAppNotifications;
+ case syncer::HISTORY_DELETE_DIRECTIVES:
+ return prefs::kSyncHistoryDeleteDirectives;
default:
break;
}
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 7805631..8ebff59 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1616,6 +1616,7 @@ const char kSyncExtensions[] = "sync.extensions";
const char kSyncExtensionSettings[] = "sync.extension_settings";
const char kSyncSearchEngines[] = "sync.search_engines";
const char kSyncSessions[] = "sync.sessions";
+const char kSyncHistoryDeleteDirectives[] = "sync.history_delete_directives";
// Boolean used by enterprise configuration management in order to lock down
// sync.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 39c1cee..323d072 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -576,6 +576,7 @@ extern const char kSyncThemes[];
extern const char kSyncTypedUrls[];
extern const char kSyncExtensions[];
extern const char kSyncExtensionSettings[];
+extern const char kSyncHistoryDeleteDirectives[];
extern const char kSyncManaged[];
extern const char kSyncSearchEngines[];
extern const char kSyncSessions[];
diff --git a/net/tools/testserver/chromiumsync.py b/net/tools/testserver/chromiumsync.py
index 4bc2d85..af3e59a 100644
--- a/net/tools/testserver/chromiumsync.py
+++ b/net/tools/testserver/chromiumsync.py
@@ -27,6 +27,7 @@ import bookmark_specifics_pb2
import get_updates_caller_info_pb2
import extension_setting_specifics_pb2
import extension_specifics_pb2
+import history_delete_directive_specifics_pb2
import nigori_specifics_pb2
import password_specifics_pb2
import preference_specifics_pb2
@@ -50,6 +51,7 @@ ALL_TYPES = (
AUTOFILL_PROFILE,
BOOKMARK,
EXTENSIONS,
+ HISTORY_DELETE_DIRECTIVE,
NIGORI,
PASSWORD,
PREFERENCE,
@@ -57,7 +59,7 @@ ALL_TYPES = (
SESSION,
THEME,
TYPED_URL,
- EXTENSION_SETTINGS) = range(16)
+ EXTENSION_SETTINGS) = range(17)
# An eumeration on the frequency at which the server should send errors
# to the client. This would be specified by the url that triggers the error.
@@ -82,6 +84,7 @@ SYNC_TYPE_TO_DESCRIPTOR = {
BOOKMARK: SYNC_TYPE_FIELDS['bookmark'],
EXTENSION_SETTINGS: SYNC_TYPE_FIELDS['extension_setting'],
EXTENSIONS: SYNC_TYPE_FIELDS['extension'],
+ HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'],
NIGORI: SYNC_TYPE_FIELDS['nigori'],
PASSWORD: SYNC_TYPE_FIELDS['password'],
PREFERENCE: SYNC_TYPE_FIELDS['preference'],
@@ -437,6 +440,10 @@ class SyncDataModel(object):
parent_tag='google_chrome', sync_type=EXTENSION_SETTINGS),
PermanentItem('google_chrome_extensions', name='Extensions',
parent_tag='google_chrome', sync_type=EXTENSIONS),
+ PermanentItem('google_chrome_history_delete_directives',
+ name='History Delete Directives',
+ parent_tag='google_chrome',
+ sync_type=HISTORY_DELETE_DIRECTIVE),
PermanentItem('google_chrome_passwords', name='Passwords',
parent_tag='google_chrome', sync_type=PASSWORD),
PermanentItem('google_chrome_search_engines', name='Search Engines',
diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h
index af528f8..f743bff 100644
--- a/sync/internal_api/public/base/model_type.h
+++ b/sync/internal_api/public/base/model_type.h
@@ -81,7 +81,9 @@ enum ModelType {
EXTENSION_SETTINGS,
// App notifications.
APP_NOTIFICATIONS,
- LAST_USER_MODEL_TYPE = APP_NOTIFICATIONS,
+ // History delete directives.
+ HISTORY_DELETE_DIRECTIVES,
+ LAST_USER_MODEL_TYPE = HISTORY_DELETE_DIRECTIVES,
// An object representing a set of Nigori keys.
NIGORI,
@@ -135,6 +137,9 @@ bool ShouldMaintainPosition(ModelType model_type);
// preference flag, so not all of them are individually user-selectable.
ModelTypeSet UserTypes();
+// This is the subset of UserTypes() that can be encrypted.
+ModelTypeSet EncryptableUserTypes();
+
// Returns a list of all control types.
//
// The control types are intended to contain metadata nodes that are essential
diff --git a/sync/internal_api/sync_encryption_handler_impl.cc b/sync/internal_api/sync_encryption_handler_impl.cc
index c33951e..22f5028 100644
--- a/sync/internal_api/sync_encryption_handler_impl.cc
+++ b/sync/internal_api/sync_encryption_handler_impl.cc
@@ -97,7 +97,7 @@ EnumPassphraseTypeToProto(PassphraseType type) {
return sync_pb::NigoriSpecifics::FROZEN_IMPLICIT_PASSPHRASE;
default:
NOTREACHED();
- return sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE;;
+ return sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE;
};
}
@@ -894,10 +894,10 @@ bool SyncEncryptionHandlerImpl::UpdateEncryptedTypesFromNigori(
ModelTypeSet* encrypted_types = &UnlockVaultMutable(trans)->encrypted_types;
if (nigori.encrypt_everything()) {
EnableEncryptEverythingImpl(trans);
- DCHECK(encrypted_types->Equals(UserTypes()));
+ DCHECK(encrypted_types->Equals(EncryptableUserTypes()));
return true;
} else if (encrypt_everything_) {
- DCHECK(encrypted_types->Equals(UserTypes()));
+ DCHECK(encrypted_types->Equals(EncryptableUserTypes()));
return false;
}
@@ -912,12 +912,12 @@ bool SyncEncryptionHandlerImpl::UpdateEncryptedTypesFromNigori(
!Difference(nigori_encrypted_types, SensitiveTypes()).Empty()) {
if (!encrypt_everything_) {
encrypt_everything_ = true;
- *encrypted_types = UserTypes();
+ *encrypted_types = EncryptableUserTypes();
FOR_EACH_OBSERVER(
Observer, observers_,
OnEncryptedTypesChanged(*encrypted_types, encrypt_everything_));
}
- DCHECK(encrypted_types->Equals(UserTypes()));
+ DCHECK(encrypted_types->Equals(EncryptableUserTypes()));
return false;
}
@@ -1094,7 +1094,7 @@ void SyncEncryptionHandlerImpl::MergeEncryptedTypes(
DCHECK(thread_checker_.CalledOnValidThread());
// Only UserTypes may be encrypted.
- DCHECK(UserTypes().HasAll(new_encrypted_types));
+ DCHECK(EncryptableUserTypes().HasAll(new_encrypted_types));
ModelTypeSet* encrypted_types = &UnlockVaultMutable(trans)->encrypted_types;
if (!encrypted_types->HasAll(new_encrypted_types)) {
@@ -1289,11 +1289,11 @@ void SyncEncryptionHandlerImpl::EnableEncryptEverythingImpl(
syncable::BaseTransaction* const trans) {
ModelTypeSet* encrypted_types = &UnlockVaultMutable(trans)->encrypted_types;
if (encrypt_everything_) {
- DCHECK(encrypted_types->Equals(UserTypes()));
+ DCHECK(encrypted_types->Equals(EncryptableUserTypes()));
return;
}
encrypt_everything_ = true;
- *encrypted_types = UserTypes();
+ *encrypted_types = EncryptableUserTypes();
FOR_EACH_OBSERVER(
Observer, observers_,
OnEncryptedTypesChanged(*encrypted_types, encrypt_everything_));
diff --git a/sync/internal_api/sync_encryption_handler_impl_unittest.cc b/sync/internal_api/sync_encryption_handler_impl_unittest.cc
index d8379e0..eb7ff65 100644
--- a/sync/internal_api/sync_encryption_handler_impl_unittest.cc
+++ b/sync/internal_api/sync_encryption_handler_impl_unittest.cc
@@ -217,15 +217,19 @@ TEST_F(SyncEncryptionHandlerImplTest, NigoriEncryptionTypes) {
Mock::VerifyAndClearExpectations(observer());
Mock::VerifyAndClearExpectations(&observer2);
+ ModelTypeSet encrypted_user_types = EncryptableUserTypes();
+ // We never encrypt history delete directives.
+ encrypted_user_types.Remove(HISTORY_DELETE_DIRECTIVES);
+
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), false));
+ HasModelTypes(encrypted_user_types), false));
EXPECT_CALL(observer2,
OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), false));
+ HasModelTypes(encrypted_user_types), false));
// Set all encrypted types
- encrypted_types = UserTypes();
+ encrypted_types = EncryptableUserTypes();
{
WriteTransaction trans(FROM_HERE, user_share());
encryption_handler()->MergeEncryptedTypes(
@@ -238,7 +242,7 @@ TEST_F(SyncEncryptionHandlerImplTest, NigoriEncryptionTypes) {
}
EXPECT_TRUE(encrypted_types.Equals(
encryption_handler()->GetEncryptedTypesUnsafe()));
- EXPECT_TRUE(encrypted_types.Equals(handler2.GetEncryptedTypesUnsafe()));
+ //EXPECT_TRUE(encrypted_types.Equals(handler2.GetEncryptedTypesUnsafe()));
// Receiving an empty nigori should not reset any encrypted types or trigger
// an observer notification.
@@ -261,7 +265,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EncryptEverythingExplicit) {
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), true));
+ HasModelTypes(EncryptableUserTypes()), true));
EXPECT_FALSE(encryption_handler()->EncryptEverythingEnabled());
ModelTypeSet encrypted_types =
@@ -277,7 +281,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EncryptEverythingExplicit) {
EXPECT_TRUE(encryption_handler()->EncryptEverythingEnabled());
encrypted_types = encryption_handler()->GetEncryptedTypesUnsafe();
- EXPECT_TRUE(encrypted_types.HasAll(UserTypes()));
+ EXPECT_TRUE(encrypted_types.HasAll(EncryptableUserTypes()));
// Receiving the nigori node again shouldn't trigger another notification.
Mock::VerifyAndClearExpectations(observer());
@@ -297,7 +301,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EncryptEverythingImplicit) {
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), true));
+ HasModelTypes(EncryptableUserTypes()), true));
EXPECT_FALSE(encryption_handler()->EncryptEverythingEnabled());
ModelTypeSet encrypted_types =
@@ -313,7 +317,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EncryptEverythingImplicit) {
EXPECT_TRUE(encryption_handler()->EncryptEverythingEnabled());
encrypted_types = encryption_handler()->GetEncryptedTypesUnsafe();
- EXPECT_TRUE(encrypted_types.HasAll(UserTypes()));
+ EXPECT_TRUE(encrypted_types.HasAll(EncryptableUserTypes()));
// Receiving a nigori node with encrypt everything explicitly set shouldn't
// trigger another notification.
@@ -377,7 +381,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldNigori) {
other_encrypted_specifics.mutable_encrypted());
sync_pb::EntitySpecifics our_encrypted_specifics;
our_encrypted_specifics.mutable_bookmark()->set_title("title2");
- ModelTypeSet encrypted_types = UserTypes();
+ ModelTypeSet encrypted_types = EncryptableUserTypes();
// Set up the current encryption state (containing both keys and encrypt
// everything).
@@ -393,7 +397,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldNigori) {
EXPECT_CALL(*observer(), OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(), OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), true));
+ HasModelTypes(EncryptableUserTypes()), true));
{
// Update the encryption handler.
WriteTransaction trans(FROM_HERE, user_share());
diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc
index 5dbb651..831d625 100644
--- a/sync/internal_api/sync_manager_impl_unittest.cc
+++ b/sync/internal_api/sync_manager_impl_unittest.cc
@@ -1419,7 +1419,7 @@ TEST_F(SyncManagerTest, EncryptDataTypesWithNoData) {
EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
EXPECT_CALL(encryption_observer_,
OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), true));
+ HasModelTypes(EncryptableUserTypes()), true));
EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
sync_manager_.GetEncryptionHandler()->EnableEncryptEverything();
EXPECT_TRUE(EncryptEverythingEnabledForTest());
@@ -1473,14 +1473,14 @@ TEST_F(SyncManagerTest, EncryptDataTypesWithData) {
EXPECT_CALL(encryption_observer_,
OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), true));
+ HasModelTypes(EncryptableUserTypes()), true));
EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
sync_manager_.GetEncryptionHandler()->EnableEncryptEverything();
EXPECT_TRUE(EncryptEverythingEnabledForTest());
{
ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
EXPECT_TRUE(GetEncryptedTypesWithTrans(&trans).Equals(
- UserTypes()));
+ EncryptableUserTypes()));
EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
trans.GetWrappedTrans(),
BOOKMARKS,
@@ -1509,7 +1509,8 @@ TEST_F(SyncManagerTest, EncryptDataTypesWithData) {
EXPECT_TRUE(EncryptEverythingEnabledForTest());
{
ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
- EXPECT_TRUE(GetEncryptedTypesWithTrans(&trans).Equals(UserTypes()));
+ EXPECT_TRUE(GetEncryptedTypesWithTrans(&trans).Equals(
+ EncryptableUserTypes()));
EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
trans.GetWrappedTrans(),
BOOKMARKS,
@@ -2006,14 +2007,15 @@ TEST_F(SyncManagerTest, EncryptBookmarksWithLegacyData) {
EXPECT_CALL(encryption_observer_,
OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), true));
+ HasModelTypes(EncryptableUserTypes()), true));
EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
sync_manager_.GetEncryptionHandler()->EnableEncryptEverything();
EXPECT_TRUE(EncryptEverythingEnabledForTest());
{
ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
- EXPECT_TRUE(GetEncryptedTypesWithTrans(&trans).Equals(UserTypes()));
+ EXPECT_TRUE(GetEncryptedTypesWithTrans(&trans).Equals(
+ EncryptableUserTypes()));
EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
trans.GetWrappedTrans(),
BOOKMARKS,
@@ -2093,7 +2095,7 @@ TEST_F(SyncManagerTest, UpdateEntryWithEncryption) {
// Encrypt the datatatype, should set is_unsynced.
EXPECT_CALL(encryption_observer_,
OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), true));
+ HasModelTypes(EncryptableUserTypes()), true));
EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, FULL_ENCRYPTION));
@@ -2418,7 +2420,7 @@ TEST_F(SyncManagerTest, SetBookmarkTitleWithEncryption) {
// Encrypt the datatatype, should set is_unsynced.
EXPECT_CALL(encryption_observer_,
OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), true));
+ HasModelTypes(EncryptableUserTypes()), true));
EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, FULL_ENCRYPTION));
EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
@@ -2515,7 +2517,7 @@ TEST_F(SyncManagerTest, SetNonBookmarkTitleWithEncryption) {
// Encrypt the datatatype, should set is_unsynced.
EXPECT_CALL(encryption_observer_,
OnEncryptedTypesChanged(
- HasModelTypes(UserTypes()), true));
+ HasModelTypes(EncryptableUserTypes()), true));
EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, FULL_ENCRYPTION));
EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
diff --git a/sync/protocol/history_delete_directive_specifics.proto b/sync/protocol/history_delete_directive_specifics.proto
new file mode 100644
index 0000000..557de8d
--- /dev/null
+++ b/sync/protocol/history_delete_directive_specifics.proto
@@ -0,0 +1,42 @@
+// 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 history delete directives.
+
+// Update proto_value_conversions{.h,.cc,_unittest.cc} if you change
+// any fields in this file.
+
+syntax = "proto2";
+
+option optimize_for = LITE_RUNTIME;
+option retain_unknown_fields = true;
+
+package sync_pb;
+
+// All timestamps below are from Sane Time (
+// http://www.chromium.org/developers/design-documents/sane-time )
+// and are in microseconds since the Unix epoch.
+
+// Properties of history delete directive sync objects.
+message HistoryDeleteDirectiveSpecifics {
+ // Exactly one of the fields below must be filled in. Otherwise, this
+ // delete directive must be ignored.
+ optional GlobalIdDirective global_id_directive = 1;
+ optional TimeRangeDirective time_range_directive = 2;
+}
+
+message GlobalIdDirective {
+ // The global IDs of the navigations to delete.
+ repeated int64 global_id = 1;
+}
+
+message TimeRangeDirective {
+ // Both fields below must be filled in. Otherwise, this delete directive
+ // must be ignored.
+
+ // The time on or after which entries must be deleted.
+ optional int64 start_time_usec = 1;
+ // The time on or before which entries must be deleted.
+ optional int64 end_time_usec = 2;
+}
diff --git a/sync/protocol/nigori_specifics.proto b/sync/protocol/nigori_specifics.proto
index 6b3b066..c904783 100644
--- a/sync/protocol/nigori_specifics.proto
+++ b/sync/protocol/nigori_specifics.proto
@@ -51,6 +51,8 @@ message NigoriSpecifics {
// Booleans corresponding to whether a datatype should be encrypted.
// Passwords are always encrypted, so we don't need a field here.
+ // History delete directives need to be consumable by the server, and
+ // thus can't be encrypted.
optional bool encrypt_bookmarks = 13;
optional bool encrypt_preferences = 14;
optional bool encrypt_autofill_profile = 15;
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index 79deafa..9408346 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -19,6 +19,7 @@
#include "sync/protocol/encryption.pb.h"
#include "sync/protocol/extension_setting_specifics.pb.h"
#include "sync/protocol/extension_specifics.pb.h"
+#include "sync/protocol/history_delete_directive_specifics.pb.h"
#include "sync/protocol/nigori_specifics.pb.h"
#include "sync/protocol/password_specifics.pb.h"
#include "sync/protocol/preference_specifics.pb.h"
@@ -206,6 +207,21 @@ DictionaryValue* DeviceInfoSpecificsToValue(
return value;
}
+base::DictionaryValue* GlobalIdDirectiveToValue(
+ const sync_pb::GlobalIdDirective& proto) {
+ DictionaryValue* value = new DictionaryValue();
+ SET_INT64_REP(global_id);
+ return value;
+}
+
+base::DictionaryValue* TimeRangeDirectiveToValue(
+ const sync_pb::TimeRangeDirective& proto) {
+ DictionaryValue* value = new DictionaryValue();
+ SET_INT64(start_time_usec);
+ SET_INT64(end_time_usec);
+ return value;
+}
+
DictionaryValue* AppNotificationToValue(
const sync_pb::AppNotification& proto) {
DictionaryValue* value = new DictionaryValue();
@@ -301,6 +317,14 @@ DictionaryValue* ExtensionSpecificsToValue(
return value;
}
+base::DictionaryValue* HistoryDeleteDirectiveSpecificsToValue(
+ const sync_pb::HistoryDeleteDirectiveSpecifics& proto) {
+ DictionaryValue* value = new DictionaryValue();
+ SET(global_id_directive, GlobalIdDirectiveToValue);
+ SET(time_range_directive, TimeRangeDirectiveToValue);
+ return value;
+}
+
DictionaryValue* NigoriSpecificsToValue(
const sync_pb::NigoriSpecifics& proto) {
DictionaryValue* value = new DictionaryValue();
@@ -408,6 +432,7 @@ DictionaryValue* EntitySpecificsToValue(
SET_FIELD(device_info, DeviceInfoSpecificsToValue);
SET_FIELD(extension, ExtensionSpecificsToValue);
SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue);
+ SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsToValue);
SET_FIELD(nigori, NigoriSpecificsToValue);
SET_FIELD(password, PasswordSpecificsToValue);
SET_FIELD(preference, PreferenceSpecificsToValue);
diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h
index 597b767..fac364e 100644
--- a/sync/protocol/proto_value_conversions.h
+++ b/sync/protocol/proto_value_conversions.h
@@ -25,8 +25,11 @@ class DeviceInfoSpecifics;
class DeviceInformation;
class EncryptedData;
class EntitySpecifics;
+class EverythingDirective;
class ExtensionSettingSpecifics;
class ExtensionSpecifics;
+class GlobalIdDirective;
+class HistoryDeleteDirectiveSpecifics;
class NigoriSpecifics;
class PasswordSpecifics;
class PasswordSpecificsData;
@@ -38,6 +41,7 @@ class SessionTab;
class SessionWindow;
class TabNavigation;
class ThemeSpecifics;
+class TimeRangeDirective;
class TypedUrlSpecifics;
} // namespace sync_pb
@@ -82,6 +86,19 @@ base::DictionaryValue* TabNavigationToValue(
base::DictionaryValue* PasswordSpecificsDataToValue(
const sync_pb::PasswordSpecificsData& password_specifics_data);
+// Sub-protocol of NigoriSpecifics.
+
+base::DictionaryValue* DeviceInformationToValue(
+ const sync_pb::DeviceInformation& device_information);
+
+// Sub-protocol of HistoryDeleteDirectiveSpecifics.
+
+base::DictionaryValue* GlobalIdDirectiveToValue(
+ const sync_pb::GlobalIdDirective& global_id_directive);
+
+base::DictionaryValue* TimeRangeDirectiveToValue(
+ const sync_pb::TimeRangeDirective& time_range_directive);
+
// Main *SpecificsToValue functions.
base::DictionaryValue* AppNotificationToValue(
@@ -108,6 +125,10 @@ base::DictionaryValue* ExtensionSettingSpecificsToValue(
base::DictionaryValue* ExtensionSpecificsToValue(
const sync_pb::ExtensionSpecifics& extension_specifics);
+base::DictionaryValue* HistoryDeleteDirectiveSpecificsToValue(
+ const sync_pb::HistoryDeleteDirectiveSpecifics&
+ history_delete_directive_specifics);
+
base::DictionaryValue* NigoriSpecificsToValue(
const sync_pb::NigoriSpecifics& nigori_specifics);
diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc
index c98023c..3f5d539 100644
--- a/sync/protocol/proto_value_conversions_unittest.cc
+++ b/sync/protocol/proto_value_conversions_unittest.cc
@@ -48,7 +48,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(18, MODEL_TYPE_COUNT);
+ EXPECT_EQ(19, 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
@@ -140,6 +140,10 @@ TEST_F(ProtoValueConversionsTest, ExtensionSpecificsToValue) {
TestSpecificsToValue(ExtensionSpecificsToValue);
}
+TEST_F(ProtoValueConversionsTest, HistoryDeleteDirectiveSpecificsToValue) {
+ TestSpecificsToValue(HistoryDeleteDirectiveSpecificsToValue);
+}
+
TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) {
TestSpecificsToValue(NigoriSpecificsToValue);
}
@@ -188,6 +192,7 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) {
SET_FIELD(bookmark);
SET_FIELD(extension);
SET_FIELD(extension_setting);
+ SET_FIELD(history_delete_directive);
SET_FIELD(nigori);
SET_FIELD(password);
SET_FIELD(device_info);
diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto
index ed4871b..b9d1310 100644
--- a/sync/protocol/sync.proto
+++ b/sync/protocol/sync.proto
@@ -26,6 +26,7 @@ import "encryption.proto";
import "extension_setting_specifics.proto";
import "extension_specifics.proto";
import "get_updates_caller_info.proto";
+import "history_delete_directive_specifics.proto";
import "nigori_specifics.proto";
import "password_specifics.proto";
import "preference_specifics.proto";
@@ -98,6 +99,7 @@ message EntitySpecifics {
optional SearchEngineSpecifics search_engine = 88610;
optional ExtensionSettingSpecifics extension_setting = 96159;
optional AppSettingSpecifics app_setting = 103656;
+ optional HistoryDeleteDirectiveSpecifics history_delete_directive = 150251;
optional DeviceInfoSpecifics device_info = 154522;
}
diff --git a/sync/protocol/sync_proto.gyp b/sync/protocol/sync_proto.gyp
index ce5aba6..d3b9e95 100644
--- a/sync/protocol/sync_proto.gyp
+++ b/sync/protocol/sync_proto.gyp
@@ -23,6 +23,7 @@
'extension_setting_specifics.proto',
'extension_specifics.proto',
'get_updates_caller_info.proto',
+ 'history_delete_directive_specifics.proto',
'nigori_specifics.proto',
'password_specifics.proto',
'preference_specifics.proto',
diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc
index e4993a4..f4e2361 100644
--- a/sync/syncable/model_type.cc
+++ b/sync/syncable/model_type.cc
@@ -73,6 +73,9 @@ void AddDefaultFieldValue(ModelType datatype,
case APP_NOTIFICATIONS:
specifics->mutable_app_notification();
break;
+ case HISTORY_DELETE_DIRECTIVES:
+ specifics->mutable_history_delete_directive();
+ break;
case DEVICE_INFO:
specifics->mutable_device_info();
break;
@@ -138,6 +141,8 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) {
case APP_NOTIFICATIONS:
return sync_pb::EntitySpecifics::kAppNotificationFieldNumber;
break;
+ case HISTORY_DELETE_DIRECTIVES:
+ return sync_pb::EntitySpecifics::kHistoryDeleteDirectiveFieldNumber;
case DEVICE_INFO:
return sync_pb::EntitySpecifics::kDeviceInfoFieldNumber;
break;
@@ -158,7 +163,7 @@ FullModelTypeSet ToFullModelTypeSet(ModelTypeSet in) {
return out;
}
-// Note: keep this consistent with GetModelType in syncable.cc!
+// Note: keep this consistent with GetModelType in entry.cc!
ModelType GetModelType(const sync_pb::SyncEntity& sync_entity) {
DCHECK(!IsRoot(sync_entity)); // Root shouldn't ever go over the wire.
@@ -233,6 +238,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) {
if (specifics.has_app_notification())
return APP_NOTIFICATIONS;
+ if (specifics.has_history_delete_directive())
+ return HISTORY_DELETE_DIRECTIVES;
+
if (specifics.has_device_info())
return DEVICE_INFO;
@@ -251,6 +259,13 @@ ModelTypeSet UserTypes() {
return set;
}
+ModelTypeSet EncryptableUserTypes() {
+ ModelTypeSet encryptable_user_types = UserTypes();
+ // We never encrypt history delete directives.
+ encryptable_user_types.Remove(HISTORY_DELETE_DIRECTIVES);
+ return encryptable_user_types;
+}
+
ModelTypeSet ControlTypes() {
ModelTypeSet set;
for (int i = FIRST_CONTROL_MODEL_TYPE; i <= LAST_CONTROL_MODEL_TYPE; ++i) {
@@ -306,6 +321,8 @@ const char* ModelTypeToString(ModelType model_type) {
return "Extension settings";
case APP_NOTIFICATIONS:
return "App Notifications";
+ case HISTORY_DELETE_DIRECTIVES:
+ return "History Delete Directives";
case DEVICE_INFO:
return "Device Info";
default:
@@ -373,6 +390,8 @@ ModelType ModelTypeFromString(const std::string& model_type_string) {
return EXTENSION_SETTINGS;
else if (model_type_string == "App Notifications")
return APP_NOTIFICATIONS;
+ else if (model_type_string == "History Delete Directives")
+ return HISTORY_DELETE_DIRECTIVES;
else if (model_type_string == "Device Info")
return DEVICE_INFO;
else
@@ -443,6 +462,8 @@ std::string ModelTypeToRootTag(ModelType type) {
return "google_chrome_extension_settings";
case APP_NOTIFICATIONS:
return "google_chrome_app_notifications";
+ case HISTORY_DELETE_DIRECTIVES:
+ return "google_chrome_history_delete_directives";
case DEVICE_INFO:
return "google_chrome_device_info";
default:
@@ -470,6 +491,8 @@ const char kSearchEngineNotificationType[] = "SEARCH_ENGINE";
const char kSessionNotificationType[] = "SESSION";
const char kAutofillProfileNotificationType[] = "AUTOFILL_PROFILE";
const char kAppNotificationNotificationType[] = "APP_NOTIFICATION";
+const char kHistoryDeleteDirectiveNotificationType[] =
+ "HISTORY_DELETE_DIRECTIVE";
const char kDeviceInfoNotificationType[] = "DEVICE_INFO";
} // namespace
@@ -521,6 +544,8 @@ bool RealModelTypeToNotificationType(ModelType model_type,
case APP_NOTIFICATIONS:
*notification_type = kAppNotificationNotificationType;
return true;
+ case HISTORY_DELETE_DIRECTIVES:
+ *notification_type = kHistoryDeleteDirectiveNotificationType;
case DEVICE_INFO:
*notification_type = kDeviceInfoNotificationType;
return true;
@@ -578,13 +603,14 @@ bool NotificationTypeToRealModelType(const std::string& notification_type,
} else if (notification_type == kAppNotificationNotificationType) {
*model_type = APP_NOTIFICATIONS;
return true;
+ } else if (notification_type == kHistoryDeleteDirectiveNotificationType) {
+ *model_type = HISTORY_DELETE_DIRECTIVES;
} else if (notification_type == kDeviceInfoNotificationType) {
*model_type = DEVICE_INFO;;
return true;
- } else {
- *model_type = UNSPECIFIED;
- return false;
}
+ *model_type = UNSPECIFIED;
+ return false;
}
bool IsRealDataType(ModelType model_type) {
diff --git a/sync/util/cryptographer_unittest.cc b/sync/util/cryptographer_unittest.cc
index 9d1b236..1541d36 100644
--- a/sync/util/cryptographer_unittest.cc
+++ b/sync/util/cryptographer_unittest.cc
@@ -21,15 +21,15 @@ using ::testing::_;
} // namespace
-class SyncCryptographerTest : public ::testing::Test {
+class CryptographerTest : public ::testing::Test {
protected:
- SyncCryptographerTest() : cryptographer_(&encryptor_) {}
+ CryptographerTest() : cryptographer_(&encryptor_) {}
FakeEncryptor encryptor_;
Cryptographer cryptographer_;
};
-TEST_F(SyncCryptographerTest, EmptyCantDecrypt) {
+TEST_F(CryptographerTest, EmptyCantDecrypt) {
EXPECT_FALSE(cryptographer_.is_ready());
sync_pb::EncryptedData encrypted;
@@ -39,7 +39,7 @@ TEST_F(SyncCryptographerTest, EmptyCantDecrypt) {
EXPECT_FALSE(cryptographer_.CanDecrypt(encrypted));
}
-TEST_F(SyncCryptographerTest, EmptyCantEncrypt) {
+TEST_F(CryptographerTest, EmptyCantEncrypt) {
EXPECT_FALSE(cryptographer_.is_ready());
sync_pb::EncryptedData encrypted;
@@ -47,7 +47,7 @@ TEST_F(SyncCryptographerTest, EmptyCantEncrypt) {
EXPECT_FALSE(cryptographer_.Encrypt(original, &encrypted));
}
-TEST_F(SyncCryptographerTest, MissingCantDecrypt) {
+TEST_F(CryptographerTest, MissingCantDecrypt) {
KeyParams params = {"localhost", "dummy", "dummy"};
cryptographer_.AddKey(params);
EXPECT_TRUE(cryptographer_.is_ready());
@@ -59,7 +59,7 @@ TEST_F(SyncCryptographerTest, MissingCantDecrypt) {
EXPECT_FALSE(cryptographer_.CanDecrypt(encrypted));
}
-TEST_F(SyncCryptographerTest, CanEncryptAndDecrypt) {
+TEST_F(CryptographerTest, CanEncryptAndDecrypt) {
KeyParams params = {"localhost", "dummy", "dummy"};
EXPECT_TRUE(cryptographer_.AddKey(params));
EXPECT_TRUE(cryptographer_.is_ready());
@@ -78,7 +78,7 @@ TEST_F(SyncCryptographerTest, CanEncryptAndDecrypt) {
EXPECT_EQ(original.SerializeAsString(), decrypted.SerializeAsString());
}
-TEST_F(SyncCryptographerTest, EncryptOnlyIfDifferent) {
+TEST_F(CryptographerTest, EncryptOnlyIfDifferent) {
KeyParams params = {"localhost", "dummy", "dummy"};
EXPECT_TRUE(cryptographer_.AddKey(params));
EXPECT_TRUE(cryptographer_.is_ready());
@@ -109,7 +109,7 @@ TEST_F(SyncCryptographerTest, EncryptOnlyIfDifferent) {
EXPECT_EQ(original.SerializeAsString(), decrypted.SerializeAsString());
}
-TEST_F(SyncCryptographerTest, AddKeySetsDefault) {
+TEST_F(CryptographerTest, AddKeySetsDefault) {
KeyParams params1 = {"localhost", "dummy", "dummy1"};
EXPECT_TRUE(cryptographer_.AddKey(params1));
EXPECT_TRUE(cryptographer_.is_ready());
@@ -144,7 +144,7 @@ TEST_F(SyncCryptographerTest, AddKeySetsDefault) {
#else
#define MAYBE_EncryptExportDecrypt EncryptExportDecrypt
#endif
-TEST_F(SyncCryptographerTest, MAYBE_EncryptExportDecrypt) {
+TEST_F(CryptographerTest, MAYBE_EncryptExportDecrypt) {
sync_pb::EncryptedData nigori;
sync_pb::EncryptedData encrypted;
@@ -183,7 +183,7 @@ TEST_F(SyncCryptographerTest, MAYBE_EncryptExportDecrypt) {
}
}
-TEST_F(SyncCryptographerTest, Bootstrap) {
+TEST_F(CryptographerTest, Bootstrap) {
KeyParams params = {"localhost", "dummy", "dummy"};
cryptographer_.AddKey(params);
diff --git a/sync/util/data_type_histogram.h b/sync/util/data_type_histogram.h
index 90cf605..faf54bf 100644
--- a/sync/util/data_type_histogram.h
+++ b/sync/util/data_type_histogram.h
@@ -81,6 +81,9 @@
case ::syncer::APP_NOTIFICATIONS: \
PER_DATA_TYPE_MACRO("AppNotifications"); \
break; \
+ case ::syncer::HISTORY_DELETE_DIRECTIVES: \
+ PER_DATA_TYPE_MACRO("HistoryDeleteDirectives"); \
+ break; \
case ::syncer::DEVICE_INFO: \
PER_DATA_TYPE_MACRO("DeviceInfo"); \
break; \