OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bookmarks/bookmark_extension_helpers.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_extension_api_constants.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" | |
11 | 11 |
12 namespace keys = extension_bookmarks_module_constants; | 12 namespace keys = bookmark_extension_api_constants; |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 void AddNode(const BookmarkNode* node, | 16 void AddNode(const BookmarkNode* node, |
17 base::ListValue* list, | 17 base::ListValue* list, |
18 bool recurse, | 18 bool recurse, |
19 bool only_folders) { | 19 bool only_folders) { |
20 if (node->IsVisible()) { | 20 if (node->IsVisible()) { |
21 base::DictionaryValue* dict = extension_bookmark_helpers::GetNodeDictionary( | 21 base::DictionaryValue* dict = bookmark_extension_helpers::GetNodeDictionary( |
22 node, recurse, only_folders); | 22 node, recurse, only_folders); |
23 list->Append(dict); | 23 list->Append(dict); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 namespace extension_bookmark_helpers { | 29 namespace bookmark_extension_helpers { |
30 | 30 |
31 base::DictionaryValue* GetNodeDictionary(const BookmarkNode* node, | 31 base::DictionaryValue* GetNodeDictionary(const BookmarkNode* node, |
32 bool recurse, | 32 bool recurse, |
33 bool only_folders) { | 33 bool only_folders) { |
34 base::DictionaryValue* dict = new base::DictionaryValue; | 34 base::DictionaryValue* dict = new base::DictionaryValue; |
35 dict->SetString(keys::kIdKey, base::Int64ToString(node->id())); | 35 dict->SetString(keys::kIdKey, base::Int64ToString(node->id())); |
36 | 36 |
37 const BookmarkNode* parent = node->parent(); | 37 const BookmarkNode* parent = node->parent(); |
38 if (parent) { | 38 if (parent) { |
39 dict->SetString(keys::kParentIdKey, base::Int64ToString(parent->id())); | 39 dict->SetString(keys::kParentIdKey, base::Int64ToString(parent->id())); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 if (node->is_folder() && !node->empty() && !recursive) { | 97 if (node->is_folder() && !node->empty() && !recursive) { |
98 *error = keys::kFolderNotEmptyError; | 98 *error = keys::kFolderNotEmptyError; |
99 return false; | 99 return false; |
100 } | 100 } |
101 | 101 |
102 const BookmarkNode* parent = node->parent(); | 102 const BookmarkNode* parent = node->parent(); |
103 model->Remove(parent, parent->GetIndexOf(node)); | 103 model->Remove(parent, parent->GetIndexOf(node)); |
104 return true; | 104 return true; |
105 } | 105 } |
106 | 106 |
107 } // namespace extension_bookmark_helpers | 107 } // namespace bookmark_extension_helpers |
OLD | NEW |