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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 GetChromeBookmarkClient(), node, false, false)); | 659 GetChromeBookmarkClient(), node, false, false)); |
660 results_ = CreateWithMetaInfo::Results::Create(*result_node); | 660 results_ = CreateWithMetaInfo::Results::Create(*result_node); |
661 | 661 |
662 return true; | 662 return true; |
663 } | 663 } |
664 | 664 |
665 bool BookmarkManagerPrivateGetMetaInfoFunction::RunOnReady() { | 665 bool BookmarkManagerPrivateGetMetaInfoFunction::RunOnReady() { |
666 scoped_ptr<GetMetaInfo::Params> params(GetMetaInfo::Params::Create(*args_)); | 666 scoped_ptr<GetMetaInfo::Params> params(GetMetaInfo::Params::Create(*args_)); |
667 EXTENSION_FUNCTION_VALIDATE(params); | 667 EXTENSION_FUNCTION_VALIDATE(params); |
668 | 668 |
669 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); | 669 if (params->id) { |
670 if (!node) | 670 const BookmarkNode* node = GetBookmarkNodeFromId(*params->id); |
671 return false; | 671 if (!node) |
| 672 return false; |
672 | 673 |
673 if (params->key) { | 674 if (params->key) { |
674 std::string value; | 675 std::string value; |
675 if (node->GetMetaInfo(*params->key, &value)) { | 676 if (node->GetMetaInfo(*params->key, &value)) { |
| 677 GetMetaInfo::Results::Value result; |
| 678 result.as_string.reset(new std::string(value)); |
| 679 results_ = GetMetaInfo::Results::Create(result); |
| 680 } |
| 681 } else { |
676 GetMetaInfo::Results::Value result; | 682 GetMetaInfo::Results::Value result; |
677 result.as_string.reset(new std::string(value)); | 683 result.as_map_meta_info_fields.reset( |
| 684 new bookmark_manager_private::MapMetaInfoFields); |
| 685 |
| 686 const BookmarkNode::MetaInfoMap* meta_info = node->GetMetaInfoMap(); |
| 687 if (meta_info) { |
| 688 BookmarkNode::MetaInfoMap::const_iterator itr; |
| 689 base::DictionaryValue& value = |
| 690 result.as_map_meta_info_fields->additional_properties; |
| 691 for (itr = meta_info->begin(); itr != meta_info->end(); itr++) { |
| 692 value.SetStringWithoutPathExpansion(itr->first, itr->second); |
| 693 } |
| 694 } |
678 results_ = GetMetaInfo::Results::Create(result); | 695 results_ = GetMetaInfo::Results::Create(result); |
679 } | 696 } |
680 } else { | 697 } else { |
| 698 if (params->key) { |
| 699 return true; |
| 700 } |
| 701 |
| 702 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 703 const BookmarkNode* node = model->root_node(); |
| 704 |
681 GetMetaInfo::Results::Value result; | 705 GetMetaInfo::Results::Value result; |
682 result.as_meta_info_fields.reset( | 706 result.as_map_meta_info_fields.reset( |
683 new bookmark_manager_private::MetaInfoFields); | 707 new bookmark_manager_private::MapMetaInfoFields); |
684 | 708 |
685 const BookmarkNode::MetaInfoMap* meta_info = node->GetMetaInfoMap(); | 709 bookmark_api_helpers::GetMetaInfo(node, |
686 if (meta_info) | 710 &result.as_map_meta_info_fields->additional_properties); |
687 result.as_meta_info_fields->additional_properties = *meta_info; | 711 |
688 results_ = GetMetaInfo::Results::Create(result); | 712 results_ = GetMetaInfo::Results::Create(result); |
689 } | 713 } |
690 | 714 |
691 return true; | 715 return true; |
692 } | 716 } |
693 | 717 |
694 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { | 718 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { |
695 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); | 719 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); |
696 EXTENSION_FUNCTION_VALIDATE(params); | 720 EXTENSION_FUNCTION_VALIDATE(params); |
697 | 721 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 result.enabled = undo_manager->redo_count() > 0; | 816 result.enabled = undo_manager->redo_count() > 0; |
793 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); | 817 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); |
794 | 818 |
795 results_ = RedoInfo::Results::Create(result); | 819 results_ = RedoInfo::Results::Create(result); |
796 #endif // !defined(OS_ANDROID) | 820 #endif // !defined(OS_ANDROID) |
797 | 821 |
798 return true; | 822 return true; |
799 } | 823 } |
800 | 824 |
801 } // namespace extensions | 825 } // namespace extensions |
OLD | NEW |