Chromium Code Reviews| 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" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 | 12 |
| 13 namespace ntp_snippets { | 13 namespace ntp_snippets { |
| 14 | 14 |
| 15 CategoryFactory::CategoryFactory() { | 15 CategoryFactory::CategoryFactory() { |
| 16 // Add all local categories in a fixed order. | 16 // Add all local categories in a fixed order. |
| 17 AddKnownCategory(KnownCategories::DOWNLOADS); | 17 AddKnownCategory(KnownCategories::DOWNLOADS); |
| 18 AddKnownCategory(KnownCategories::RECENT_TABS); | 18 AddKnownCategory(KnownCategories::RECENT_TABS); |
| 19 AddKnownCategory(KnownCategories::FOREIGN_TABS); | 19 AddKnownCategory(KnownCategories::FOREIGN_TABS); |
| 20 AddKnownCategory(KnownCategories::BOOKMARKS); | 20 AddKnownCategory(KnownCategories::BOOKMARKS); |
| 21 AddKnownCategory(KnownCategories::PHYSICAL_WEB_PAGES); | 21 AddKnownCategory(KnownCategories::PHYSICAL_WEB_PAGES); |
| 22 | 22 |
| 23 DCHECK_EQ(static_cast<size_t>(KnownCategories::LOCAL_CATEGORIES_COUNT), | 23 DCHECK_EQ(static_cast<size_t>(KnownCategories::LOCAL_CATEGORIES_COUNT), |
| 24 ordered_categories_.size()); | 24 ordered_categories_.size()); |
| 25 | |
| 26 AddKnownCategory(KnownCategories::ARTICLES); | |
|
dgn
2016/10/13 14:46:51
Added to keep the articles as the first remote sec
Marc Treib
2016/10/13 15:59:00
Please add a comment saying this :)
| |
| 25 } | 27 } |
| 26 | 28 |
| 27 CategoryFactory::~CategoryFactory() = default; | 29 CategoryFactory::~CategoryFactory() = default; |
| 28 | 30 |
| 29 Category CategoryFactory::FromKnownCategory(KnownCategories known_category) { | 31 Category CategoryFactory::FromKnownCategory(KnownCategories known_category) { |
| 30 if (known_category < KnownCategories::LOCAL_CATEGORIES_COUNT) { | 32 if (known_category < KnownCategories::LOCAL_CATEGORIES_COUNT) { |
| 31 // Local categories should have been added already. | 33 // Local categories should have been added already. |
| 32 DCHECK(CategoryExists(static_cast<int>(known_category))); | 34 DCHECK(CategoryExists(static_cast<int>(known_category))); |
| 33 } else { | 35 } else { |
| 34 DCHECK_GT(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET); | 36 DCHECK_GT(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 Category(id)); | 78 Category(id)); |
| 77 if (it != ordered_categories_.end()) | 79 if (it != ordered_categories_.end()) |
| 78 return *it; | 80 return *it; |
| 79 | 81 |
| 80 Category category(id); | 82 Category category(id); |
| 81 ordered_categories_.push_back(category); | 83 ordered_categories_.push_back(category); |
| 82 return category; | 84 return category; |
| 83 } | 85 } |
| 84 | 86 |
| 85 } // namespace ntp_snippets | 87 } // namespace ntp_snippets |
| OLD | NEW |