OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |