| 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_object.reset(new GetMetaInfo::Results::Value::Object); |
| 684 |
| 685 const BookmarkNode::MetaInfoMap* meta_info = node->GetMetaInfoMap(); |
| 686 if (meta_info) { |
| 687 BookmarkNode::MetaInfoMap::const_iterator itr; |
| 688 base::DictionaryValue& temp = result.as_object->additional_properties; |
| 689 for (itr = meta_info->begin(); itr != meta_info->end(); itr++) { |
| 690 temp.SetStringWithoutPathExpansion(itr->first, itr->second); |
| 691 } |
| 692 } |
| 678 results_ = GetMetaInfo::Results::Create(result); | 693 results_ = GetMetaInfo::Results::Create(result); |
| 679 } | 694 } |
| 680 } else { | 695 } else { |
| 696 if (params->key) { |
| 697 error_ = bookmark_api_constants::kInvalidParamError; |
| 698 return true; |
| 699 } |
| 700 |
| 701 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 702 const BookmarkNode* node = model->root_node(); |
| 703 |
| 681 GetMetaInfo::Results::Value result; | 704 GetMetaInfo::Results::Value result; |
| 682 result.as_meta_info_fields.reset( | 705 result.as_object.reset(new GetMetaInfo::Results::Value::Object); |
| 683 new bookmark_manager_private::MetaInfoFields); | |
| 684 | 706 |
| 685 const BookmarkNode::MetaInfoMap* meta_info = node->GetMetaInfoMap(); | 707 bookmark_api_helpers::GetMetaInfo(node, |
| 686 if (meta_info) | 708 &result.as_object->additional_properties); |
| 687 result.as_meta_info_fields->additional_properties = *meta_info; | 709 |
| 688 results_ = GetMetaInfo::Results::Create(result); | 710 results_ = GetMetaInfo::Results::Create(result); |
| 689 } | 711 } |
| 690 | 712 |
| 691 return true; | 713 return true; |
| 692 } | 714 } |
| 693 | 715 |
| 694 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { | 716 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { |
| 695 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); | 717 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); |
| 696 EXTENSION_FUNCTION_VALIDATE(params); | 718 EXTENSION_FUNCTION_VALIDATE(params); |
| 697 | 719 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 result.enabled = undo_manager->redo_count() > 0; | 814 result.enabled = undo_manager->redo_count() > 0; |
| 793 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); | 815 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); |
| 794 | 816 |
| 795 results_ = RedoInfo::Results::Create(result); | 817 results_ = RedoInfo::Results::Create(result); |
| 796 #endif // !defined(OS_ANDROID) | 818 #endif // !defined(OS_ANDROID) |
| 797 | 819 |
| 798 return true; | 820 return true; |
| 799 } | 821 } |
| 800 | 822 |
| 801 } // namespace extensions | 823 } // namespace extensions |
| OLD | NEW |