Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: chrome/browser/extensions/extension_bookmarks_module.cc

Issue 160064: Push bookmarks.remove/removeAll polymorphism into c++. fix bookmarks id schema issues (Closed)
Patch Set: presubmit Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_bookmarks_module.cc
diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc
index 2d7cbb3a431c03a5d277b2152f35f9cee21ad6c0..f0acba9717f4b324e1b15c8defcfcef0d08b7b2e 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) {
« no previous file with comments | « chrome/browser/automation/automation_extension_function.cc ('k') | chrome/browser/extensions/extension_function.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698