| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 if (!base::StringToInt64(id_string, &id)) | 72 if (!base::StringToInt64(id_string, &id)) |
| 73 return NULL; | 73 return NULL; |
| 74 return GetBookmarkNodeByID(model, id); | 74 return GetBookmarkNodeByID(model, id); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Gets a vector of bookmark nodes from the argument list of IDs. | 77 // Gets a vector of bookmark nodes from the argument list of IDs. |
| 78 // This returns false in the case of failure. | 78 // This returns false in the case of failure. |
| 79 bool GetNodesFromVector(BookmarkModel* model, | 79 bool GetNodesFromVector(BookmarkModel* model, |
| 80 const std::vector<std::string>& id_strings, | 80 const std::vector<std::string>& id_strings, |
| 81 std::vector<const BookmarkNode*>* nodes) { | 81 std::vector<const BookmarkNode*>* nodes) { |
| 82 | |
| 83 if (id_strings.empty()) | 82 if (id_strings.empty()) |
| 84 return false; | 83 return false; |
| 85 | 84 |
| 86 for (size_t i = 0; i < id_strings.size(); ++i) { | 85 for (size_t i = 0; i < id_strings.size(); ++i) { |
| 87 const BookmarkNode* node = GetNodeFromString(model, id_strings[i]); | 86 const BookmarkNode* node = GetNodeFromString(model, id_strings[i]); |
| 88 if (!node) | 87 if (!node) |
| 89 return false; | 88 return false; |
| 90 nodes->push_back(node); | 89 nodes->push_back(node); |
| 91 } | 90 } |
| 92 | 91 |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 SetResult(new base::FundamentalValue(can_open_new_windows)); | 751 SetResult(new base::FundamentalValue(can_open_new_windows)); |
| 753 return true; | 752 return true; |
| 754 } | 753 } |
| 755 | 754 |
| 756 bool BookmarkManagerPrivateRemoveTreesFunction::RunOnReady() { | 755 bool BookmarkManagerPrivateRemoveTreesFunction::RunOnReady() { |
| 757 scoped_ptr<RemoveTrees::Params> params(RemoveTrees::Params::Create(*args_)); | 756 scoped_ptr<RemoveTrees::Params> params(RemoveTrees::Params::Create(*args_)); |
| 758 EXTENSION_FUNCTION_VALIDATE(params); | 757 EXTENSION_FUNCTION_VALIDATE(params); |
| 759 | 758 |
| 760 BookmarkModel* model = GetBookmarkModel(); | 759 BookmarkModel* model = GetBookmarkModel(); |
| 761 ChromeBookmarkClient* client = GetChromeBookmarkClient(); | 760 ChromeBookmarkClient* client = GetChromeBookmarkClient(); |
| 762 #if !defined(OS_ANDROID) | |
| 763 bookmarks::ScopedGroupBookmarkActions group_deletes(model); | 761 bookmarks::ScopedGroupBookmarkActions group_deletes(model); |
| 764 #endif | |
| 765 int64 id; | 762 int64 id; |
| 766 for (size_t i = 0; i < params->id_list.size(); ++i) { | 763 for (size_t i = 0; i < params->id_list.size(); ++i) { |
| 767 if (!GetBookmarkIdAsInt64(params->id_list[i], &id)) | 764 if (!GetBookmarkIdAsInt64(params->id_list[i], &id)) |
| 768 return false; | 765 return false; |
| 769 if (!bookmark_api_helpers::RemoveNode(model, client, id, true, &error_)) | 766 if (!bookmark_api_helpers::RemoveNode(model, client, id, true, &error_)) |
| 770 return false; | 767 return false; |
| 771 } | 768 } |
| 772 | 769 |
| 773 return true; | 770 return true; |
| 774 } | 771 } |
| 775 | 772 |
| 776 bool BookmarkManagerPrivateUndoFunction::RunOnReady() { | 773 bool BookmarkManagerPrivateUndoFunction::RunOnReady() { |
| 777 #if !defined(OS_ANDROID) | |
| 778 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> | 774 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> |
| 779 Undo(); | 775 Undo(); |
| 780 #endif | |
| 781 | |
| 782 return true; | 776 return true; |
| 783 } | 777 } |
| 784 | 778 |
| 785 bool BookmarkManagerPrivateRedoFunction::RunOnReady() { | 779 bool BookmarkManagerPrivateRedoFunction::RunOnReady() { |
| 786 #if !defined(OS_ANDROID) | |
| 787 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> | 780 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager()-> |
| 788 Redo(); | 781 Redo(); |
| 789 #endif | |
| 790 | |
| 791 return true; | 782 return true; |
| 792 } | 783 } |
| 793 | 784 |
| 794 bool BookmarkManagerPrivateGetUndoInfoFunction::RunOnReady() { | 785 bool BookmarkManagerPrivateGetUndoInfoFunction::RunOnReady() { |
| 795 #if !defined(OS_ANDROID) | |
| 796 UndoManager* undo_manager = | 786 UndoManager* undo_manager = |
| 797 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); | 787 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); |
| 798 | 788 |
| 799 UndoInfo::Results::Result result; | 789 UndoInfo::Results::Result result; |
| 800 result.enabled = undo_manager->undo_count() > 0; | 790 result.enabled = undo_manager->undo_count() > 0; |
| 801 result.label = base::UTF16ToUTF8(undo_manager->GetUndoLabel()); | 791 result.label = base::UTF16ToUTF8(undo_manager->GetUndoLabel()); |
| 802 | 792 |
| 803 results_ = UndoInfo::Results::Create(result); | 793 results_ = UndoInfo::Results::Create(result); |
| 804 #endif // !defined(OS_ANDROID) | |
| 805 | |
| 806 return true; | 794 return true; |
| 807 } | 795 } |
| 808 | 796 |
| 809 bool BookmarkManagerPrivateGetRedoInfoFunction::RunOnReady() { | 797 bool BookmarkManagerPrivateGetRedoInfoFunction::RunOnReady() { |
| 810 #if !defined(OS_ANDROID) | |
| 811 UndoManager* undo_manager = | 798 UndoManager* undo_manager = |
| 812 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); | 799 BookmarkUndoServiceFactory::GetForProfile(GetProfile())->undo_manager(); |
| 813 | 800 |
| 814 RedoInfo::Results::Result result; | 801 RedoInfo::Results::Result result; |
| 815 result.enabled = undo_manager->redo_count() > 0; | 802 result.enabled = undo_manager->redo_count() > 0; |
| 816 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); | 803 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); |
| 817 | 804 |
| 818 results_ = RedoInfo::Results::Create(result); | 805 results_ = RedoInfo::Results::Create(result); |
| 819 #endif // !defined(OS_ANDROID) | |
| 820 | |
| 821 return true; | 806 return true; |
| 822 } | 807 } |
| 823 | 808 |
| 824 } // namespace extensions | 809 } // namespace extensions |
| OLD | NEW |