OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_bookmarks_module.h" | 5 #include "chrome/browser/extensions/extension_bookmarks_module.h" |
6 | 6 |
7 #include "base/json_writer.h" | 7 #include "base/json_writer.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/bookmarks/bookmark_codec.h" | 9 #include "chrome/browser/bookmarks/bookmark_codec.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 DispatchEvent(model->profile(), keys::kOnBookmarkMoved, json_args); | 190 DispatchEvent(model->profile(), keys::kOnBookmarkMoved, json_args); |
191 } | 191 } |
192 | 192 |
193 void ExtensionBookmarkEventRouter::BookmarkNodeAdded(BookmarkModel* model, | 193 void ExtensionBookmarkEventRouter::BookmarkNodeAdded(BookmarkModel* model, |
194 const BookmarkNode* parent, | 194 const BookmarkNode* parent, |
195 int index) { | 195 int index) { |
196 ListValue args; | 196 ListValue args; |
197 const BookmarkNode* node = parent->GetChild(index); | 197 const BookmarkNode* node = parent->GetChild(index); |
198 args.Append(new StringValue(Int64ToString(node->id()))); | 198 args.Append(new StringValue(Int64ToString(node->id()))); |
199 DictionaryValue* obj = ExtensionBookmarks::GetNodeDictionary(node, false); | 199 DictionaryValue* obj = ExtensionBookmarks::GetNodeDictionary(node, false); |
200 | |
201 // Remove id since it's already being passed as the first argument. | |
202 obj->Remove(keys::kIdKey, NULL); | |
203 args.Append(obj); | 200 args.Append(obj); |
204 | 201 |
205 std::string json_args; | 202 std::string json_args; |
206 JSONWriter::Write(&args, false, &json_args); | 203 JSONWriter::Write(&args, false, &json_args); |
207 DispatchEvent(model->profile(), keys::kOnBookmarkCreated, json_args); | 204 DispatchEvent(model->profile(), keys::kOnBookmarkCreated, json_args); |
208 } | 205 } |
209 | 206 |
210 void ExtensionBookmarkEventRouter::BookmarkNodeRemoved( | 207 void ExtensionBookmarkEventRouter::BookmarkNodeRemoved( |
211 BookmarkModel* model, | 208 BookmarkModel* model, |
212 const BookmarkNode* parent, | 209 const BookmarkNode* parent, |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 error_ = keys::kModifySpecialError; | 545 error_ = keys::kModifySpecialError; |
549 return false; | 546 return false; |
550 } | 547 } |
551 model->SetTitle(node, title); | 548 model->SetTitle(node, title); |
552 | 549 |
553 DictionaryValue* ret = ExtensionBookmarks::GetNodeDictionary(node, false); | 550 DictionaryValue* ret = ExtensionBookmarks::GetNodeDictionary(node, false); |
554 result_.reset(ret); | 551 result_.reset(ret); |
555 | 552 |
556 return true; | 553 return true; |
557 } | 554 } |
OLD | NEW |