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

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

Issue 591006: Make it so that chrome.bookmarks.update can update the URL of a bookmark.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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
« no previous file with comments | « no previous file | chrome/common/extensions/api/extension_api.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_bookmarks_module.cc
===================================================================
--- chrome/browser/extensions/extension_bookmarks_module.cc (revision 38359)
+++ chrome/browser/extensions/extension_bookmarks_module.cc (working copy)
@@ -238,13 +238,15 @@
ListValue args;
args.Append(new StringValue(Int64ToString(node->id())));
- // TODO(erikkay) The only two things that BookmarkModel sends this
- // notification for are title and favicon. Since we're currently ignoring
- // favicon and since the notification doesn't say which one anyway, for now
- // we only include title. The ideal thing would be to change BookmarkModel
- // to indicate what changed.
+ // TODO(erikkay) The only three things that BookmarkModel sends this
+ // notification for are title, url and favicon. Since we're currently
+ // ignoring favicon and since the notification doesn't say which one anyway,
+ // for now we only include title and url. The ideal thing would be to change
+ // BookmarkModel to indicate what changed.
DictionaryValue* object_args = new DictionaryValue();
object_args->SetString(keys::kTitleKey, node->GetTitle());
+ if (node->is_url())
+ object_args->SetString(keys::kUrlKey, node->GetURL().spec());
args.Append(object_args);
std::string json_args;
@@ -639,9 +641,23 @@
const ListValue* args = args_as_list();
DictionaryValue* updates;
EXTENSION_FUNCTION_VALIDATE(args->GetDictionary(1, &updates));
+
std::wstring title;
- updates->GetString(keys::kTitleKey, &title); // Optional (empty is clear).
+ std::string url_string;
+ // Optional but we need to distinguish non present from an empty title.
+ const bool has_title = updates->GetString(keys::kTitleKey, &title);
+ updates->GetString(keys::kUrlKey, &url_string); // Optional.
+
+ GURL url;
+ if (!url_string.empty()) {
+ url = GURL(url_string);
+
+ // If URL is present then it needs to be a non empty valid URL.
+ EXTENSION_FUNCTION_VALIDATE(!url.is_empty());
+ EXTENSION_FUNCTION_VALIDATE(url.is_valid());
+ }
+
BookmarkModel* model = profile()->GetBookmarkModel();
const BookmarkNode* node = model->GetNodeByID(ids.front());
if (!node) {
@@ -654,7 +670,10 @@
error_ = keys::kModifySpecialError;
return false;
}
- model->SetTitle(node, title);
+ if (has_title)
+ model->SetTitle(node, title);
+ if (!url.is_empty())
+ model->SetURL(node, url);
DictionaryValue* ret = ExtensionBookmarks::GetNodeDictionary(node, false);
result_.reset(ret);
« no previous file with comments | « no previous file | chrome/common/extensions/api/extension_api.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698