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

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

Issue 183020: more bookmark tests, plus fix a couple of API bugs (Closed)
Patch Set: cleanup from review comments (plus merge fallout) Created 11 years, 4 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 1edef1c6dfc7dfa4d3a16ed7cbaf5276f113f15e..910684f244dc27882f4b308f3f939199edac3307 100644
--- a/chrome/browser/extensions/extension_bookmarks_module.cc
+++ b/chrome/browser/extensions/extension_bookmarks_module.cc
@@ -60,7 +60,8 @@ class ExtensionBookmarks {
DictionaryValue* dict = GetNodeDictionary(child, true);
children->Append(dict);
}
- dict->Set(keys::kChildrenKey, children);
+ if (node->is_folder())
+ dict->Set(keys::kChildrenKey, children);
}
return dict;
}
@@ -515,22 +516,27 @@ bool MoveBookmarkFunction::RunImpl() {
}
model->Move(node, parent, index);
- return true;
-}
-bool SetBookmarkTitleFunction::RunImpl() {
- EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY));
- DictionaryValue* json = static_cast<DictionaryValue*>(args_);
+ DictionaryValue* ret = ExtensionBookmarks::GetNodeDictionary(node, false);
+ result_.reset(ret);
- std::wstring title;
- json->GetString(keys::kTitleKey, &title); // Optional (empty is clear).
+ return true;
+}
- BookmarkModel* model = profile()->GetBookmarkModel();
- int64 id = 0;
+bool UpdateBookmarkFunction::RunImpl() {
+ EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST));
+ const ListValue* args = static_cast<const ListValue*>(args_);
+ int64 id;
std::string id_string;
- EXTENSION_FUNCTION_VALIDATE(json->GetString(keys::kIdKey, &id_string));
+ EXTENSION_FUNCTION_VALIDATE(args->GetString(0, &id_string));
if (!GetBookmarkIdAsInt64(id_string, &id))
return false;
+ DictionaryValue* updates;
+ EXTENSION_FUNCTION_VALIDATE(args->GetDictionary(1, &updates));
+ std::wstring title;
+ updates->GetString(keys::kTitleKey, &title); // Optional (empty is clear).
+
+ BookmarkModel* model = profile()->GetBookmarkModel();
const BookmarkNode* node = model->GetNodeByID(id);
if (!node) {
error_ = keys::kNoNodeError;
@@ -543,5 +549,9 @@ bool SetBookmarkTitleFunction::RunImpl() {
return false;
}
model->SetTitle(node, title);
+
+ DictionaryValue* ret = ExtensionBookmarks::GetNodeDictionary(node, false);
+ result_.reset(ret);
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698