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/bookmarks/bookmarks_api.h" | 5 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 std::map<BucketIdType, Bucket*> buckets_; | 716 std::map<BucketIdType, Bucket*> buckets_; |
717 }; | 717 }; |
718 | 718 |
719 // Mapper for 'bookmarks.create'. Maps "same input to bookmarks.create" to a | 719 // Mapper for 'bookmarks.create'. Maps "same input to bookmarks.create" to a |
720 // unique bucket. | 720 // unique bucket. |
721 class CreateBookmarkBucketMapper : public BookmarkBucketMapper<std::string> { | 721 class CreateBookmarkBucketMapper : public BookmarkBucketMapper<std::string> { |
722 public: | 722 public: |
723 explicit CreateBookmarkBucketMapper(Profile* profile) : profile_(profile) {} | 723 explicit CreateBookmarkBucketMapper(Profile* profile) : profile_(profile) {} |
724 // TODO(tim): This should share code with BookmarksCreateFunction::RunImpl, | 724 // TODO(tim): This should share code with BookmarksCreateFunction::RunImpl, |
725 // but I can't figure out a good way to do that with all the macros. | 725 // but I can't figure out a good way to do that with all the macros. |
726 virtual void GetBucketsForArgs(const ListValue* args, BucketList* buckets) { | 726 virtual void GetBucketsForArgs(const ListValue* args, |
| 727 BucketList* buckets) OVERRIDE { |
727 const DictionaryValue* json; | 728 const DictionaryValue* json; |
728 if (!args->GetDictionary(0, &json)) | 729 if (!args->GetDictionary(0, &json)) |
729 return; | 730 return; |
730 | 731 |
731 std::string parent_id; | 732 std::string parent_id; |
732 if (json->HasKey(keys::kParentIdKey)) { | 733 if (json->HasKey(keys::kParentIdKey)) { |
733 if (!json->GetString(keys::kParentIdKey, &parent_id)) | 734 if (!json->GetString(keys::kParentIdKey, &parent_id)) |
734 return; | 735 return; |
735 } | 736 } |
736 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); | 737 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); |
(...skipping 17 matching lines...) Expand all Loading... |
754 buckets->push_back(GetBucket(base::SHA1HashString(bucket_id))); | 755 buckets->push_back(GetBucket(base::SHA1HashString(bucket_id))); |
755 } | 756 } |
756 private: | 757 private: |
757 Profile* profile_; | 758 Profile* profile_; |
758 }; | 759 }; |
759 | 760 |
760 // Mapper for 'bookmarks.remove'. | 761 // Mapper for 'bookmarks.remove'. |
761 class RemoveBookmarksBucketMapper : public BookmarkBucketMapper<std::string> { | 762 class RemoveBookmarksBucketMapper : public BookmarkBucketMapper<std::string> { |
762 public: | 763 public: |
763 explicit RemoveBookmarksBucketMapper(Profile* profile) : profile_(profile) {} | 764 explicit RemoveBookmarksBucketMapper(Profile* profile) : profile_(profile) {} |
764 virtual void GetBucketsForArgs(const ListValue* args, BucketList* buckets) { | 765 virtual void GetBucketsForArgs(const ListValue* args, |
| 766 BucketList* buckets) OVERRIDE { |
765 typedef std::list<int64> IdList; | 767 typedef std::list<int64> IdList; |
766 IdList ids; | 768 IdList ids; |
767 bool invalid_id = false; | 769 bool invalid_id = false; |
768 if (!BookmarksRemoveFunction::ExtractIds(args, &ids, &invalid_id) || | 770 if (!BookmarksRemoveFunction::ExtractIds(args, &ids, &invalid_id) || |
769 invalid_id) { | 771 invalid_id) { |
770 return; | 772 return; |
771 } | 773 } |
772 | 774 |
773 for (IdList::iterator it = ids.begin(); it != ids.end(); ++it) { | 775 for (IdList::iterator it = ids.begin(); it != ids.end(); ++it) { |
774 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); | 776 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 #if !defined(OS_ANDROID) | 991 #if !defined(OS_ANDROID) |
990 // Android does not have support for the standard exporter. | 992 // Android does not have support for the standard exporter. |
991 // TODO(jgreenwald): remove ifdef once extensions are no longer built on | 993 // TODO(jgreenwald): remove ifdef once extensions are no longer built on |
992 // Android. | 994 // Android. |
993 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); | 995 bookmark_html_writer::WriteBookmarks(profile(), path, NULL); |
994 #endif | 996 #endif |
995 Release(); // Balanced in BookmarksIOFunction::SelectFile() | 997 Release(); // Balanced in BookmarksIOFunction::SelectFile() |
996 } | 998 } |
997 | 999 |
998 } // namespace extensions | 1000 } // namespace extensions |
OLD | NEW |