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/extensions/extension_bookmark_helpers.h" | 5 #include "chrome/browser/extensions/extension_bookmark_helpers.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_number_conversions.h" |
8 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" | 8 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" |
9 | 9 |
10 namespace keys = extension_bookmarks_module_constants; | 10 namespace keys = extension_bookmarks_module_constants; |
11 | 11 |
12 // Helper functions. | 12 // Helper functions. |
13 namespace extension_bookmark_helpers { | 13 namespace extension_bookmark_helpers { |
14 | 14 |
15 DictionaryValue* GetNodeDictionary(const BookmarkNode* node, | 15 DictionaryValue* GetNodeDictionary(const BookmarkNode* node, |
16 bool recurse, | 16 bool recurse, |
17 bool only_folders) { | 17 bool only_folders) { |
18 DictionaryValue* dict = new DictionaryValue(); | 18 DictionaryValue* dict = new DictionaryValue(); |
19 dict->SetString(keys::kIdKey, Int64ToString(node->id())); | 19 dict->SetString(keys::kIdKey, base::Int64ToString(node->id())); |
20 | 20 |
21 const BookmarkNode* parent = node->GetParent(); | 21 const BookmarkNode* parent = node->GetParent(); |
22 if (parent) { | 22 if (parent) { |
23 dict->SetString(keys::kParentIdKey, Int64ToString(parent->id())); | 23 dict->SetString(keys::kParentIdKey, base::Int64ToString(parent->id())); |
24 dict->SetInteger(keys::kIndexKey, parent->IndexOfChild(node)); | 24 dict->SetInteger(keys::kIndexKey, parent->IndexOfChild(node)); |
25 } | 25 } |
26 | 26 |
27 if (!node->is_folder()) { | 27 if (!node->is_folder()) { |
28 dict->SetString(keys::kUrlKey, node->GetURL().spec()); | 28 dict->SetString(keys::kUrlKey, node->GetURL().spec()); |
29 } else { | 29 } else { |
30 // Javascript Date wants milliseconds since the epoch, ToDoubleT is | 30 // Javascript Date wants milliseconds since the epoch, ToDoubleT is |
31 // seconds. | 31 // seconds. |
32 base::Time t = node->date_group_modified(); | 32 base::Time t = node->date_group_modified(); |
33 if (!t.is_null()) | 33 if (!t.is_null()) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return false; | 98 return false; |
99 } | 99 } |
100 | 100 |
101 const BookmarkNode* parent = node->GetParent(); | 101 const BookmarkNode* parent = node->GetParent(); |
102 int index = parent->IndexOfChild(node); | 102 int index = parent->IndexOfChild(node); |
103 model->Remove(parent, index); | 103 model->Remove(parent, index); |
104 return true; | 104 return true; |
105 } | 105 } |
106 | 106 |
107 } | 107 } |
OLD | NEW |