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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 std::vector<const BookmarkNode*> nodes; | 369 std::vector<const BookmarkNode*> nodes; |
370 EXTENSION_FUNCTION_VALIDATE(GetNodesFromVector(model, id_list, &nodes)); | 370 EXTENSION_FUNCTION_VALIDATE(GetNodesFromVector(model, id_list, &nodes)); |
371 if (cut && bookmarks::HasDescendantsOf(nodes, managed->managed_node())) { | 371 if (cut && bookmarks::HasDescendantsOf(nodes, managed->managed_node())) { |
372 error_ = bookmark_keys::kModifyManagedError; | 372 error_ = bookmark_keys::kModifyManagedError; |
373 return false; | 373 return false; |
374 } | 374 } |
375 bookmarks::CopyToClipboard(model, nodes, cut); | 375 bookmarks::CopyToClipboard(model, nodes, cut); |
376 return true; | 376 return true; |
377 } | 377 } |
378 | 378 |
| 379 BookmarkManagerPrivateCopyFunction::BookmarkManagerPrivateCopyFunction() = |
| 380 default; |
| 381 |
379 bool BookmarkManagerPrivateCopyFunction::RunOnReady() { | 382 bool BookmarkManagerPrivateCopyFunction::RunOnReady() { |
380 scoped_ptr<Copy::Params> params(Copy::Params::Create(*args_)); | 383 scoped_ptr<Copy::Params> params(Copy::Params::Create(*args_)); |
381 EXTENSION_FUNCTION_VALIDATE(params); | 384 EXTENSION_FUNCTION_VALIDATE(params); |
382 return CopyOrCut(false, params->id_list); | 385 return CopyOrCut(false, params->id_list); |
383 } | 386 } |
384 | 387 |
| 388 BookmarkManagerPrivateCutFunction::BookmarkManagerPrivateCutFunction() = |
| 389 default; |
| 390 |
385 bool BookmarkManagerPrivateCutFunction::RunOnReady() { | 391 bool BookmarkManagerPrivateCutFunction::RunOnReady() { |
386 if (!EditBookmarksEnabled()) | 392 if (!EditBookmarksEnabled()) |
387 return false; | 393 return false; |
388 | 394 |
389 scoped_ptr<Cut::Params> params(Cut::Params::Create(*args_)); | 395 scoped_ptr<Cut::Params> params(Cut::Params::Create(*args_)); |
390 EXTENSION_FUNCTION_VALIDATE(params); | 396 EXTENSION_FUNCTION_VALIDATE(params); |
391 return CopyOrCut(true, params->id_list); | 397 return CopyOrCut(true, params->id_list); |
392 } | 398 } |
393 | 399 |
| 400 BookmarkManagerPrivatePasteFunction::BookmarkManagerPrivatePasteFunction() = |
| 401 default; |
| 402 |
394 bool BookmarkManagerPrivatePasteFunction::RunOnReady() { | 403 bool BookmarkManagerPrivatePasteFunction::RunOnReady() { |
395 if (!EditBookmarksEnabled()) | 404 if (!EditBookmarksEnabled()) |
396 return false; | 405 return false; |
397 | 406 |
398 scoped_ptr<Paste::Params> params(Paste::Params::Create(*args_)); | 407 scoped_ptr<Paste::Params> params(Paste::Params::Create(*args_)); |
399 EXTENSION_FUNCTION_VALIDATE(params); | 408 EXTENSION_FUNCTION_VALIDATE(params); |
400 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 409 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
401 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); | 410 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); |
402 if (!CanBeModified(parent_node)) | 411 if (!CanBeModified(parent_node)) |
403 return false; | 412 return false; |
(...skipping 11 matching lines...) Expand all Loading... |
415 // + 1 so that we insert after the selection. | 424 // + 1 so that we insert after the selection. |
416 int index = parent_node->GetIndexOf(nodes[i]) + 1; | 425 int index = parent_node->GetIndexOf(nodes[i]) + 1; |
417 if (index > highest_index) | 426 if (index > highest_index) |
418 highest_index = index; | 427 highest_index = index; |
419 } | 428 } |
420 | 429 |
421 bookmarks::PasteFromClipboard(model, parent_node, highest_index); | 430 bookmarks::PasteFromClipboard(model, parent_node, highest_index); |
422 return true; | 431 return true; |
423 } | 432 } |
424 | 433 |
| 434 BookmarkManagerPrivateCanPasteFunction:: |
| 435 BookmarkManagerPrivateCanPasteFunction() = default; |
| 436 |
425 bool BookmarkManagerPrivateCanPasteFunction::RunOnReady() { | 437 bool BookmarkManagerPrivateCanPasteFunction::RunOnReady() { |
426 scoped_ptr<CanPaste::Params> params(CanPaste::Params::Create(*args_)); | 438 scoped_ptr<CanPaste::Params> params(CanPaste::Params::Create(*args_)); |
427 EXTENSION_FUNCTION_VALIDATE(params); | 439 EXTENSION_FUNCTION_VALIDATE(params); |
428 | 440 |
429 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); | 441 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); |
430 if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled)) { | 442 if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled)) { |
431 SetResult(new base::FundamentalValue(false)); | 443 SetResult(new base::FundamentalValue(false)); |
432 return true; | 444 return true; |
433 } | 445 } |
434 | 446 |
435 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 447 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
436 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); | 448 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); |
437 if (!parent_node) { | 449 if (!parent_node) { |
438 error_ = bookmark_keys::kNoParentError; | 450 error_ = bookmark_keys::kNoParentError; |
439 return false; | 451 return false; |
440 } | 452 } |
441 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node); | 453 bool can_paste = bookmarks::CanPasteFromClipboard(model, parent_node); |
442 SetResult(new base::FundamentalValue(can_paste)); | 454 SetResult(new base::FundamentalValue(can_paste)); |
443 return true; | 455 return true; |
444 } | 456 } |
445 | 457 |
| 458 BookmarkManagerPrivateSortChildrenFunction:: |
| 459 BookmarkManagerPrivateSortChildrenFunction() = default; |
| 460 |
446 bool BookmarkManagerPrivateSortChildrenFunction::RunOnReady() { | 461 bool BookmarkManagerPrivateSortChildrenFunction::RunOnReady() { |
447 if (!EditBookmarksEnabled()) | 462 if (!EditBookmarksEnabled()) |
448 return false; | 463 return false; |
449 | 464 |
450 scoped_ptr<SortChildren::Params> params(SortChildren::Params::Create(*args_)); | 465 scoped_ptr<SortChildren::Params> params(SortChildren::Params::Create(*args_)); |
451 EXTENSION_FUNCTION_VALIDATE(params); | 466 EXTENSION_FUNCTION_VALIDATE(params); |
452 | 467 |
453 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 468 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
454 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); | 469 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); |
455 if (!CanBeModified(parent_node)) | 470 if (!CanBeModified(parent_node)) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 | 548 |
534 SetResult(localized_strings); | 549 SetResult(localized_strings); |
535 | 550 |
536 // This is needed because unlike the rest of these functions, this class | 551 // This is needed because unlike the rest of these functions, this class |
537 // inherits from AsyncFunction directly, rather than BookmarkFunction. | 552 // inherits from AsyncFunction directly, rather than BookmarkFunction. |
538 SendResponse(true); | 553 SendResponse(true); |
539 | 554 |
540 return true; | 555 return true; |
541 } | 556 } |
542 | 557 |
| 558 BookmarkManagerPrivateStartDragFunction:: |
| 559 BookmarkManagerPrivateStartDragFunction() = default; |
| 560 |
543 bool BookmarkManagerPrivateStartDragFunction::RunOnReady() { | 561 bool BookmarkManagerPrivateStartDragFunction::RunOnReady() { |
544 if (!EditBookmarksEnabled()) | 562 if (!EditBookmarksEnabled()) |
545 return false; | 563 return false; |
546 | 564 |
547 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) { | 565 if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) { |
548 NOTREACHED(); | 566 NOTREACHED(); |
549 return false; | 567 return false; |
550 } | 568 } |
551 | 569 |
552 scoped_ptr<StartDrag::Params> params(StartDrag::Params::Create(*args_)); | 570 scoped_ptr<StartDrag::Params> params(StartDrag::Params::Create(*args_)); |
(...skipping 11 matching lines...) Expand all Loading... |
564 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; | 582 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; |
565 if (params->is_from_touch) | 583 if (params->is_from_touch) |
566 source = ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; | 584 source = ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; |
567 | 585 |
568 chrome::DragBookmarks( | 586 chrome::DragBookmarks( |
569 GetProfile(), nodes, web_contents->GetNativeView(), source); | 587 GetProfile(), nodes, web_contents->GetNativeView(), source); |
570 | 588 |
571 return true; | 589 return true; |
572 } | 590 } |
573 | 591 |
| 592 BookmarkManagerPrivateDropFunction::BookmarkManagerPrivateDropFunction() = |
| 593 default; |
| 594 |
574 bool BookmarkManagerPrivateDropFunction::RunOnReady() { | 595 bool BookmarkManagerPrivateDropFunction::RunOnReady() { |
575 if (!EditBookmarksEnabled()) | 596 if (!EditBookmarksEnabled()) |
576 return false; | 597 return false; |
577 | 598 |
578 scoped_ptr<Drop::Params> params(Drop::Params::Create(*args_)); | 599 scoped_ptr<Drop::Params> params(Drop::Params::Create(*args_)); |
579 EXTENSION_FUNCTION_VALIDATE(params); | 600 EXTENSION_FUNCTION_VALIDATE(params); |
580 | 601 |
581 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 602 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
582 | 603 |
583 const BookmarkNode* drop_parent = GetNodeFromString(model, params->parent_id); | 604 const BookmarkNode* drop_parent = GetNodeFromString(model, params->parent_id); |
(...skipping 26 matching lines...) Expand all Loading... |
610 return false; | 631 return false; |
611 } | 632 } |
612 const bool copy = false; | 633 const bool copy = false; |
613 chrome::DropBookmarks( | 634 chrome::DropBookmarks( |
614 GetProfile(), *drag_data, drop_parent, drop_index, copy); | 635 GetProfile(), *drag_data, drop_parent, drop_index, copy); |
615 | 636 |
616 router->ClearBookmarkNodeData(); | 637 router->ClearBookmarkNodeData(); |
617 return true; | 638 return true; |
618 } | 639 } |
619 | 640 |
| 641 BookmarkManagerPrivateGetSubtreeFunction:: |
| 642 BookmarkManagerPrivateGetSubtreeFunction() = default; |
| 643 |
620 bool BookmarkManagerPrivateGetSubtreeFunction::RunOnReady() { | 644 bool BookmarkManagerPrivateGetSubtreeFunction::RunOnReady() { |
621 scoped_ptr<GetSubtree::Params> params(GetSubtree::Params::Create(*args_)); | 645 scoped_ptr<GetSubtree::Params> params(GetSubtree::Params::Create(*args_)); |
622 EXTENSION_FUNCTION_VALIDATE(params); | 646 EXTENSION_FUNCTION_VALIDATE(params); |
623 | 647 |
624 const BookmarkNode* node = NULL; | 648 const BookmarkNode* node = NULL; |
625 | 649 |
626 if (params->id.empty()) { | 650 if (params->id.empty()) { |
627 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 651 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
628 node = model->root_node(); | 652 node = model->root_node(); |
629 } else { | 653 } else { |
630 node = GetBookmarkNodeFromId(params->id); | 654 node = GetBookmarkNodeFromId(params->id); |
631 if (!node) | 655 if (!node) |
632 return false; | 656 return false; |
633 } | 657 } |
634 | 658 |
635 std::vector<linked_ptr<api::bookmarks::BookmarkTreeNode> > nodes; | 659 std::vector<linked_ptr<api::bookmarks::BookmarkTreeNode> > nodes; |
636 bookmarks::ManagedBookmarkService* managed = GetManagedBookmarkService(); | 660 bookmarks::ManagedBookmarkService* managed = GetManagedBookmarkService(); |
637 if (params->folders_only) | 661 if (params->folders_only) |
638 bookmark_api_helpers::AddNodeFoldersOnly(managed, node, &nodes, true); | 662 bookmark_api_helpers::AddNodeFoldersOnly(managed, node, &nodes, true); |
639 else | 663 else |
640 bookmark_api_helpers::AddNode(managed, node, &nodes, true); | 664 bookmark_api_helpers::AddNode(managed, node, &nodes, true); |
641 results_ = GetSubtree::Results::Create(nodes); | 665 results_ = GetSubtree::Results::Create(nodes); |
642 return true; | 666 return true; |
643 } | 667 } |
644 | 668 |
| 669 BookmarkManagerPrivateCanEditFunction::BookmarkManagerPrivateCanEditFunction() = |
| 670 default; |
| 671 |
645 bool BookmarkManagerPrivateCanEditFunction::RunOnReady() { | 672 bool BookmarkManagerPrivateCanEditFunction::RunOnReady() { |
646 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); | 673 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); |
647 SetResult(new base::FundamentalValue( | 674 SetResult(new base::FundamentalValue( |
648 prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled))); | 675 prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled))); |
649 return true; | 676 return true; |
650 } | 677 } |
651 | 678 |
| 679 BookmarkManagerPrivateRecordLaunchFunction:: |
| 680 BookmarkManagerPrivateRecordLaunchFunction() = default; |
| 681 |
652 bool BookmarkManagerPrivateRecordLaunchFunction::RunOnReady() { | 682 bool BookmarkManagerPrivateRecordLaunchFunction::RunOnReady() { |
653 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_MANAGER); | 683 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_MANAGER); |
654 return true; | 684 return true; |
655 } | 685 } |
656 | 686 |
| 687 BookmarkManagerPrivateCreateWithMetaInfoFunction:: |
| 688 BookmarkManagerPrivateCreateWithMetaInfoFunction() = default; |
| 689 |
657 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() { | 690 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() { |
658 if (!EditBookmarksEnabled()) | 691 if (!EditBookmarksEnabled()) |
659 return false; | 692 return false; |
660 | 693 |
661 scoped_ptr<CreateWithMetaInfo::Params> params( | 694 scoped_ptr<CreateWithMetaInfo::Params> params( |
662 CreateWithMetaInfo::Params::Create(*args_)); | 695 CreateWithMetaInfo::Params::Create(*args_)); |
663 EXTENSION_FUNCTION_VALIDATE(params); | 696 EXTENSION_FUNCTION_VALIDATE(params); |
664 | 697 |
665 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 698 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
666 const BookmarkNode* node = CreateBookmarkNode( | 699 const BookmarkNode* node = CreateBookmarkNode( |
667 model, params->bookmark, ¶ms->meta_info.additional_properties); | 700 model, params->bookmark, ¶ms->meta_info.additional_properties); |
668 if (!node) | 701 if (!node) |
669 return false; | 702 return false; |
670 | 703 |
671 scoped_ptr<api::bookmarks::BookmarkTreeNode> result_node( | 704 scoped_ptr<api::bookmarks::BookmarkTreeNode> result_node( |
672 bookmark_api_helpers::GetBookmarkTreeNode(GetManagedBookmarkService(), | 705 bookmark_api_helpers::GetBookmarkTreeNode(GetManagedBookmarkService(), |
673 node, false, false)); | 706 node, false, false)); |
674 results_ = CreateWithMetaInfo::Results::Create(*result_node); | 707 results_ = CreateWithMetaInfo::Results::Create(*result_node); |
675 | 708 |
676 return true; | 709 return true; |
677 } | 710 } |
678 | 711 |
| 712 BookmarkManagerPrivateGetMetaInfoFunction:: |
| 713 BookmarkManagerPrivateGetMetaInfoFunction() = default; |
| 714 |
679 bool BookmarkManagerPrivateGetMetaInfoFunction::RunOnReady() { | 715 bool BookmarkManagerPrivateGetMetaInfoFunction::RunOnReady() { |
680 scoped_ptr<GetMetaInfo::Params> params(GetMetaInfo::Params::Create(*args_)); | 716 scoped_ptr<GetMetaInfo::Params> params(GetMetaInfo::Params::Create(*args_)); |
681 EXTENSION_FUNCTION_VALIDATE(params); | 717 EXTENSION_FUNCTION_VALIDATE(params); |
682 | 718 |
683 if (params->id) { | 719 if (params->id) { |
684 const BookmarkNode* node = GetBookmarkNodeFromId(*params->id); | 720 const BookmarkNode* node = GetBookmarkNodeFromId(*params->id); |
685 if (!node) | 721 if (!node) |
686 return false; | 722 return false; |
687 | 723 |
688 if (params->key) { | 724 if (params->key) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 | 756 |
721 bookmark_api_helpers::GetMetaInfo(*node, | 757 bookmark_api_helpers::GetMetaInfo(*node, |
722 &result.as_object->additional_properties); | 758 &result.as_object->additional_properties); |
723 | 759 |
724 results_ = GetMetaInfo::Results::Create(result); | 760 results_ = GetMetaInfo::Results::Create(result); |
725 } | 761 } |
726 | 762 |
727 return true; | 763 return true; |
728 } | 764 } |
729 | 765 |
| 766 BookmarkManagerPrivateSetMetaInfoFunction:: |
| 767 BookmarkManagerPrivateSetMetaInfoFunction() = default; |
| 768 |
730 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { | 769 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { |
731 if (!EditBookmarksEnabled()) | 770 if (!EditBookmarksEnabled()) |
732 return false; | 771 return false; |
733 | 772 |
734 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); | 773 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); |
735 EXTENSION_FUNCTION_VALIDATE(params); | 774 EXTENSION_FUNCTION_VALIDATE(params); |
736 | 775 |
737 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); | 776 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); |
738 if (!node) | 777 if (!node) |
739 return false; | 778 return false; |
740 | 779 |
741 if (!CanBeModified(node)) | 780 if (!CanBeModified(node)) |
742 return false; | 781 return false; |
743 | 782 |
744 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 783 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
745 if (model->is_permanent_node(node)) { | 784 if (model->is_permanent_node(node)) { |
746 error_ = bookmark_keys::kModifySpecialError; | 785 error_ = bookmark_keys::kModifySpecialError; |
747 return false; | 786 return false; |
748 } | 787 } |
749 | 788 |
750 model->SetNodeMetaInfo(node, params->key, params->value); | 789 model->SetNodeMetaInfo(node, params->key, params->value); |
751 return true; | 790 return true; |
752 } | 791 } |
753 | 792 |
| 793 BookmarkManagerPrivateUpdateMetaInfoFunction:: |
| 794 BookmarkManagerPrivateUpdateMetaInfoFunction() = default; |
| 795 |
754 bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunOnReady() { | 796 bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunOnReady() { |
755 if (!EditBookmarksEnabled()) | 797 if (!EditBookmarksEnabled()) |
756 return false; | 798 return false; |
757 | 799 |
758 scoped_ptr<UpdateMetaInfo::Params> params( | 800 scoped_ptr<UpdateMetaInfo::Params> params( |
759 UpdateMetaInfo::Params::Create(*args_)); | 801 UpdateMetaInfo::Params::Create(*args_)); |
760 EXTENSION_FUNCTION_VALIDATE(params); | 802 EXTENSION_FUNCTION_VALIDATE(params); |
761 | 803 |
762 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); | 804 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); |
763 if (!node) | 805 if (!node) |
(...skipping 12 matching lines...) Expand all Loading... |
776 params->meta_info_changes.additional_properties); | 818 params->meta_info_changes.additional_properties); |
777 if (node->GetMetaInfoMap()) { | 819 if (node->GetMetaInfoMap()) { |
778 new_meta_info.insert(node->GetMetaInfoMap()->begin(), | 820 new_meta_info.insert(node->GetMetaInfoMap()->begin(), |
779 node->GetMetaInfoMap()->end()); | 821 node->GetMetaInfoMap()->end()); |
780 } | 822 } |
781 model->SetNodeMetaInfoMap(node, new_meta_info); | 823 model->SetNodeMetaInfoMap(node, new_meta_info); |
782 | 824 |
783 return true; | 825 return true; |
784 } | 826 } |
785 | 827 |
| 828 BookmarkManagerPrivateCanOpenNewWindowsFunction:: |
| 829 BookmarkManagerPrivateCanOpenNewWindowsFunction() = default; |
| 830 |
786 bool BookmarkManagerPrivateCanOpenNewWindowsFunction::RunOnReady() { | 831 bool BookmarkManagerPrivateCanOpenNewWindowsFunction::RunOnReady() { |
787 bool can_open_new_windows = true; | 832 bool can_open_new_windows = true; |
788 SetResult(new base::FundamentalValue(can_open_new_windows)); | 833 SetResult(new base::FundamentalValue(can_open_new_windows)); |
789 return true; | 834 return true; |
790 } | 835 } |
791 | 836 |
| 837 BookmarkManagerPrivateRemoveTreesFunction:: |
| 838 BookmarkManagerPrivateRemoveTreesFunction() = default; |
| 839 |
792 bool BookmarkManagerPrivateRemoveTreesFunction::RunOnReady() { | 840 bool BookmarkManagerPrivateRemoveTreesFunction::RunOnReady() { |
793 if (!EditBookmarksEnabled()) | 841 if (!EditBookmarksEnabled()) |
794 return false; | 842 return false; |
795 | 843 |
796 scoped_ptr<RemoveTrees::Params> params(RemoveTrees::Params::Create(*args_)); | 844 scoped_ptr<RemoveTrees::Params> params(RemoveTrees::Params::Create(*args_)); |
797 EXTENSION_FUNCTION_VALIDATE(params); | 845 EXTENSION_FUNCTION_VALIDATE(params); |
798 | 846 |
799 BookmarkModel* model = GetBookmarkModel(); | 847 BookmarkModel* model = GetBookmarkModel(); |
800 bookmarks::ManagedBookmarkService* managed = GetManagedBookmarkService(); | 848 bookmarks::ManagedBookmarkService* managed = GetManagedBookmarkService(); |
801 bookmarks::ScopedGroupBookmarkActions group_deletes(model); | 849 bookmarks::ScopedGroupBookmarkActions group_deletes(model); |
802 int64 id; | 850 int64 id; |
803 for (size_t i = 0; i < params->id_list.size(); ++i) { | 851 for (size_t i = 0; i < params->id_list.size(); ++i) { |
804 if (!GetBookmarkIdAsInt64(params->id_list[i], &id)) | 852 if (!GetBookmarkIdAsInt64(params->id_list[i], &id)) |
805 return false; | 853 return false; |
806 if (!bookmark_api_helpers::RemoveNode(model, managed, id, true, &error_)) | 854 if (!bookmark_api_helpers::RemoveNode(model, managed, id, true, &error_)) |
807 return false; | 855 return false; |
808 } | 856 } |
809 | 857 |
810 return true; | 858 return true; |
811 } | 859 } |
812 | 860 |
| 861 BookmarkManagerPrivateUndoFunction::BookmarkManagerPrivateUndoFunction() = |
| 862 default; |
| 863 |
813 bool BookmarkManagerPrivateUndoFunction::RunOnReady() { | 864 bool BookmarkManagerPrivateUndoFunction::RunOnReady() { |
814 if (!EditBookmarksEnabled()) | 865 if (!EditBookmarksEnabled()) |
815 return false; | 866 return false; |
816 | 867 |
817 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> | 868 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> |
818 Undo(); | 869 Undo(); |
819 return true; | 870 return true; |
820 } | 871 } |
821 | 872 |
| 873 BookmarkManagerPrivateRedoFunction::BookmarkManagerPrivateRedoFunction() = |
| 874 default; |
| 875 |
822 bool BookmarkManagerPrivateRedoFunction::RunOnReady() { | 876 bool BookmarkManagerPrivateRedoFunction::RunOnReady() { |
823 if (!EditBookmarksEnabled()) | 877 if (!EditBookmarksEnabled()) |
824 return false; | 878 return false; |
825 | 879 |
826 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> | 880 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> |
827 Redo(); | 881 Redo(); |
828 return true; | 882 return true; |
829 } | 883 } |
830 | 884 |
| 885 BookmarkManagerPrivateGetUndoInfoFunction:: |
| 886 BookmarkManagerPrivateGetUndoInfoFunction() = default; |
| 887 |
831 bool BookmarkManagerPrivateGetUndoInfoFunction::RunOnReady() { | 888 bool BookmarkManagerPrivateGetUndoInfoFunction::RunOnReady() { |
832 UndoManager* undo_manager = | 889 UndoManager* undo_manager = |
833 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); | 890 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); |
834 | 891 |
835 UndoInfo::Results::Result result; | 892 UndoInfo::Results::Result result; |
836 result.enabled = undo_manager->undo_count() > 0; | 893 result.enabled = undo_manager->undo_count() > 0; |
837 result.label = base::UTF16ToUTF8(undo_manager->GetUndoLabel()); | 894 result.label = base::UTF16ToUTF8(undo_manager->GetUndoLabel()); |
838 | 895 |
839 results_ = UndoInfo::Results::Create(result); | 896 results_ = UndoInfo::Results::Create(result); |
840 return true; | 897 return true; |
841 } | 898 } |
842 | 899 |
| 900 BookmarkManagerPrivateGetRedoInfoFunction:: |
| 901 BookmarkManagerPrivateGetRedoInfoFunction() = default; |
| 902 |
843 bool BookmarkManagerPrivateGetRedoInfoFunction::RunOnReady() { | 903 bool BookmarkManagerPrivateGetRedoInfoFunction::RunOnReady() { |
844 UndoManager* undo_manager = | 904 UndoManager* undo_manager = |
845 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); | 905 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); |
846 | 906 |
847 RedoInfo::Results::Result result; | 907 RedoInfo::Results::Result result; |
848 result.enabled = undo_manager->redo_count() > 0; | 908 result.enabled = undo_manager->redo_count() > 0; |
849 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); | 909 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); |
850 | 910 |
851 results_ = RedoInfo::Results::Create(result); | 911 results_ = RedoInfo::Results::Create(result); |
852 return true; | 912 return true; |
853 } | 913 } |
854 | 914 |
| 915 BookmarkManagerPrivateSetVersionFunction:: |
| 916 BookmarkManagerPrivateSetVersionFunction() = default; |
| 917 |
855 bool BookmarkManagerPrivateSetVersionFunction::RunOnReady() { | 918 bool BookmarkManagerPrivateSetVersionFunction::RunOnReady() { |
856 scoped_ptr<SetVersion::Params> params = SetVersion::Params::Create(*args_); | 919 scoped_ptr<SetVersion::Params> params = SetVersion::Params::Create(*args_); |
857 | 920 |
858 enhanced_bookmarks::EnhancedBookmarkModel* model = | 921 enhanced_bookmarks::EnhancedBookmarkModel* model = |
859 enhanced_bookmarks::EnhancedBookmarkModelFactory::GetForBrowserContext( | 922 enhanced_bookmarks::EnhancedBookmarkModelFactory::GetForBrowserContext( |
860 browser_context()); | 923 browser_context()); |
861 model->SetVersionSuffix(params->version); | 924 model->SetVersionSuffix(params->version); |
862 | 925 |
863 return true; | 926 return true; |
864 } | 927 } |
865 | 928 |
866 } // namespace extensions | 929 } // namespace extensions |
OLD | NEW |