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

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

Issue 330983002: Added option to bookmarkManagerPrivate.getMetaInfo() to get meta info from all bookmarks in a one f… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {
692 if (params->key) {
693 return true;
694 }
695
696 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile());
697 const BookmarkNode* node = model->root_node();
698
681 GetMetaInfo::Results::Value result; 699 GetMetaInfo::Results::Value result;
682 result.as_meta_info_fields.reset( 700 result.as_map_meta_info_fields.reset(
683 new bookmark_manager_private::MetaInfoFields); 701 new bookmark_manager_private::MapMetaInfoFields);
684 702
685 const BookmarkNode::MetaInfoMap* meta_info = node->GetMetaInfoMap(); 703 bookmark_api_helpers::GetMetaInfo(node,
686 if (meta_info) 704 &result.as_map_meta_info_fields->additional_properties);
687 result.as_meta_info_fields->additional_properties = *meta_info; 705
688 results_ = GetMetaInfo::Results::Create(result); 706 results_ = GetMetaInfo::Results::Create(result);
689 } 707 }
690 708
691 return true; 709 return true;
692 } 710 }
693 711
694 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { 712 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() {
695 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); 713 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_));
696 EXTENSION_FUNCTION_VALIDATE(params); 714 EXTENSION_FUNCTION_VALIDATE(params);
697 715
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 result.enabled = undo_manager->redo_count() > 0; 810 result.enabled = undo_manager->redo_count() > 0;
793 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); 811 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel());
794 812
795 results_ = RedoInfo::Results::Create(result); 813 results_ = RedoInfo::Results::Create(result);
796 #endif // !defined(OS_ANDROID) 814 #endif // !defined(OS_ANDROID)
797 815
798 return true; 816 return true;
799 } 817 }
800 818
801 } // namespace extensions 819 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698