| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sync/internal_api/public/base_node.h" | 5 #include "sync/internal_api/public/base_node.h" |
| 6 | 6 |
| 7 #include <stack> | 7 #include <stack> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 GetEntry()->Get(syncable::SPECIFICS).has_encrypted()) { | 198 GetEntry()->Get(syncable::SPECIFICS).has_encrypted()) { |
| 199 // Special case for legacy bookmarks dealing with encryption. | 199 // Special case for legacy bookmarks dealing with encryption. |
| 200 ServerNameToSyncAPIName(GetBookmarkSpecifics().title(), &result); | 200 ServerNameToSyncAPIName(GetBookmarkSpecifics().title(), &result); |
| 201 } else { | 201 } else { |
| 202 ServerNameToSyncAPIName(GetEntry()->Get(syncable::NON_UNIQUE_NAME), | 202 ServerNameToSyncAPIName(GetEntry()->Get(syncable::NON_UNIQUE_NAME), |
| 203 &result); | 203 &result); |
| 204 } | 204 } |
| 205 return result; | 205 return result; |
| 206 } | 206 } |
| 207 | 207 |
| 208 GURL BaseNode::GetURL() const { | |
| 209 return GURL(GetBookmarkSpecifics().url()); | |
| 210 } | |
| 211 | |
| 212 bool BaseNode::HasChildren() const { | 208 bool BaseNode::HasChildren() const { |
| 213 syncable::Directory* dir = GetTransaction()->GetDirectory(); | 209 syncable::Directory* dir = GetTransaction()->GetDirectory(); |
| 214 syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans(); | 210 syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans(); |
| 215 return dir->HasChildren(trans, GetEntry()->Get(syncable::ID)); | 211 return dir->HasChildren(trans, GetEntry()->Get(syncable::ID)); |
| 216 } | 212 } |
| 217 | 213 |
| 218 int64 BaseNode::GetPredecessorId() const { | 214 int64 BaseNode::GetPredecessorId() const { |
| 219 syncable::Id id_string = GetEntry()->Get(syncable::PREV_ID); | 215 syncable::Id id_string = GetEntry()->Get(syncable::PREV_ID); |
| 220 if (id_string.IsRoot()) | 216 if (id_string.IsRoot()) |
| 221 return kInvalidId; | 217 return kInvalidId; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 node_info->SetString("predecessorId", | 288 node_info->SetString("predecessorId", |
| 293 base::Int64ToString(GetPredecessorId())); | 289 base::Int64ToString(GetPredecessorId())); |
| 294 node_info->SetString("successorId", | 290 node_info->SetString("successorId", |
| 295 base::Int64ToString(GetSuccessorId())); | 291 base::Int64ToString(GetSuccessorId())); |
| 296 node_info->SetString("firstChildId", | 292 node_info->SetString("firstChildId", |
| 297 base::Int64ToString(GetFirstChildId())); | 293 base::Int64ToString(GetFirstChildId())); |
| 298 node_info->Set("entry", GetEntry()->ToValue()); | 294 node_info->Set("entry", GetEntry()->ToValue()); |
| 299 return node_info; | 295 return node_info; |
| 300 } | 296 } |
| 301 | 297 |
| 302 void BaseNode::GetFaviconBytes(std::vector<unsigned char>* output) const { | |
| 303 if (!output) | |
| 304 return; | |
| 305 const std::string& favicon = GetBookmarkSpecifics().favicon(); | |
| 306 output->assign(reinterpret_cast<const unsigned char*>(favicon.data()), | |
| 307 reinterpret_cast<const unsigned char*>(favicon.data() + | |
| 308 favicon.length())); | |
| 309 } | |
| 310 | |
| 311 int64 BaseNode::GetExternalId() const { | 298 int64 BaseNode::GetExternalId() const { |
| 312 return GetEntry()->Get(syncable::LOCAL_EXTERNAL_ID); | 299 return GetEntry()->Get(syncable::LOCAL_EXTERNAL_ID); |
| 313 } | 300 } |
| 314 | 301 |
| 315 const sync_pb::AppSpecifics& BaseNode::GetAppSpecifics() const { | 302 const sync_pb::AppSpecifics& BaseNode::GetAppSpecifics() const { |
| 316 DCHECK_EQ(GetModelType(), APPS); | 303 DCHECK_EQ(GetModelType(), APPS); |
| 317 return GetEntitySpecifics().app(); | 304 return GetEntitySpecifics().app(); |
| 318 } | 305 } |
| 319 | 306 |
| 320 const sync_pb::AutofillSpecifics& BaseNode::GetAutofillSpecifics() const { | 307 const sync_pb::AutofillSpecifics& BaseNode::GetAutofillSpecifics() const { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 const sync_pb::EntitySpecifics& specifics) { | 371 const sync_pb::EntitySpecifics& specifics) { |
| 385 ModelType type = GetModelTypeFromSpecifics(specifics); | 372 ModelType type = GetModelTypeFromSpecifics(specifics); |
| 386 DCHECK_NE(UNSPECIFIED, type); | 373 DCHECK_NE(UNSPECIFIED, type); |
| 387 if (GetModelType() != UNSPECIFIED) { | 374 if (GetModelType() != UNSPECIFIED) { |
| 388 DCHECK_EQ(GetModelType(), type); | 375 DCHECK_EQ(GetModelType(), type); |
| 389 } | 376 } |
| 390 unencrypted_data_.CopyFrom(specifics); | 377 unencrypted_data_.CopyFrom(specifics); |
| 391 } | 378 } |
| 392 | 379 |
| 393 } // namespace syncer | 380 } // namespace syncer |
| OLD | NEW |