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

Side by Side Diff: chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc

Issue 606923002: Protect against setting meta info on unmodifiable nodes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Extra test Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/bookmark_manager/standard/test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api.h" 5 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 714 }
715 715
716 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { 716 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() {
717 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); 717 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_));
718 EXTENSION_FUNCTION_VALIDATE(params); 718 EXTENSION_FUNCTION_VALIDATE(params);
719 719
720 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); 720 const BookmarkNode* node = GetBookmarkNodeFromId(params->id);
721 if (!node) 721 if (!node)
722 return false; 722 return false;
723 723
724 if (!CanBeModified(node))
725 return false;
726
724 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 727 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
728 if (model->is_permanent_node(node)) {
729 error_ = bookmark_keys::kModifySpecialError;
730 return false;
731 }
732
725 model->SetNodeMetaInfo(node, params->key, params->value); 733 model->SetNodeMetaInfo(node, params->key, params->value);
726 return true; 734 return true;
727 } 735 }
728 736
729 bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunOnReady() { 737 bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunOnReady() {
730 scoped_ptr<UpdateMetaInfo::Params> params( 738 scoped_ptr<UpdateMetaInfo::Params> params(
731 UpdateMetaInfo::Params::Create(*args_)); 739 UpdateMetaInfo::Params::Create(*args_));
732 EXTENSION_FUNCTION_VALIDATE(params); 740 EXTENSION_FUNCTION_VALIDATE(params);
733 741
734 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); 742 const BookmarkNode* node = GetBookmarkNodeFromId(params->id);
735 if (!node) 743 if (!node)
736 return false; 744 return false;
737 745
746 if (!CanBeModified(node))
747 return false;
748
738 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); 749 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
750 if (model->is_permanent_node(node)) {
751 error_ = bookmark_keys::kModifySpecialError;
752 return false;
753 }
754
739 BookmarkNode::MetaInfoMap new_meta_info( 755 BookmarkNode::MetaInfoMap new_meta_info(
740 params->meta_info_changes.additional_properties); 756 params->meta_info_changes.additional_properties);
741 if (node->GetMetaInfoMap()) { 757 if (node->GetMetaInfoMap()) {
742 new_meta_info.insert(node->GetMetaInfoMap()->begin(), 758 new_meta_info.insert(node->GetMetaInfoMap()->begin(),
743 node->GetMetaInfoMap()->end()); 759 node->GetMetaInfoMap()->end());
744 } 760 }
745 model->SetNodeMetaInfoMap(node, new_meta_info); 761 model->SetNodeMetaInfoMap(node, new_meta_info);
746 762
747 return true; 763 return true;
748 } 764 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 817
802 RedoInfo::Results::Result result; 818 RedoInfo::Results::Result result;
803 result.enabled = undo_manager->redo_count() > 0; 819 result.enabled = undo_manager->redo_count() > 0;
804 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); 820 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel());
805 821
806 results_ = RedoInfo::Results::Create(result); 822 results_ = RedoInfo::Results::Create(result);
807 return true; 823 return true;
808 } 824 }
809 825
810 } // namespace extensions 826 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/bookmark_manager/standard/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698