diff options
author | albertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 22:50:29 +0000 |
---|---|---|
committer | albertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 22:50:29 +0000 |
commit | 58fe019372fa8cf8dee7c5ed5f7e4c69609ec5c0 (patch) | |
tree | 2eba77b6b99335081ec273ef5b26068eef60f756 | |
parent | 1056b6caefdc122e512becdc65c44b9f9574f3a7 (diff) | |
download | chromium_src-58fe019372fa8cf8dee7c5ed5f7e4c69609ec5c0.zip chromium_src-58fe019372fa8cf8dee7c5ed5f7e4c69609ec5c0.tar.gz chromium_src-58fe019372fa8cf8dee7c5ed5f7e4c69609ec5c0.tar.bz2 |
Re-land the protocol extension for syncing passwords patch.
BUG=34176
TEST=none
Review URL: http://codereview.chromium.org/2024006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46747 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/sync/engine/syncapi.cc | 27 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncapi.h | 12 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncproto.h | 1 | ||||
-rw-r--r-- | chrome/browser/sync/protocol/password_specifics.proto | 40 | ||||
-rwxr-xr-x | chrome/browser/sync/protocol/sync_proto.gyp | 1 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/model_type.cc | 7 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/model_type.h | 2 | ||||
-rw-r--r-- | chrome/chrome.gyp | 2 |
8 files changed, 92 insertions, 0 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc index 20bfc12..bace7c4 100644 --- a/chrome/browser/sync/engine/syncapi.cc +++ b/chrome/browser/sync/engine/syncapi.cc @@ -48,6 +48,7 @@ #include "chrome/browser/sync/engine/syncer_thread.h" #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" +#include "chrome/browser/sync/protocol/password_specifics.pb.h" #include "chrome/browser/sync/protocol/preference_specifics.pb.h" #include "chrome/browser/sync/protocol/service_constants.h" #include "chrome/browser/sync/protocol/theme_specifics.pb.h" @@ -483,6 +484,15 @@ const sync_pb::BookmarkSpecifics& BaseNode::GetBookmarkSpecifics() const { return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::bookmark); } +bool BaseNode::GetPasswordSpecifics(sync_pb::PasswordSpecificsData* data) + const { + DCHECK(GetModelType() == syncable::PASSWORD); + DCHECK(data); + const sync_pb::PasswordSpecifics& specifics = + GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::password); + return data->ParseFromString(specifics.blob()); +} + const sync_pb::PreferenceSpecifics& BaseNode::GetPreferenceSpecifics() const { DCHECK(GetModelType() == syncable::PREFERENCES); return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::preference); @@ -557,6 +567,16 @@ void WriteNode::PutBookmarkSpecificsAndMarkForSyncing( PutSpecificsAndMarkForSyncing(entity_specifics); } +void WriteNode::SetPasswordSpecifics( + const sync_pb::PasswordSpecificsData& data) { + DCHECK(GetModelType() == syncable::PASSWORD); + std::string serialized_data; + data.SerializeToString(&serialized_data); + sync_pb::PasswordSpecifics new_value; + new_value.set_blob(serialized_data); + PutPasswordSpecificsAndMarkForSyncing(new_value); +} + void WriteNode::SetPreferenceSpecifics( const sync_pb::PreferenceSpecifics& new_value) { DCHECK(GetModelType() == syncable::PREFERENCES); @@ -569,6 +589,13 @@ void WriteNode::SetThemeSpecifics( PutThemeSpecificsAndMarkForSyncing(new_value); } +void WriteNode::PutPasswordSpecificsAndMarkForSyncing( + const sync_pb::PasswordSpecifics& new_value) { + sync_pb::EntitySpecifics entity_specifics; + entity_specifics.MutableExtension(sync_pb::password)->CopyFrom(new_value); + PutSpecificsAndMarkForSyncing(entity_specifics); +} + void WriteNode::PutPreferenceSpecificsAndMarkForSyncing( const sync_pb::PreferenceSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h index 6420be6..edfd70f 100644 --- a/chrome/browser/sync/engine/syncapi.h +++ b/chrome/browser/sync/engine/syncapi.h @@ -76,6 +76,8 @@ class AutofillSpecifics; class BookmarkSpecifics; class EntitySpecifics; class PreferenceSpecifics; +class PasswordSpecifics; +class PasswordSpecificsData; class ThemeSpecifics; class TypedUrlSpecifics; } @@ -172,6 +174,10 @@ class BaseNode { // data. Can only be called if GetModelType() == AUTOFILL. const sync_pb::AutofillSpecifics& GetAutofillSpecifics() const; + // Getter specific to the PASSWORD datatype. Returns protobuf + // data. Can only be called if GetModelType() == PASSWORD. + bool GetPasswordSpecifics(sync_pb::PasswordSpecificsData*) const; + // Getter specific to the PREFERENCE datatype. Returns protobuf // data. Can only be called if GetModelType() == PREFERENCE. const sync_pb::PreferenceSpecifics& GetPreferenceSpecifics() const; @@ -287,6 +293,10 @@ class WriteNode : public BaseNode { // Should only be called if GetModelType() == AUTOFILL. void SetAutofillSpecifics(const sync_pb::AutofillSpecifics& specifics); + // Set the password specifics. + // Should only be called if GetModelType() == PASSWORD. + void SetPasswordSpecifics(const sync_pb::PasswordSpecificsData& specifics); + // Set the preference specifics (name and value). // Should only be called if GetModelType() == PREFERENCE. void SetPreferenceSpecifics(const sync_pb::PreferenceSpecifics& specifics); @@ -322,6 +332,8 @@ class WriteNode : public BaseNode { const sync_pb::AutofillSpecifics& new_value); void PutBookmarkSpecificsAndMarkForSyncing( const sync_pb::BookmarkSpecifics& new_value); + void PutPasswordSpecificsAndMarkForSyncing( + const sync_pb::PasswordSpecifics& new_value); void PutPreferenceSpecificsAndMarkForSyncing( const sync_pb::PreferenceSpecifics& new_value); void PutThemeSpecificsAndMarkForSyncing( diff --git a/chrome/browser/sync/engine/syncproto.h b/chrome/browser/sync/engine/syncproto.h index b412bea..3b9acb0 100644 --- a/chrome/browser/sync/engine/syncproto.h +++ b/chrome/browser/sync/engine/syncproto.h @@ -8,6 +8,7 @@ #define CHROME_BROWSER_SYNC_ENGINE_SYNCPROTO_H_ #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" +#include "chrome/browser/sync/protocol/password_specifics.pb.h" #include "chrome/browser/sync/protocol/preference_specifics.pb.h" #include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/browser/sync/syncable/model_type.h" diff --git a/chrome/browser/sync/protocol/password_specifics.proto b/chrome/browser/sync/protocol/password_specifics.proto new file mode 100644 index 0000000..4d1bc17 --- /dev/null +++ b/chrome/browser/sync/protocol/password_specifics.proto @@ -0,0 +1,40 @@ +// 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 password data. + +syntax = "proto2"; + +option optimize_for = LITE_RUNTIME; + +package sync_pb; + +import "sync.proto"; + +// These are the properties that get serialized into the |blob| field of +// |PasswordSpecifics|. +message PasswordSpecificsData { + optional int32 scheme = 1; + optional string signon_realm = 2; + optional string origin = 3; + optional string action = 4; + optional string username_element = 5; + optional string username_value = 6; + optional string password_element = 7; + optional string password_value = 8; + optional bool ssl_valid = 9; + optional bool preferred = 10; + optional int64 date_created = 11; + optional bool blacklisted = 12; +} + +// Properties of password sync objects. +message PasswordSpecifics { + optional string key = 1; + optional string blob = 2; +} + +extend EntitySpecifics { + optional PasswordSpecifics password = 45873; +} diff --git a/chrome/browser/sync/protocol/sync_proto.gyp b/chrome/browser/sync/protocol/sync_proto.gyp index 4628ab6..5c3e2be 100755 --- a/chrome/browser/sync/protocol/sync_proto.gyp +++ b/chrome/browser/sync/protocol/sync_proto.gyp @@ -16,6 +16,7 @@ 'sync.proto', 'autofill_specifics.proto', 'bookmark_specifics.proto', + 'password_specifics.proto', 'preference_specifics.proto', 'theme_specifics.proto', 'typed_url_specifics.proto', diff --git a/chrome/browser/sync/syncable/model_type.cc b/chrome/browser/sync/syncable/model_type.cc index 27bfd92..dd3af20 100644 --- a/chrome/browser/sync/syncable/model_type.cc +++ b/chrome/browser/sync/syncable/model_type.cc @@ -7,6 +7,7 @@ #include "chrome/browser/sync/engine/syncproto.h" #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" +#include "chrome/browser/sync/protocol/password_specifics.pb.h" #include "chrome/browser/sync/protocol/preference_specifics.pb.h" #include "chrome/browser/sync/protocol/sync.pb.h" #include "chrome/browser/sync/protocol/theme_specifics.pb.h" @@ -20,6 +21,9 @@ void AddDefaultExtensionValue(syncable::ModelType datatype, case BOOKMARKS: specifics->MutableExtension(sync_pb::bookmark); break; + case PASSWORD: + specifics->MutableExtension(sync_pb::password); + break; case PREFERENCES: specifics->MutableExtension(sync_pb::preference); break; @@ -72,6 +76,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) { if (specifics.HasExtension(sync_pb::bookmark)) return BOOKMARKS; + if (specifics.HasExtension(sync_pb::password)) + return PASSWORD; + if (specifics.HasExtension(sync_pb::preference)) return PREFERENCES; diff --git a/chrome/browser/sync/syncable/model_type.h b/chrome/browser/sync/syncable/model_type.h index dc7aceb..517484f 100644 --- a/chrome/browser/sync/syncable/model_type.h +++ b/chrome/browser/sync/syncable/model_type.h @@ -44,6 +44,8 @@ enum ModelType { // A preference folder or a preference object. PREFERENCES, + // A password folder or password object. + PASSWORD, // An autofill folder or an autofill object. AUTOFILL, // A themes folder or a themes object. diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index d66de827..ee1ce24 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -810,6 +810,8 @@ '<(protoc_out_dir)/chrome/browser/sync/protocol/autofill_specifics.pb.h', '<(protoc_out_dir)/chrome/browser/sync/protocol/bookmark_specifics.pb.cc', '<(protoc_out_dir)/chrome/browser/sync/protocol/bookmark_specifics.pb.h', + '<(protoc_out_dir)/chrome/browser/sync/protocol/password_specifics.pb.cc', + '<(protoc_out_dir)/chrome/browser/sync/protocol/password_specifics.pb.h', '<(protoc_out_dir)/chrome/browser/sync/protocol/preference_specifics.pb.cc', '<(protoc_out_dir)/chrome/browser/sync/protocol/preference_specifics.pb.h', '<(protoc_out_dir)/chrome/browser/sync/protocol/theme_specifics.pb.cc', |