diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-29 21:32:12 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-29 21:32:12 +0000 |
commit | 15bc709d5af8b4d1d31d7297d21c5d95396f01c4 (patch) | |
tree | 4cf3be3de15af83c28d3ab0626faf0a67a90e140 /chrome/browser/extensions | |
parent | d4db95b2c1e239700c5557197ecce1e36c735d4a (diff) | |
download | chromium_src-15bc709d5af8b4d1d31d7297d21c5d95396f01c4.zip chromium_src-15bc709d5af8b4d1d31d7297d21c5d95396f01c4.tar.gz chromium_src-15bc709d5af8b4d1d31d7297d21c5d95396f01c4.tar.bz2 |
a few minor tweaks the bookmarks API:
* change name "childrenIds" to "children"
* add dateAdded and dateGroupModified properties
* add id to onRemoved
BUG=13994
BUG=14581
BUG=12217
TEST=load sample bookmarks extension and play around with Dump Bookmarks
Review URL: http://codereview.chromium.org/151032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19536 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
4 files changed, 35 insertions, 11 deletions
diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc index f25bd40..a538d3b 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.cc +++ b/chrome/browser/extensions/extension_bookmarks_module.cc @@ -31,10 +31,23 @@ class ExtensionBookmarks { if (parent) dict->SetInteger(keys::kParentIdKey, parent->id()); - if (!node->is_folder()) + if (!node->is_folder()) { dict->SetString(keys::kUrlKey, node->GetURL().spec()); + } else { + // Javascript Date wants milliseconds since the epoch, ToDoubleT is + // seconds. + base::Time t = node->date_group_modified(); + if (!t.is_null()) + dict->SetReal(keys::kDateGroupModifiedKey, floor(t.ToDoubleT() * 1000)); + } dict->SetString(keys::kTitleKey, node->GetTitle()); + if (!node->date_added().is_null()) { + // Javascript Date wants milliseconds since the epoch, ToDoubleT is + // seconds. + dict->SetReal(keys::kDateAddedKey, + floor(node->date_added().ToDoubleT() * 1000)); + } int childCount = node->GetChildCount(); ListValue* children = new ListValue(); @@ -168,12 +181,11 @@ void ExtensionBookmarkEventRouter::BookmarkNodeAdded(BookmarkModel* model, ListValue args; const BookmarkNode* node = parent->GetChild(index); args.Append(new FundamentalValue(node->id())); - DictionaryValue* object_args = new DictionaryValue(); - object_args->SetString(keys::kTitleKey, node->GetTitle()); - object_args->SetString(keys::kUrlKey, node->GetURL().spec()); - object_args->SetInteger(keys::kParentIdKey, parent->id()); - object_args->SetInteger(keys::kIndexKey, index); - args.Append(object_args); + DictionaryValue* obj = ExtensionBookmarks::GetNodeDictionary(node, false); + + // Remove id since it's already being passed as the first argument. + obj->Remove(keys::kIdKey, NULL); + args.Append(obj); std::string json_args; JSONWriter::Write(&args, false, &json_args); @@ -184,7 +196,17 @@ void ExtensionBookmarkEventRouter::BookmarkNodeRemoved( BookmarkModel* model, const BookmarkNode* parent, int index) { + // TODO(erikkay) can this version ever be called? + NOTREACHED(); +} + +void ExtensionBookmarkEventRouter::BookmarkNodeRemoved( + BookmarkModel* model, + const BookmarkNode* parent, + int index, + const BookmarkNode* node) { ListValue args; + args.Append(new FundamentalValue(node->id())); DictionaryValue* object_args = new DictionaryValue(); object_args->SetInteger(keys::kParentIdKey, parent->id()); object_args->SetInteger(keys::kIndexKey, index); diff --git a/chrome/browser/extensions/extension_bookmarks_module.h b/chrome/browser/extensions/extension_bookmarks_module.h index 426e145..cfa32de 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.h +++ b/chrome/browser/extensions/extension_bookmarks_module.h @@ -40,9 +40,7 @@ class ExtensionBookmarkEventRouter : public BookmarkModelObserver { virtual void BookmarkNodeRemoved(BookmarkModel* model, const BookmarkNode* parent, int old_index, - const BookmarkNode* node) { - BookmarkNodeRemoved(model, parent, old_index); - } + const BookmarkNode* node); virtual void BookmarkNodeChanged(BookmarkModel* model, const BookmarkNode* node); virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model, diff --git a/chrome/browser/extensions/extension_bookmarks_module_constants.cc b/chrome/browser/extensions/extension_bookmarks_module_constants.cc index 96b8623..cdf602d 100755 --- a/chrome/browser/extensions/extension_bookmarks_module_constants.cc +++ b/chrome/browser/extensions/extension_bookmarks_module_constants.cc @@ -13,8 +13,10 @@ const wchar_t kOldIndexKey[] = L"oldIndex"; const wchar_t kOldParentIdKey[] = L"oldParentId"; const wchar_t kUrlKey[] = L"url"; const wchar_t kTitleKey[] = L"title"; -const wchar_t kChildrenKey[] = L"childrenIds"; +const wchar_t kChildrenKey[] = L"children"; const wchar_t kRecursiveKey[] = L"recursive"; +const wchar_t kDateAddedKey[] = L"dateAdded"; +const wchar_t kDateGroupModifiedKey[] = L"dateGroupModified"; const char kNoNodeError[] = "Can't find bookmark for id."; const char kNoParentError[] = "Can't find parent bookmark for id."; diff --git a/chrome/browser/extensions/extension_bookmarks_module_constants.h b/chrome/browser/extensions/extension_bookmarks_module_constants.h index 4287359..3b504e6 100755 --- a/chrome/browser/extensions/extension_bookmarks_module_constants.h +++ b/chrome/browser/extensions/extension_bookmarks_module_constants.h @@ -19,6 +19,8 @@ extern const wchar_t kUrlKey[]; extern const wchar_t kTitleKey[]; extern const wchar_t kChildrenKey[]; extern const wchar_t kRecursiveKey[]; +extern const wchar_t kDateAddedKey[]; +extern const wchar_t kDateGroupModifiedKey[]; // Errors. extern const char kNoNodeError[]; |