| 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_manager_api.h" | 5 #include "chrome/browser/extensions/extension_bookmark_manager_api.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_drag_data.h" | 13 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_utils.h" | 15 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 16 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 16 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 17 #include "chrome/browser/extensions/extension_bookmark_helpers.h" | 17 #include "chrome/browser/extensions/extension_bookmark_helpers.h" |
| 18 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" | 18 #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" |
| 19 #include "chrome/browser/extensions/extension_dom_ui.h" | 19 #include "chrome/browser/extensions/extension_dom_ui.h" |
| 20 #include "chrome/browser/extensions/extension_message_service.h" | 20 #include "chrome/browser/extensions/extension_message_service.h" |
| 21 #include "chrome/browser/profile.h" | 21 #include "chrome/browser/profile.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Recursively adds a node to a list. This is by used |BookmarkDragDataToJSON| | 72 // Recursively adds a node to a list. This is by used |BookmarkDragDataToJSON| |
| 73 // when the data comes from the current profile. In this case we have a | 73 // when the data comes from the current profile. In this case we have a |
| 74 // BookmarkNode since we got the data from the current profile. | 74 // BookmarkNode since we got the data from the current profile. |
| 75 void AddNodeToList(ListValue* list, const BookmarkNode& node) { | 75 void AddNodeToList(ListValue* list, const BookmarkNode& node) { |
| 76 DictionaryValue* dict = new DictionaryValue(); | 76 DictionaryValue* dict = new DictionaryValue(); |
| 77 | 77 |
| 78 // Add id and parentId so we can associate the data with existing nodes on the | 78 // Add id and parentId so we can associate the data with existing nodes on the |
| 79 // client side. | 79 // client side. |
| 80 std::string id_string = Int64ToString(node.id()); | 80 std::string id_string = base::Int64ToString(node.id()); |
| 81 dict->SetString(keys::kIdKey, id_string); | 81 dict->SetString(keys::kIdKey, id_string); |
| 82 | 82 |
| 83 std::string parent_id_string = Int64ToString(node.GetParent()->id()); | 83 std::string parent_id_string = base::Int64ToString(node.GetParent()->id()); |
| 84 dict->SetString(keys::kParentIdKey, parent_id_string); | 84 dict->SetString(keys::kParentIdKey, parent_id_string); |
| 85 | 85 |
| 86 if (node.is_url()) | 86 if (node.is_url()) |
| 87 dict->SetString(keys::kUrlKey, node.GetURL().spec()); | 87 dict->SetString(keys::kUrlKey, node.GetURL().spec()); |
| 88 | 88 |
| 89 dict->SetString(keys::kTitleKey, node.GetTitle()); | 89 dict->SetString(keys::kTitleKey, node.GetTitle()); |
| 90 | 90 |
| 91 ListValue* children = new ListValue(); | 91 ListValue* children = new ListValue(); |
| 92 for (int i = 0; i < node.GetChildCount(); ++i) | 92 for (int i = 0; i < node.GetChildCount(); ++i) |
| 93 AddNodeToList(children, *node.GetChild(i)); | 93 AddNodeToList(children, *node.GetChild(i)); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 if (folders_only) { | 431 if (folders_only) { |
| 432 extension_bookmark_helpers::AddNodeFoldersOnly(node, | 432 extension_bookmark_helpers::AddNodeFoldersOnly(node, |
| 433 json.get(), | 433 json.get(), |
| 434 true); | 434 true); |
| 435 } else { | 435 } else { |
| 436 extension_bookmark_helpers::AddNode(node, json.get(), true); | 436 extension_bookmark_helpers::AddNode(node, json.get(), true); |
| 437 } | 437 } |
| 438 result_.reset(json.release()); | 438 result_.reset(json.release()); |
| 439 return true; | 439 return true; |
| 440 } | 440 } |
| OLD | NEW |