summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorerikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 15:49:37 +0000
committererikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 15:49:37 +0000
commitea7c4fb4adfef2d9d0d5ebc394b8428b8804dd9f (patch)
tree4e82bb4eb089b5ff8fc05b21ce4710ac192c4cc4 /chrome/browser
parent6a644bd074bd8c035a8b40e8e66c75122e16e66d (diff)
downloadchromium_src-ea7c4fb4adfef2d9d0d5ebc394b8428b8804dd9f.zip
chromium_src-ea7c4fb4adfef2d9d0d5ebc394b8428b8804dd9f.tar.gz
chromium_src-ea7c4fb4adfef2d9d0d5ebc394b8428b8804dd9f.tar.bz2
more bookmark tests, plus fix a couple of API bugs
BUG=19099,17288 TEST=browser_tests.exe --gtest_filter=ExtensionApiTest.Bookmarks Review URL: http://codereview.chromium.org/183020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25036 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/extension_bookmarks_module.cc32
-rw-r--r--chrome/browser/extensions/extension_bookmarks_module.h2
-rw-r--r--chrome/browser/extensions/extension_bookmarks_module_constants.cc2
-rw-r--r--chrome/browser/extensions/extension_bookmarks_module_constants.h2
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc4
5 files changed, 26 insertions, 16 deletions
diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc
index 1edef1c..910684f 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;
}
diff --git a/chrome/browser/extensions/extension_bookmarks_module.h b/chrome/browser/extensions/extension_bookmarks_module.h
index c9301eb..cb2cd6c 100644
--- a/chrome/browser/extensions/extension_bookmarks_module.h
+++ b/chrome/browser/extensions/extension_bookmarks_module.h
@@ -108,7 +108,7 @@ class MoveBookmarkFunction : public BookmarksFunction {
virtual bool RunImpl();
};
-class SetBookmarkTitleFunction : public BookmarksFunction {
+class UpdateBookmarkFunction : public BookmarksFunction {
virtual bool RunImpl();
};
diff --git a/chrome/browser/extensions/extension_bookmarks_module_constants.cc b/chrome/browser/extensions/extension_bookmarks_module_constants.cc
index ef4e3f4..769fe09 100644
--- a/chrome/browser/extensions/extension_bookmarks_module_constants.cc
+++ b/chrome/browser/extensions/extension_bookmarks_module_constants.cc
@@ -42,6 +42,6 @@ const char kRemoveBookmarkFunction[] = "bookmarks.remove";
const char kRemoveBookmarkTreeFunction[] = "bookmarks.removeTree";
const char kCreateBookmarkFunction[] = "bookmarks.create";
const char kMoveBookmarkFunction[] = "bookmarks.move";
-const char kSetBookmarkTitleFunction[] = "bookmarks.update";
+const char kUpdateBookmarkFunction[] = "bookmarks.update";
} // namespace extension_bookmarks_module_constants
diff --git a/chrome/browser/extensions/extension_bookmarks_module_constants.h b/chrome/browser/extensions/extension_bookmarks_module_constants.h
index 5f49b44..12d677d 100644
--- a/chrome/browser/extensions/extension_bookmarks_module_constants.h
+++ b/chrome/browser/extensions/extension_bookmarks_module_constants.h
@@ -48,7 +48,7 @@ extern const char kRemoveBookmarkFunction[];
extern const char kRemoveBookmarkTreeFunction[];
extern const char kCreateBookmarkFunction[];
extern const char kMoveBookmarkFunction[];
-extern const char kSetBookmarkTitleFunction[];
+extern const char kUpdateBookmarkFunction[];
}; // namespace extension_bookmarks_module_constants
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index fbd329e..d0281c3 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -133,8 +133,8 @@ void FactoryRegistry::ResetFunctions() {
&NewExtensionFunction<CreateBookmarkFunction>;
factories_[bookmarks::kMoveBookmarkFunction] =
&NewExtensionFunction<MoveBookmarkFunction>;
- factories_[bookmarks::kSetBookmarkTitleFunction] =
- &NewExtensionFunction<SetBookmarkTitleFunction>;
+ factories_[bookmarks::kUpdateBookmarkFunction] =
+ &NewExtensionFunction<UpdateBookmarkFunction>;
// Toolstrips.
factories_[toolstrip::kExpandFunction] =