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 | 10 |
| 11 namespace ntp_snippets { | 11 namespace ntp_snippets { |
| 12 | 12 |
| 13 CategoryFactory::CategoryFactory() { | 13 CategoryFactory::CategoryFactory() { |
| 14 // Add all local categories in a fixed order. | 14 // Add all local categories in a fixed order. |
| 15 AddKnownCategory(KnownCategories::DOWNLOADS); | 15 AddKnownCategory(KnownCategories::DOWNLOADS); |
| 16 AddKnownCategory(KnownCategories::RECENT_TABS); | 16 AddKnownCategory(KnownCategories::RECENT_TABS); |
| 17 AddKnownCategory(KnownCategories::BOOKMARKS); | 17 AddKnownCategory(KnownCategories::BOOKMARKS); |
| 18 AddKnownCategory(KnownCategories::PHYSICAL_WEB_PAGES); | 18 AddKnownCategory(KnownCategories::PHYSICAL_WEB_PAGES); |
| 19 AddKnownCategory(KnownCategories::FOREIGN_TABS); | |
|
Marc Treib
2016/08/29 09:18:50
Have we decided on an order here? I think we might
skym
2016/09/15 23:18:17
I don't think there's been any thought/agreement o
| |
| 19 } | 20 } |
| 20 | 21 |
| 21 CategoryFactory::~CategoryFactory() {} | 22 CategoryFactory::~CategoryFactory() {} |
| 22 | 23 |
| 23 Category CategoryFactory::FromKnownCategory(KnownCategories known_category) { | 24 Category CategoryFactory::FromKnownCategory(KnownCategories known_category) { |
| 24 if (known_category < KnownCategories::LOCAL_CATEGORIES_COUNT) { | 25 if (known_category < KnownCategories::LOCAL_CATEGORIES_COUNT) { |
| 25 // Local categories should have been added already. | 26 // Local categories should have been added already. |
| 26 DCHECK(CategoryExists(static_cast<int>(known_category))); | 27 DCHECK(CategoryExists(static_cast<int>(known_category))); |
| 27 } else { | 28 } else { |
| 28 DCHECK_GT(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET); | 29 DCHECK_GT(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 Category(id)); | 71 Category(id)); |
| 71 if (it != ordered_categories_.end()) | 72 if (it != ordered_categories_.end()) |
| 72 return *it; | 73 return *it; |
| 73 | 74 |
| 74 Category category(id); | 75 Category category(id); |
| 75 ordered_categories_.push_back(category); | 76 ordered_categories_.push_back(category); |
| 76 return category; | 77 return category; |
| 77 } | 78 } |
| 78 | 79 |
| 79 } // namespace ntp_snippets | 80 } // namespace ntp_snippets |
| OLD | NEW |