| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 350 |
| 351 bool ClipboardBookmarkManagerFunction::CopyOrCut(bool cut, | 351 bool ClipboardBookmarkManagerFunction::CopyOrCut(bool cut, |
| 352 const std::vector<std::string>& id_list) { | 352 const std::vector<std::string>& id_list) { |
| 353 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 353 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 354 std::vector<const BookmarkNode*> nodes; | 354 std::vector<const BookmarkNode*> nodes; |
| 355 EXTENSION_FUNCTION_VALIDATE(GetNodesFromVector(model, id_list, &nodes)); | 355 EXTENSION_FUNCTION_VALIDATE(GetNodesFromVector(model, id_list, &nodes)); |
| 356 bookmark_utils::CopyToClipboard(model, nodes, cut); | 356 bookmark_utils::CopyToClipboard(model, nodes, cut); |
| 357 return true; | 357 return true; |
| 358 } | 358 } |
| 359 | 359 |
| 360 bool BookmarkManagerPrivateCopyFunction::RunImpl() { | 360 bool BookmarkManagerPrivateCopyFunction::RunOnReady() { |
| 361 scoped_ptr<Copy::Params> params(Copy::Params::Create(*args_)); | 361 scoped_ptr<Copy::Params> params(Copy::Params::Create(*args_)); |
| 362 EXTENSION_FUNCTION_VALIDATE(params); | 362 EXTENSION_FUNCTION_VALIDATE(params); |
| 363 return CopyOrCut(false, params->id_list); | 363 return CopyOrCut(false, params->id_list); |
| 364 } | 364 } |
| 365 | 365 |
| 366 bool BookmarkManagerPrivateCutFunction::RunImpl() { | 366 bool BookmarkManagerPrivateCutFunction::RunOnReady() { |
| 367 if (!EditBookmarksEnabled()) | 367 if (!EditBookmarksEnabled()) |
| 368 return false; | 368 return false; |
| 369 | 369 |
| 370 scoped_ptr<Cut::Params> params(Cut::Params::Create(*args_)); | 370 scoped_ptr<Cut::Params> params(Cut::Params::Create(*args_)); |
| 371 EXTENSION_FUNCTION_VALIDATE(params); | 371 EXTENSION_FUNCTION_VALIDATE(params); |
| 372 return CopyOrCut(true, params->id_list); | 372 return CopyOrCut(true, params->id_list); |
| 373 } | 373 } |
| 374 | 374 |
| 375 bool BookmarkManagerPrivatePasteFunction::RunImpl() { | 375 bool BookmarkManagerPrivatePasteFunction::RunOnReady() { |
| 376 if (!EditBookmarksEnabled()) | 376 if (!EditBookmarksEnabled()) |
| 377 return false; | 377 return false; |
| 378 | 378 |
| 379 scoped_ptr<Paste::Params> params(Paste::Params::Create(*args_)); | 379 scoped_ptr<Paste::Params> params(Paste::Params::Create(*args_)); |
| 380 EXTENSION_FUNCTION_VALIDATE(params); | 380 EXTENSION_FUNCTION_VALIDATE(params); |
| 381 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 381 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 382 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); | 382 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); |
| 383 if (!parent_node) { | 383 if (!parent_node) { |
| 384 error_ = bookmark_keys::kNoParentError; | 384 error_ = bookmark_keys::kNoParentError; |
| 385 return false; | 385 return false; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 398 // + 1 so that we insert after the selection. | 398 // + 1 so that we insert after the selection. |
| 399 int index = parent_node->GetIndexOf(nodes[i]) + 1; | 399 int index = parent_node->GetIndexOf(nodes[i]) + 1; |
| 400 if (index > highest_index) | 400 if (index > highest_index) |
| 401 highest_index = index; | 401 highest_index = index; |
| 402 } | 402 } |
| 403 | 403 |
| 404 bookmark_utils::PasteFromClipboard(model, parent_node, highest_index); | 404 bookmark_utils::PasteFromClipboard(model, parent_node, highest_index); |
| 405 return true; | 405 return true; |
| 406 } | 406 } |
| 407 | 407 |
| 408 bool BookmarkManagerPrivateCanPasteFunction::RunImpl() { | 408 bool BookmarkManagerPrivateCanPasteFunction::RunOnReady() { |
| 409 if (!EditBookmarksEnabled()) | 409 if (!EditBookmarksEnabled()) |
| 410 return false; | 410 return false; |
| 411 | 411 |
| 412 scoped_ptr<CanPaste::Params> params(CanPaste::Params::Create(*args_)); | 412 scoped_ptr<CanPaste::Params> params(CanPaste::Params::Create(*args_)); |
| 413 EXTENSION_FUNCTION_VALIDATE(params); | 413 EXTENSION_FUNCTION_VALIDATE(params); |
| 414 | 414 |
| 415 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 415 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 416 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); | 416 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); |
| 417 if (!parent_node) { | 417 if (!parent_node) { |
| 418 error_ = bookmark_keys::kNoParentError; | 418 error_ = bookmark_keys::kNoParentError; |
| 419 return false; | 419 return false; |
| 420 } | 420 } |
| 421 bool can_paste = bookmark_utils::CanPasteFromClipboard(parent_node); | 421 bool can_paste = bookmark_utils::CanPasteFromClipboard(parent_node); |
| 422 SetResult(new base::FundamentalValue(can_paste)); | 422 SetResult(new base::FundamentalValue(can_paste)); |
| 423 return true; | 423 return true; |
| 424 } | 424 } |
| 425 | 425 |
| 426 bool BookmarkManagerPrivateSortChildrenFunction::RunImpl() { | 426 bool BookmarkManagerPrivateSortChildrenFunction::RunOnReady() { |
| 427 if (!EditBookmarksEnabled()) | 427 if (!EditBookmarksEnabled()) |
| 428 return false; | 428 return false; |
| 429 | 429 |
| 430 scoped_ptr<SortChildren::Params> params(SortChildren::Params::Create(*args_)); | 430 scoped_ptr<SortChildren::Params> params(SortChildren::Params::Create(*args_)); |
| 431 EXTENSION_FUNCTION_VALIDATE(params); | 431 EXTENSION_FUNCTION_VALIDATE(params); |
| 432 | 432 |
| 433 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 433 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 434 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); | 434 const BookmarkNode* parent_node = GetNodeFromString(model, params->parent_id); |
| 435 if (!parent_node) { | 435 if (!parent_node) { |
| 436 error_ = bookmark_keys::kNoParentError; | 436 error_ = bookmark_keys::kNoParentError; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 512 |
| 513 SetResult(localized_strings); | 513 SetResult(localized_strings); |
| 514 | 514 |
| 515 // This is needed because unlike the rest of these functions, this class | 515 // This is needed because unlike the rest of these functions, this class |
| 516 // inherits from AsyncFunction directly, rather than BookmarkFunction. | 516 // inherits from AsyncFunction directly, rather than BookmarkFunction. |
| 517 SendResponse(true); | 517 SendResponse(true); |
| 518 | 518 |
| 519 return true; | 519 return true; |
| 520 } | 520 } |
| 521 | 521 |
| 522 bool BookmarkManagerPrivateStartDragFunction::RunImpl() { | 522 bool BookmarkManagerPrivateStartDragFunction::RunOnReady() { |
| 523 if (!EditBookmarksEnabled()) | 523 if (!EditBookmarksEnabled()) |
| 524 return false; | 524 return false; |
| 525 | 525 |
| 526 scoped_ptr<StartDrag::Params> params(StartDrag::Params::Create(*args_)); | 526 scoped_ptr<StartDrag::Params> params(StartDrag::Params::Create(*args_)); |
| 527 EXTENSION_FUNCTION_VALIDATE(params); | 527 EXTENSION_FUNCTION_VALIDATE(params); |
| 528 | 528 |
| 529 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 529 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 530 std::vector<const BookmarkNode*> nodes; | 530 std::vector<const BookmarkNode*> nodes; |
| 531 EXTENSION_FUNCTION_VALIDATE( | 531 EXTENSION_FUNCTION_VALIDATE( |
| 532 GetNodesFromVector(model, params->id_list, &nodes)); | 532 GetNodesFromVector(model, params->id_list, &nodes)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 546 chrome::DragBookmarks( | 546 chrome::DragBookmarks( |
| 547 GetProfile(), nodes, web_contents->GetView()->GetNativeView(), source); | 547 GetProfile(), nodes, web_contents->GetView()->GetNativeView(), source); |
| 548 | 548 |
| 549 return true; | 549 return true; |
| 550 } else { | 550 } else { |
| 551 NOTREACHED(); | 551 NOTREACHED(); |
| 552 return false; | 552 return false; |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 | 555 |
| 556 bool BookmarkManagerPrivateDropFunction::RunImpl() { | 556 bool BookmarkManagerPrivateDropFunction::RunOnReady() { |
| 557 if (!EditBookmarksEnabled()) | 557 if (!EditBookmarksEnabled()) |
| 558 return false; | 558 return false; |
| 559 | 559 |
| 560 scoped_ptr<Drop::Params> params(Drop::Params::Create(*args_)); | 560 scoped_ptr<Drop::Params> params(Drop::Params::Create(*args_)); |
| 561 EXTENSION_FUNCTION_VALIDATE(params); | 561 EXTENSION_FUNCTION_VALIDATE(params); |
| 562 | 562 |
| 563 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 563 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 564 | 564 |
| 565 const BookmarkNode* drop_parent = GetNodeFromString(model, params->parent_id); | 565 const BookmarkNode* drop_parent = GetNodeFromString(model, params->parent_id); |
| 566 if (!drop_parent) { | 566 if (!drop_parent) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 595 chrome::DropBookmarks(GetProfile(), *drag_data, drop_parent, drop_index); | 595 chrome::DropBookmarks(GetProfile(), *drag_data, drop_parent, drop_index); |
| 596 | 596 |
| 597 router->ClearBookmarkNodeData(); | 597 router->ClearBookmarkNodeData(); |
| 598 return true; | 598 return true; |
| 599 } else { | 599 } else { |
| 600 NOTREACHED(); | 600 NOTREACHED(); |
| 601 return false; | 601 return false; |
| 602 } | 602 } |
| 603 } | 603 } |
| 604 | 604 |
| 605 bool BookmarkManagerPrivateGetSubtreeFunction::RunImpl() { | 605 bool BookmarkManagerPrivateGetSubtreeFunction::RunOnReady() { |
| 606 scoped_ptr<GetSubtree::Params> params(GetSubtree::Params::Create(*args_)); | 606 scoped_ptr<GetSubtree::Params> params(GetSubtree::Params::Create(*args_)); |
| 607 EXTENSION_FUNCTION_VALIDATE(params); | 607 EXTENSION_FUNCTION_VALIDATE(params); |
| 608 | 608 |
| 609 const BookmarkNode* node = NULL; | 609 const BookmarkNode* node = NULL; |
| 610 | 610 |
| 611 if (params->id == "") { | 611 if (params->id == "") { |
| 612 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 612 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 613 node = model->root_node(); | 613 node = model->root_node(); |
| 614 } else { | 614 } else { |
| 615 node = GetBookmarkNodeFromId(params->id); | 615 node = GetBookmarkNodeFromId(params->id); |
| 616 if (!node) | 616 if (!node) |
| 617 return false; | 617 return false; |
| 618 } | 618 } |
| 619 | 619 |
| 620 std::vector<linked_ptr<api::bookmarks::BookmarkTreeNode> > nodes; | 620 std::vector<linked_ptr<api::bookmarks::BookmarkTreeNode> > nodes; |
| 621 if (params->folders_only) | 621 if (params->folders_only) |
| 622 bookmark_api_helpers::AddNodeFoldersOnly(node, &nodes, true); | 622 bookmark_api_helpers::AddNodeFoldersOnly(node, &nodes, true); |
| 623 else | 623 else |
| 624 bookmark_api_helpers::AddNode(node, &nodes, true); | 624 bookmark_api_helpers::AddNode(node, &nodes, true); |
| 625 results_ = GetSubtree::Results::Create(nodes); | 625 results_ = GetSubtree::Results::Create(nodes); |
| 626 return true; | 626 return true; |
| 627 } | 627 } |
| 628 | 628 |
| 629 bool BookmarkManagerPrivateCanEditFunction::RunImpl() { | 629 bool BookmarkManagerPrivateCanEditFunction::RunOnReady() { |
| 630 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); | 630 PrefService* prefs = user_prefs::UserPrefs::Get(GetProfile()); |
| 631 SetResult(new base::FundamentalValue( | 631 SetResult(new base::FundamentalValue( |
| 632 prefs->GetBoolean(prefs::kEditBookmarksEnabled))); | 632 prefs->GetBoolean(prefs::kEditBookmarksEnabled))); |
| 633 return true; | 633 return true; |
| 634 } | 634 } |
| 635 | 635 |
| 636 bool BookmarkManagerPrivateRecordLaunchFunction::RunImpl() { | 636 bool BookmarkManagerPrivateRecordLaunchFunction::RunOnReady() { |
| 637 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_MANAGER); | 637 RecordBookmarkLaunch(NULL, BOOKMARK_LAUNCH_LOCATION_MANAGER); |
| 638 return true; | 638 return true; |
| 639 } | 639 } |
| 640 | 640 |
| 641 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunImpl() { | 641 bool BookmarkManagerPrivateCreateWithMetaInfoFunction::RunOnReady() { |
| 642 scoped_ptr<CreateWithMetaInfo::Params> params( | 642 scoped_ptr<CreateWithMetaInfo::Params> params( |
| 643 CreateWithMetaInfo::Params::Create(*args_)); | 643 CreateWithMetaInfo::Params::Create(*args_)); |
| 644 EXTENSION_FUNCTION_VALIDATE(params); | 644 EXTENSION_FUNCTION_VALIDATE(params); |
| 645 | 645 |
| 646 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 646 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 647 const BookmarkNode* node = CreateBookmarkNode( | 647 const BookmarkNode* node = CreateBookmarkNode( |
| 648 model, params->bookmark, ¶ms->meta_info.additional_properties); | 648 model, params->bookmark, ¶ms->meta_info.additional_properties); |
| 649 if (!node) | 649 if (!node) |
| 650 return false; | 650 return false; |
| 651 | 651 |
| 652 scoped_ptr<api::bookmarks::BookmarkTreeNode> result_node( | 652 scoped_ptr<api::bookmarks::BookmarkTreeNode> result_node( |
| 653 bookmark_api_helpers::GetBookmarkTreeNode(node, false, false)); | 653 bookmark_api_helpers::GetBookmarkTreeNode(node, false, false)); |
| 654 results_ = CreateWithMetaInfo::Results::Create(*result_node); | 654 results_ = CreateWithMetaInfo::Results::Create(*result_node); |
| 655 | 655 |
| 656 return true; | 656 return true; |
| 657 } | 657 } |
| 658 | 658 |
| 659 bool BookmarkManagerPrivateGetMetaInfoFunction::RunImpl() { | 659 bool BookmarkManagerPrivateGetMetaInfoFunction::RunOnReady() { |
| 660 scoped_ptr<GetMetaInfo::Params> params(GetMetaInfo::Params::Create(*args_)); | 660 scoped_ptr<GetMetaInfo::Params> params(GetMetaInfo::Params::Create(*args_)); |
| 661 EXTENSION_FUNCTION_VALIDATE(params); | 661 EXTENSION_FUNCTION_VALIDATE(params); |
| 662 | 662 |
| 663 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); | 663 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); |
| 664 if (!node) | 664 if (!node) |
| 665 return false; | 665 return false; |
| 666 | 666 |
| 667 if (params->key) { | 667 if (params->key) { |
| 668 std::string value; | 668 std::string value; |
| 669 if (node->GetMetaInfo(*params->key, &value)) { | 669 if (node->GetMetaInfo(*params->key, &value)) { |
| 670 GetMetaInfo::Results::Value result; | 670 GetMetaInfo::Results::Value result; |
| 671 result.as_string.reset(new std::string(value)); | 671 result.as_string.reset(new std::string(value)); |
| 672 results_ = GetMetaInfo::Results::Create(result); | 672 results_ = GetMetaInfo::Results::Create(result); |
| 673 } | 673 } |
| 674 } else { | 674 } else { |
| 675 GetMetaInfo::Results::Value result; | 675 GetMetaInfo::Results::Value result; |
| 676 result.as_meta_info_fields.reset( | 676 result.as_meta_info_fields.reset( |
| 677 new bookmark_manager_private::MetaInfoFields); | 677 new bookmark_manager_private::MetaInfoFields); |
| 678 | 678 |
| 679 const BookmarkNode::MetaInfoMap* meta_info = node->GetMetaInfoMap(); | 679 const BookmarkNode::MetaInfoMap* meta_info = node->GetMetaInfoMap(); |
| 680 if (meta_info) | 680 if (meta_info) |
| 681 result.as_meta_info_fields->additional_properties = *meta_info; | 681 result.as_meta_info_fields->additional_properties = *meta_info; |
| 682 results_ = GetMetaInfo::Results::Create(result); | 682 results_ = GetMetaInfo::Results::Create(result); |
| 683 } | 683 } |
| 684 | 684 |
| 685 return true; | 685 return true; |
| 686 } | 686 } |
| 687 | 687 |
| 688 bool BookmarkManagerPrivateSetMetaInfoFunction::RunImpl() { | 688 bool BookmarkManagerPrivateSetMetaInfoFunction::RunOnReady() { |
| 689 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); | 689 scoped_ptr<SetMetaInfo::Params> params(SetMetaInfo::Params::Create(*args_)); |
| 690 EXTENSION_FUNCTION_VALIDATE(params); | 690 EXTENSION_FUNCTION_VALIDATE(params); |
| 691 | 691 |
| 692 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); | 692 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); |
| 693 if (!node) | 693 if (!node) |
| 694 return false; | 694 return false; |
| 695 | 695 |
| 696 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 696 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 697 model->SetNodeMetaInfo(node, params->key, params->value); | 697 model->SetNodeMetaInfo(node, params->key, params->value); |
| 698 return true; | 698 return true; |
| 699 } | 699 } |
| 700 | 700 |
| 701 bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunImpl() { | 701 bool BookmarkManagerPrivateUpdateMetaInfoFunction::RunOnReady() { |
| 702 scoped_ptr<UpdateMetaInfo::Params> params( | 702 scoped_ptr<UpdateMetaInfo::Params> params( |
| 703 UpdateMetaInfo::Params::Create(*args_)); | 703 UpdateMetaInfo::Params::Create(*args_)); |
| 704 EXTENSION_FUNCTION_VALIDATE(params); | 704 EXTENSION_FUNCTION_VALIDATE(params); |
| 705 | 705 |
| 706 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); | 706 const BookmarkNode* node = GetBookmarkNodeFromId(params->id); |
| 707 if (!node) | 707 if (!node) |
| 708 return false; | 708 return false; |
| 709 | 709 |
| 710 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 710 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 711 BookmarkNode::MetaInfoMap new_meta_info( | 711 BookmarkNode::MetaInfoMap new_meta_info( |
| 712 params->meta_info_changes.additional_properties); | 712 params->meta_info_changes.additional_properties); |
| 713 if (node->GetMetaInfoMap()) { | 713 if (node->GetMetaInfoMap()) { |
| 714 new_meta_info.insert(node->GetMetaInfoMap()->begin(), | 714 new_meta_info.insert(node->GetMetaInfoMap()->begin(), |
| 715 node->GetMetaInfoMap()->end()); | 715 node->GetMetaInfoMap()->end()); |
| 716 } | 716 } |
| 717 model->SetNodeMetaInfoMap(node, new_meta_info); | 717 model->SetNodeMetaInfoMap(node, new_meta_info); |
| 718 | 718 |
| 719 return true; | 719 return true; |
| 720 } | 720 } |
| 721 | 721 |
| 722 bool BookmarkManagerPrivateCanOpenNewWindowsFunction::RunImpl() { | 722 bool BookmarkManagerPrivateCanOpenNewWindowsFunction::RunOnReady() { |
| 723 bool can_open_new_windows = true; | 723 bool can_open_new_windows = true; |
| 724 SetResult(new base::FundamentalValue(can_open_new_windows)); | 724 SetResult(new base::FundamentalValue(can_open_new_windows)); |
| 725 return true; | 725 return true; |
| 726 } | 726 } |
| 727 | 727 |
| 728 bool BookmarkManagerPrivateRemoveTreesFunction::RunImpl() { | 728 bool BookmarkManagerPrivateRemoveTreesFunction::RunOnReady() { |
| 729 scoped_ptr<RemoveTrees::Params> params(RemoveTrees::Params::Create(*args_)); | 729 scoped_ptr<RemoveTrees::Params> params(RemoveTrees::Params::Create(*args_)); |
| 730 EXTENSION_FUNCTION_VALIDATE(params); | 730 EXTENSION_FUNCTION_VALIDATE(params); |
| 731 | 731 |
| 732 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); | 732 BookmarkModel* model = BookmarkModelFactory::GetForProfile(GetProfile()); |
| 733 #if !defined(OS_ANDROID) | 733 #if !defined(OS_ANDROID) |
| 734 ScopedGroupBookmarkActions group_deletes(model); | 734 ScopedGroupBookmarkActions group_deletes(model); |
| 735 #endif | 735 #endif |
| 736 int64 id; | 736 int64 id; |
| 737 for (size_t i = 0; i < params->id_list.size(); ++i) { | 737 for (size_t i = 0; i < params->id_list.size(); ++i) { |
| 738 if (!GetBookmarkIdAsInt64(params->id_list[i], &id)) | 738 if (!GetBookmarkIdAsInt64(params->id_list[i], &id)) |
| 739 return false; | 739 return false; |
| 740 if (!bookmark_api_helpers::RemoveNode(model, id, true, &error_)) | 740 if (!bookmark_api_helpers::RemoveNode(model, id, true, &error_)) |
| 741 return false; | 741 return false; |
| 742 } | 742 } |
| 743 | 743 |
| 744 return true; | 744 return true; |
| 745 } | 745 } |
| 746 | 746 |
| 747 bool BookmarkManagerPrivateUndoFunction::RunImpl() { | 747 bool BookmarkManagerPrivateUndoFunction::RunOnReady() { |
| 748 #if !defined(OS_ANDROID) | 748 #if !defined(OS_ANDROID) |
| 749 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> | 749 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> |
| 750 Undo(); | 750 Undo(); |
| 751 #endif | 751 #endif |
| 752 | 752 |
| 753 return true; | 753 return true; |
| 754 } | 754 } |
| 755 | 755 |
| 756 bool BookmarkManagerPrivateRedoFunction::RunImpl() { | 756 bool BookmarkManagerPrivateRedoFunction::RunOnReady() { |
| 757 #if !defined(OS_ANDROID) | 757 #if !defined(OS_ANDROID) |
| 758 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> | 758 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> |
| 759 Redo(); | 759 Redo(); |
| 760 #endif | 760 #endif |
| 761 | 761 |
| 762 return true; | 762 return true; |
| 763 } | 763 } |
| 764 | 764 |
| 765 bool BookmarkManagerPrivateGetUndoInfoFunction::RunImpl() { | 765 bool BookmarkManagerPrivateGetUndoInfoFunction::RunOnReady() { |
| 766 #if !defined(OS_ANDROID) | 766 #if !defined(OS_ANDROID) |
| 767 UndoManager* undo_manager = | 767 UndoManager* undo_manager = |
| 768 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); | 768 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); |
| 769 | 769 |
| 770 UndoInfo::Results::Result result; | 770 UndoInfo::Results::Result result; |
| 771 result.enabled = undo_manager->undo_count() > 0; | 771 result.enabled = undo_manager->undo_count() > 0; |
| 772 result.label = base::UTF16ToUTF8(undo_manager->GetUndoLabel()); | 772 result.label = base::UTF16ToUTF8(undo_manager->GetUndoLabel()); |
| 773 | 773 |
| 774 results_ = UndoInfo::Results::Create(result); | 774 results_ = UndoInfo::Results::Create(result); |
| 775 #endif // !defined(OS_ANDROID) | 775 #endif // !defined(OS_ANDROID) |
| 776 | 776 |
| 777 return true; | 777 return true; |
| 778 } | 778 } |
| 779 | 779 |
| 780 bool BookmarkManagerPrivateGetRedoInfoFunction::RunImpl() { | 780 bool BookmarkManagerPrivateGetRedoInfoFunction::RunOnReady() { |
| 781 #if !defined(OS_ANDROID) | 781 #if !defined(OS_ANDROID) |
| 782 UndoManager* undo_manager = | 782 UndoManager* undo_manager = |
| 783 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); | 783 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); |
| 784 | 784 |
| 785 RedoInfo::Results::Result result; | 785 RedoInfo::Results::Result result; |
| 786 result.enabled = undo_manager->redo_count() > 0; | 786 result.enabled = undo_manager->redo_count() > 0; |
| 787 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); | 787 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); |
| 788 | 788 |
| 789 results_ = RedoInfo::Results::Create(result); | 789 results_ = RedoInfo::Results::Create(result); |
| 790 #endif // !defined(OS_ANDROID) | 790 #endif // !defined(OS_ANDROID) |
| 791 | 791 |
| 792 return true; | 792 return true; |
| 793 } | 793 } |
| 794 | 794 |
| 795 } // namespace extensions | 795 } // namespace extensions |
| OLD | NEW |