Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: components/ntp_snippets/category_factory.cc

Issue 2228553003: a provider of Physical Web pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added unittest Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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::OFFLINE_PAGES); 15 AddKnownCategory(KnownCategories::OFFLINE_PAGES);
16 AddKnownCategory(KnownCategories::BOOKMARKS); 16 AddKnownCategory(KnownCategories::BOOKMARKS);
17 AddKnownCategory(KnownCategories::PHYSICAL_WEB_PAGES);
Marc Treib 2016/08/10 16:22:03 Have we decided on an order here?
tschumann 2016/08/10 17:37:57 hehe... we should clarify the comment above and ma
vitaliii 2016/08/11 12:15:24 If I understand right and this order defines the o
Marc Treib 2016/08/11 12:53:09 That sounds reasonable, but for M54 we're going wi
vitaliii 2016/08/11 14:29:58 Acknowledged.
17 } 18 }
18 19
19 CategoryFactory::~CategoryFactory() {} 20 CategoryFactory::~CategoryFactory() {}
20 21
21 Category CategoryFactory::FromKnownCategory(KnownCategories known_category) { 22 Category CategoryFactory::FromKnownCategory(KnownCategories known_category) {
22 if (known_category < KnownCategories::LOCAL_CATEGORIES_COUNT) { 23 if (known_category < KnownCategories::LOCAL_CATEGORIES_COUNT) {
23 // Local categories should have been added already. 24 // Local categories should have been added already.
24 DCHECK(CategoryExists(static_cast<int>(known_category))); 25 DCHECK(CategoryExists(static_cast<int>(known_category)));
25 } else { 26 } else {
26 DCHECK_GT(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET); 27 DCHECK_GT(known_category, KnownCategories::REMOTE_CATEGORIES_OFFSET);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 Category(id)); 69 Category(id));
69 if (it != ordered_categories_.end()) 70 if (it != ordered_categories_.end())
70 return *it; 71 return *it;
71 72
72 Category category(id); 73 Category category(id);
73 ordered_categories_.push_back(category); 74 ordered_categories_.push_back(category);
74 return category; 75 return category;
75 } 76 }
76 77
77 } // namespace ntp_snippets 78 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698