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 "chrome/browser/bookmarks/bookmark_extension_api.h" | 5 #include "chrome/browser/bookmarks/bookmark_extension_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
13 #include "base/sha1.h" | 14 #include "base/sha1.h" |
14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
15 #include "base/string16.h" | 16 #include "base/string16.h" |
16 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
18 #include "base/time.h" | 19 #include "base/time.h" |
19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/bookmarks/bookmark_codec.h" | 21 #include "chrome/browser/bookmarks/bookmark_codec.h" |
21 #include "chrome/browser/bookmarks/bookmark_extension_api_constants.h" | 22 #include "chrome/browser/bookmarks/bookmark_extension_api_constants.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 base::JSONWriter::Write(&args, &json_args); | 190 base::JSONWriter::Write(&args, &json_args); |
190 DispatchEvent(model->profile(), keys::kOnBookmarkMoved, json_args); | 191 DispatchEvent(model->profile(), keys::kOnBookmarkMoved, json_args); |
191 } | 192 } |
192 | 193 |
193 void BookmarkExtensionEventRouter::BookmarkNodeAdded(BookmarkModel* model, | 194 void BookmarkExtensionEventRouter::BookmarkNodeAdded(BookmarkModel* model, |
194 const BookmarkNode* parent, | 195 const BookmarkNode* parent, |
195 int index) { | 196 int index) { |
196 ListValue args; | 197 ListValue args; |
197 const BookmarkNode* node = parent->GetChild(index); | 198 const BookmarkNode* node = parent->GetChild(index); |
198 args.Append(new StringValue(base::Int64ToString(node->id()))); | 199 args.Append(new StringValue(base::Int64ToString(node->id()))); |
199 BookmarkTreeNode* tree_node = | 200 scoped_ptr<BookmarkTreeNode> tree_node( |
200 bookmark_extension_helpers::GetBookmarkTreeNode(node, false, false); | 201 bookmark_extension_helpers::GetBookmarkTreeNode(node, false, false)); |
201 args.Append(tree_node->ToValue().release()); | 202 args.Append(tree_node->ToValue().release()); |
202 | 203 |
203 std::string json_args; | 204 std::string json_args; |
204 base::JSONWriter::Write(&args, &json_args); | 205 base::JSONWriter::Write(&args, &json_args); |
205 DispatchEvent(model->profile(), keys::kOnBookmarkCreated, json_args); | 206 DispatchEvent(model->profile(), keys::kOnBookmarkCreated, json_args); |
206 } | 207 } |
207 | 208 |
208 void BookmarkExtensionEventRouter::BookmarkNodeRemoved( | 209 void BookmarkExtensionEventRouter::BookmarkNodeRemoved( |
209 BookmarkModel* model, | 210 BookmarkModel* model, |
210 const BookmarkNode* parent, | 211 const BookmarkNode* parent, |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 int index, | 960 int index, |
960 void* params) { | 961 void* params) { |
961 #if !defined(OS_ANDROID) | 962 #if !defined(OS_ANDROID) |
962 // Android does not have support for the standard exporter. | 963 // Android does not have support for the standard exporter. |
963 // TODO(jgreenwald): remove ifdef once extensions are no longer built on | 964 // TODO(jgreenwald): remove ifdef once extensions are no longer built on |
964 // Android. | 965 // Android. |
965 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); | 966 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); |
966 #endif | 967 #endif |
967 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 968 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
968 } | 969 } |
OLD | NEW |