| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/bookmarks/bookmark_codec.h" | 5 #include "chrome/browser/bookmarks/bookmark_codec.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 16 | 16 |
| 17 using base::Time; | 17 using base::Time; |
| 18 | 18 |
| 19 const wchar_t* BookmarkCodec::kRootsKey = L"roots"; | 19 const char* BookmarkCodec::kRootsKey = "roots"; |
| 20 const wchar_t* BookmarkCodec::kRootFolderNameKey = L"bookmark_bar"; | 20 const char* BookmarkCodec::kRootFolderNameKey = "bookmark_bar"; |
| 21 const wchar_t* BookmarkCodec::kOtherBookmarkFolderNameKey = L"other"; | 21 const char* BookmarkCodec::kOtherBookmarkFolderNameKey = "other"; |
| 22 const wchar_t* BookmarkCodec::kVersionKey = L"version"; | 22 const char* BookmarkCodec::kVersionKey = "version"; |
| 23 const wchar_t* BookmarkCodec::kChecksumKey = L"checksum"; | 23 const char* BookmarkCodec::kChecksumKey = "checksum"; |
| 24 const wchar_t* BookmarkCodec::kIdKey = L"id"; | 24 const char* BookmarkCodec::kIdKey = "id"; |
| 25 const wchar_t* BookmarkCodec::kTypeKey = L"type"; | 25 const char* BookmarkCodec::kTypeKey = "type"; |
| 26 const wchar_t* BookmarkCodec::kNameKey = L"name"; | 26 const char* BookmarkCodec::kNameKey = "name"; |
| 27 const wchar_t* BookmarkCodec::kDateAddedKey = L"date_added"; | 27 const char* BookmarkCodec::kDateAddedKey = "date_added"; |
| 28 const wchar_t* BookmarkCodec::kURLKey = L"url"; | 28 const char* BookmarkCodec::kURLKey = "url"; |
| 29 const wchar_t* BookmarkCodec::kDateModifiedKey = L"date_modified"; | 29 const char* BookmarkCodec::kDateModifiedKey = "date_modified"; |
| 30 const wchar_t* BookmarkCodec::kChildrenKey = L"children"; | 30 const char* BookmarkCodec::kChildrenKey = "children"; |
| 31 const char* BookmarkCodec::kTypeURL = "url"; | 31 const char* BookmarkCodec::kTypeURL = "url"; |
| 32 const char* BookmarkCodec::kTypeFolder = "folder"; | 32 const char* BookmarkCodec::kTypeFolder = "folder"; |
| 33 | 33 |
| 34 // Current version of the file. | 34 // Current version of the file. |
| 35 static const int kCurrentVersion = 1; | 35 static const int kCurrentVersion = 1; |
| 36 | 36 |
| 37 BookmarkCodec::BookmarkCodec() | 37 BookmarkCodec::BookmarkCodec() |
| 38 : ids_reassigned_(false), | 38 : ids_reassigned_(false), |
| 39 ids_valid_(true), | 39 ids_valid_(true), |
| 40 maximum_id_(0) { | 40 maximum_id_(0) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 ids_.count(id) != 0) { | 197 ids_.count(id) != 0) { |
| 198 ids_valid_ = false; | 198 ids_valid_ = false; |
| 199 } else { | 199 } else { |
| 200 ids_.insert(id); | 200 ids_.insert(id); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 maximum_id_ = std::max(maximum_id_, id); | 204 maximum_id_ = std::max(maximum_id_, id); |
| 205 | 205 |
| 206 string16 title; | 206 string16 title; |
| 207 value.GetStringAsUTF16(kNameKey, &title); | 207 value.GetString(kNameKey, &title); |
| 208 | 208 |
| 209 std::string date_added_string; | 209 std::string date_added_string; |
| 210 if (!value.GetString(kDateAddedKey, &date_added_string)) | 210 if (!value.GetString(kDateAddedKey, &date_added_string)) |
| 211 date_added_string = base::Int64ToString(Time::Now().ToInternalValue()); | 211 date_added_string = base::Int64ToString(Time::Now().ToInternalValue()); |
| 212 int64 internal_time; | 212 int64 internal_time; |
| 213 base::StringToInt64(date_added_string, &internal_time); | 213 base::StringToInt64(date_added_string, &internal_time); |
| 214 base::Time date_added = base::Time::FromInternalValue(internal_time); | 214 base::Time date_added = base::Time::FromInternalValue(internal_time); |
| 215 #if !defined(OS_WIN) | 215 #if !defined(OS_WIN) |
| 216 // We changed the epoch for dates on Mac & Linux from 1970 to the Windows | 216 // We changed the epoch for dates on Mac & Linux from 1970 to the Windows |
| 217 // one of 1601. We assume any number we encounter from before 1970 is using | 217 // one of 1601. We assume any number we encounter from before 1970 is using |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 328 |
| 329 void BookmarkCodec::InitializeChecksum() { | 329 void BookmarkCodec::InitializeChecksum() { |
| 330 MD5Init(&md5_context_); | 330 MD5Init(&md5_context_); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void BookmarkCodec::FinalizeChecksum() { | 333 void BookmarkCodec::FinalizeChecksum() { |
| 334 MD5Digest digest; | 334 MD5Digest digest; |
| 335 MD5Final(&digest, &md5_context_); | 335 MD5Final(&digest, &md5_context_); |
| 336 computed_checksum_ = MD5DigestToBase16(digest); | 336 computed_checksum_ = MD5DigestToBase16(digest); |
| 337 } | 337 } |
| OLD | NEW |