diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 02:14:56 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 02:14:56 +0000 |
commit | 76a3db852fb58323d63b6857493191e00e97422a (patch) | |
tree | a9af5546c680a37ec89c1aaec0733f1026a24711 /chrome/browser/extensions/extension_bookmarks_module.cc | |
parent | d267ac762bb0764857fedb92a516a9aa290b0dd2 (diff) | |
download | chromium_src-76a3db852fb58323d63b6857493191e00e97422a.zip chromium_src-76a3db852fb58323d63b6857493191e00e97422a.tar.gz chromium_src-76a3db852fb58323d63b6857493191e00e97422a.tar.bz2 |
Push bookmarks.remove/removeAll polymorphism into c++. fix bookmarks id schema issues (http://code.google.com/p/chromium/issues/detail?id=17562 failed to update schema types from int to string).
R=erikkay
BUG=17417
Review URL: http://codereview.chromium.org/160064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21503 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_bookmarks_module.cc')
-rw-r--r-- | chrome/browser/extensions/extension_bookmarks_module.cc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc index 2d7cbb3..f0acba9 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.cc +++ b/chrome/browser/extensions/extension_bookmarks_module.cc @@ -358,19 +358,21 @@ bool SearchBookmarksFunction::RunImpl() { } bool RemoveBookmarkFunction::RunImpl() { - EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST)); - const ListValue* args = static_cast<const ListValue*>(args_); bool recursive = false; - EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(1, &recursive)); + if (name() == + extension_bookmarks_module_constants::kRemoveBookmarkTreeFunction) + recursive = true; BookmarkModel* model = profile()->GetBookmarkModel(); int64 id; std::string id_string; - if (args->GetString(0, &id_string) && StringToInt64(id_string, &id)) { + if (args_->IsType(Value::TYPE_STRING) && + args_->GetAsString(&id_string) && + StringToInt64(id_string, &id)) { return ExtensionBookmarks::RemoveNode(model, id, recursive, &error_); } else { - ListValue* ids; - EXTENSION_FUNCTION_VALIDATE(args->GetList(0, &ids)); + EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST)); + ListValue* ids = static_cast<ListValue*>(args_); size_t count = ids->GetSize(); EXTENSION_FUNCTION_VALIDATE(count > 0); for (size_t i = 0; i < count; ++i) { @@ -477,9 +479,13 @@ bool MoveBookmarkFunction::RunImpl() { // Optional, defaults to current parent. parent = node->GetParent(); } else { - int parentId; - EXTENSION_FUNCTION_VALIDATE(destination->GetInteger(keys::kParentIdKey, - &parentId)); + std::string parentId_string; + EXTENSION_FUNCTION_VALIDATE(destination->GetString(keys::kParentIdKey, + &parentId_string)); + int64 parentId; + if (!GetBookmarkIdAsInt64(parentId_string, &parentId)) + return false; + parent = model->GetNodeByID(parentId); } if (!parent) { |