OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/ntp_snippets/category_factory.h" | 5 #include "components/ntp_snippets/category_factory.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 AddKnownCategory(KnownCategories::DOWNLOADS); | 24 AddKnownCategory(KnownCategories::DOWNLOADS); |
25 AddKnownCategory(KnownCategories::RECENT_TABS); | 25 AddKnownCategory(KnownCategories::RECENT_TABS); |
26 AddKnownCategory(KnownCategories::FOREIGN_TABS); | 26 AddKnownCategory(KnownCategories::FOREIGN_TABS); |
27 AddKnownCategory(KnownCategories::BOOKMARKS); | 27 AddKnownCategory(KnownCategories::BOOKMARKS); |
28 AddKnownCategory(KnownCategories::PHYSICAL_WEB_PAGES); | 28 AddKnownCategory(KnownCategories::PHYSICAL_WEB_PAGES); |
29 | 29 |
30 DCHECK_EQ(static_cast<size_t>(KnownCategories::LOCAL_CATEGORIES_COUNT), | 30 DCHECK_EQ(static_cast<size_t>(KnownCategories::LOCAL_CATEGORIES_COUNT), |
31 ordered_categories_.size()); | 31 ordered_categories_.size()); |
32 } | 32 } |
33 | 33 |
34 CategoryFactory::~CategoryFactory() {} | 34 CategoryFactory::~CategoryFactory() = default; |
35 | 35 |
36 Category CategoryFactory::FromKnownCategory(KnownCategories known_category) { | 36 Category CategoryFactory::FromKnownCategory(KnownCategories known_category) { |
37 if (known_category < KnownCategories::LOCAL_CATEGORIES_COUNT) { | 37 if (known_category < KnownCategories::LOCAL_CATEGORIES_COUNT) { |
38 // Local categories should have been added already. | 38 // Local categories should have been added already. |
39 DCHECK(CategoryExists(static_cast<int>(known_category))); | 39 DCHECK(CategoryExists(static_cast<int>(known_category))); |
40 } else { | 40 } else { |
41 DCHECK_GT(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET); | 41 DCHECK_GT(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET); |
42 } | 42 } |
43 return InternalFromID(static_cast<int>(known_category)); | 43 return InternalFromID(static_cast<int>(known_category)); |
44 } | 44 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 Category(id)); | 109 Category(id)); |
110 if (it != ordered_categories_.end()) | 110 if (it != ordered_categories_.end()) |
111 return *it; | 111 return *it; |
112 | 112 |
113 Category category(id); | 113 Category category(id); |
114 ordered_categories_.push_back(category); | 114 ordered_categories_.push_back(category); |
115 return category; | 115 return category; |
116 } | 116 } |
117 | 117 |
118 } // namespace ntp_snippets | 118 } // namespace ntp_snippets |
OLD | NEW |