Commit f6506c31 authored by rfevang's avatar rfevang Committed by Commit bot

Protect against setting meta info on unmodifiable nodes.

BUG=418226

Review URL: https://codereview.chromium.org/606923002

Cr-Commit-Position: refs/heads/master@{#297068}
parent 1bf56544
......@@ -721,7 +721,15 @@ bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() {
if (!node)
return false;
if (!CanBeModified(node))
return false;
BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
if (model->is_permanent_node(node)) {
error_ = bookmark_keys::kModifySpecialError;
return false;
}
model->SetNodeMetaInfo(node, params->key, params->value);
return true;
}
......@@ -735,7 +743,15 @@ bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunOnReady() {
if (!node)
return false;
if (!CanBeModified(node))
return false;
BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
if (model->is_permanent_node(node)) {
error_ = bookmark_keys::kModifySpecialError;
return false;
}
BookmarkNode::MetaInfoMap new_meta_info(
params->meta_info_changes.additional_properties);
if (node->GetMetaInfoMap()) {
......
......@@ -341,6 +341,26 @@ var tests = [
}));
},
function setMetaInfoPermanent() {
bookmarks.getTree(pass(function(nodes) {
var unmodifiableFolder = nodes[0].children[0];
bookmarkManager.setMetaInfo(unmodifiableFolder.id, 'meta', 'foo', fail(
"Can't modify the root bookmark folders."));
bookmarkManager.updateMetaInfo(unmodifiableFolder.id, {a: 'a', b: 'b'},
fail("Can't modify the root bookmark folders."));
}));
},
function setMetaInfoManaged() {
bookmarks.getChildren('4', pass(function(result) {
assertTrue(result.length > 0);
bookmarkManager.setMetaInfo(result[0].id, 'meta', 'foo', fail(
"Can't modify managed bookmarks."));
bookmarkManager.updateMetaInfo(result[0].id, {a: 'a', b: 'b'},
fail("Can't modify managed bookmarks."));
}));
},
function updateMetaInfo() {
bookmarkManager.getMetaInfo(nodeB.id, pass(function(result){
assertEq({}, result);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment