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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 if (params->id == "") { | 614 if (params->id == "") { |
615 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 615 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
616 node = model->root_node(); | 616 node = model->root_node(); |
617 } else { | 617 } else { |
618 node = GetBookmarkNodeFromId(params->id); | 618 node = GetBookmarkNodeFromId(params->id); |
619 if (!node) | 619 if (!node) |
620 return false; | 620 return false; |
621 } | 621 } |
622 | 622 |
623 std::vector<linked_ptr<api::bookmarks::BookmarkTreeNode> > nodes; | 623 std::vector<linked_ptr<api::bookmarks::BookmarkTreeNode> > nodes; |
| 624 ChromeBookmarkClient* client = GetChromeBookmarkClient(); |
624 if (params->folders_only) | 625 if (params->folders_only) |
625 bookmark_api_helpers::AddNodeFoldersOnly(node, &nodes, true); | 626 bookmark_api_helpers::AddNodeFoldersOnly(client, node, &nodes, true); |
626 else | 627 else |
627 bookmark_api_helpers::AddNode(node, &nodes, true); | 628 bookmark_api_helpers::AddNode(client, node, &nodes, true); |
628 results_ = GetSubtree::Results::Create(nodes); | 629 results_ = GetSubtree::Results::Create(nodes); |
629 return true; | 630 return true; |
630 } | 631 } |
631 | 632 |
632 bool BookmarkManagerPrivateCanEditFunction::RunOnReady() { | 633 bool BookmarkManagerPrivateCanEditFunction::RunOnReady() { |
633 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); | 634 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); |
634 SetResult(new base::FundamentalValue( | 635 SetResult(new base::FundamentalValue( |
635 prefs->GetBoolean(prefs::kEditBookmarksEnabled))); | 636 prefs->GetBoolean(prefs::kEditBookmarksEnabled))); |
636 return true; | 637 return true; |
637 } | 638 } |
638 | 639 |
639 bool BookmarkManagerPrivateRecordLaunchFunction::RunOnReady() { | 640 bool BookmarkManagerPrivateRecordLaunchFunction::RunOnReady() { |
640 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_MANAGER); | 641 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_MANAGER); |
641 return true; | 642 return true; |
642 } | 643 } |
643 | 644 |
644 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() { | 645 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() { |
645 scoped_ptr<CreateWithMetaInfo::Params> params( | 646 scoped_ptr<CreateWithMetaInfo::Params> params( |
646 CreateWithMetaInfo::Params::Create(*args_)); | 647 CreateWithMetaInfo::Params::Create(*args_)); |
647 EXTENSION_FUNCTION_VALIDATE(params); | 648 EXTENSION_FUNCTION_VALIDATE(params); |
648 | 649 |
649 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 650 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
650 const BookmarkNode* node = CreateBookmarkNode( | 651 const BookmarkNode* node = CreateBookmarkNode( |
651 model, params->bookmark, ¶ms->meta_info.additional_properties); | 652 model, params->bookmark, ¶ms->meta_info.additional_properties); |
652 if (!node) | 653 if (!node) |
653 return false; | 654 return false; |
654 | 655 |
655 scoped_ptr<api::bookmarks::BookmarkTreeNode> result_node( | 656 scoped_ptr<api::bookmarks::BookmarkTreeNode> result_node( |
656 bookmark_api_helpers::GetBookmarkTreeNode(node, false, false)); | 657 bookmark_api_helpers::GetBookmarkTreeNode( |
| 658 GetChromeBookmarkClient(), node, false, false)); |
657 results_ = CreateWithMetaInfo::Results::Create(*result_node); | 659 results_ = CreateWithMetaInfo::Results::Create(*result_node); |
658 | 660 |
659 return true; | 661 return true; |
660 } | 662 } |
661 | 663 |
662 bool BookmarkManagerPrivateGetMetaInfoFunction::RunOnReady() { | 664 bool BookmarkManagerPrivateGetMetaInfoFunction::RunOnReady() { |
663 scoped_ptr<GetMetaInfo::Params> params(GetMetaInfo::Params::Create(*args_)); | 665 scoped_ptr<GetMetaInfo::Params> params(GetMetaInfo::Params::Create(*args_)); |
664 EXTENSION_FUNCTION_VALIDATE(params); | 666 EXTENSION_FUNCTION_VALIDATE(params); |
665 | 667 |
666 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); | 668 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 result.enabled = undo_manager->redo_count() > 0; | 791 result.enabled = undo_manager->redo_count() > 0; |
790 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); | 792 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); |
791 | 793 |
792 results_ = RedoInfo::Results::Create(result); | 794 results_ = RedoInfo::Results::Create(result); |
793 #endif // !defined(OS_ANDROID) | 795 #endif // !defined(OS_ANDROID) |
794 | 796 |
795 return true; | 797 return true; |
796 } | 798 } |
797 | 799 |
798 } // namespace extensions | 800 } // namespace extensions |
OLD | NEW |