Chromium Code Reviews| 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_meta_info_fields.reset( |
| 684 new bookmark_manager_private::MetaInfoFields); | |
| 685 | |
| 686 const BookmarkNode::MetaInfoMap* meta_info = node->GetMetaInfoMap(); | |
| 687 if (meta_info) | |
| 688 result.as_meta_info_fields->additional_properties = *meta_info; | |
| 678 results_ = GetMetaInfo::Results::Create(result); | 689 results_ = GetMetaInfo::Results::Create(result); |
| 679 } | 690 } |
| 680 } else { | 691 } else { |
|
Mike Wittman
2014/06/16 17:47:34
If we're not supporting the case where a key is sp
yefimt
2014/06/16 19:04:01
Done.
| |
| 692 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | |
| 693 const BookmarkNode* node = model->root_node(); | |
| 694 | |
| 681 GetMetaInfo::Results::Value result; | 695 GetMetaInfo::Results::Value result; |
| 682 result.as_meta_info_fields.reset( | 696 result.as_map_meta_info_fields.reset( |
| 683 new bookmark_manager_private::MetaInfoFields); | 697 new bookmark_manager_private::MapMetaInfoFields); |
| 684 | 698 |
| 685 const BookmarkNode::MetaInfoMap* meta_info = node->GetMetaInfoMap(); | 699 bookmark_api_helpers::GetMetaInfo(node, |
| 686 if (meta_info) | 700 &result.as_map_meta_info_fields->additional_properties); |
| 687 result.as_meta_info_fields->additional_properties = *meta_info; | 701 |
| 688 results_ = GetMetaInfo::Results::Create(result); | 702 results_ = GetMetaInfo::Results::Create(result); |
| 689 } | 703 } |
| 690 | 704 |
| 691 return true; | 705 return true; |
| 692 } | 706 } |
| 693 | 707 |
| 694 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { | 708 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { |
| 695 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); | 709 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); |
| 696 EXTENSION_FUNCTION_VALIDATE(params); | 710 EXTENSION_FUNCTION_VALIDATE(params); |
| 697 | 711 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 result.enabled = undo_manager->redo_count() > 0; | 806 result.enabled = undo_manager->redo_count() > 0; |
| 793 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); | 807 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); |
| 794 | 808 |
| 795 results_ = RedoInfo::Results::Create(result); | 809 results_ = RedoInfo::Results::Create(result); |
| 796 #endif // !defined(OS_ANDROID) | 810 #endif // !defined(OS_ANDROID) |
| 797 | 811 |
| 798 return true; | 812 return true; |
| 799 } | 813 } |
| 800 | 814 |
| 801 } // namespace extensions | 815 } // namespace extensions |
| OLD | NEW |