OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/sync/internal_api/change_record.h" | |
6 | |
7 #include "base/string_number_conversions.h" | |
8 #include "base/values.h" | |
9 #include "chrome/browser/sync/internal_api/base_node.h" | |
10 #include "chrome/browser/sync/internal_api/read_node.h" | |
11 #include "sync/protocol/proto_value_conversions.h" | |
12 | |
13 namespace sync_api { | |
14 | |
15 ChangeRecord::ChangeRecord() | |
16 : id(kInvalidId), action(ACTION_ADD) {} | |
17 | |
18 ChangeRecord::~ChangeRecord() {} | |
19 | |
20 DictionaryValue* ChangeRecord::ToValue() const { | |
21 DictionaryValue* value = new DictionaryValue(); | |
22 std::string action_str; | |
23 switch (action) { | |
24 case ACTION_ADD: | |
25 action_str = "Add"; | |
26 break; | |
27 case ACTION_DELETE: | |
28 action_str = "Delete"; | |
29 break; | |
30 case ACTION_UPDATE: | |
31 action_str = "Update"; | |
32 break; | |
33 default: | |
34 NOTREACHED(); | |
35 action_str = "Unknown"; | |
36 break; | |
37 } | |
38 value->SetString("action", action_str); | |
39 value->SetString("id", base::Int64ToString(id)); | |
40 if (action == ACTION_DELETE) { | |
41 if (extra.get()) { | |
42 value->Set("extra", extra->ToValue()); | |
43 } | |
44 value->Set("specifics", | |
45 browser_sync::EntitySpecificsToValue(specifics)); | |
46 } | |
47 return value; | |
48 } | |
49 | |
50 ExtraPasswordChangeRecordData::ExtraPasswordChangeRecordData() {} | |
51 | |
52 ExtraPasswordChangeRecordData::ExtraPasswordChangeRecordData( | |
53 const sync_pb::PasswordSpecificsData& data) | |
54 : unencrypted_(data) { | |
55 } | |
56 | |
57 ExtraPasswordChangeRecordData::~ExtraPasswordChangeRecordData() {} | |
58 | |
59 DictionaryValue* ExtraPasswordChangeRecordData::ToValue() const { | |
60 return browser_sync::PasswordSpecificsDataToValue(unencrypted_); | |
61 } | |
62 | |
63 const sync_pb::PasswordSpecificsData& | |
64 ExtraPasswordChangeRecordData::unencrypted() const { | |
65 return unencrypted_; | |
66 } | |
67 | |
68 } // namespace sync_api | |
69 | |
OLD | NEW |