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 #ifndef COMPONENTS_NTP_SNIPPETS_CATEGORY_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_CATEGORY_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_CATEGORY_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_CATEGORY_H_ |
| 7 | 7 |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 | 9 |
| 10 namespace ntp_snippets { | 10 namespace ntp_snippets { |
| 11 | 11 |
| 12 class CategoryFactory; | 12 class CategoryFactory; |
| 13 | 13 |
| 14 // These are the categories that the client knows about. | 14 // These are the categories that the client knows about. |
| 15 // The values before LOCAL_CATEGORIES_COUNT are the categories that are provided | 15 // The values before LOCAL_CATEGORIES_COUNT are the categories that are provided |
| 16 // locally on the device. Categories provided by the server (IDs strictly larger | 16 // locally on the device. Categories provided by the server (IDs strictly larger |
| 17 // than REMOTE_CATEGORIES_OFFSET) only need to be hard-coded here if they need | 17 // than REMOTE_CATEGORIES_OFFSET) only need to be hard-coded here if they need |
| 18 // to be recognized by the client implementation. | 18 // to be recognized by the client implementation. |
| 19 // NOTE: If you add an entry here, also add it to |IsAnyKnownCategory|. | |
| 19 // On Android builds, a Java counterpart will be generated for this enum. | 20 // On Android builds, a Java counterpart will be generated for this enum. |
| 20 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ntp.snippets | 21 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ntp.snippets |
| 21 enum class KnownCategories { | 22 enum class KnownCategories { |
| 22 // Pages recently downloaded during normal navigation. | 23 // Pages recently downloaded during normal navigation. |
| 23 RECENT_TABS, | 24 RECENT_TABS, |
| 24 | 25 |
| 25 // Pages downloaded by the user for offline consumption. | 26 // Pages downloaded by the user for offline consumption. |
| 26 DOWNLOADS, | 27 DOWNLOADS, |
| 27 | 28 |
| 28 // Recently used bookmarks. | 29 // Recently used bookmarks. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 48 // a std::map, but should not be used to order categories for other purposes. | 49 // a std::map, but should not be used to order categories for other purposes. |
| 49 struct CompareByID; | 50 struct CompareByID; |
| 50 | 51 |
| 51 // Returns a non-negative identifier that is unique for the category and can | 52 // Returns a non-negative identifier that is unique for the category and can |
| 52 // be converted back to a Category instance using | 53 // be converted back to a Category instance using |
| 53 // |CategoryFactory::FromIDValue(id)|. | 54 // |CategoryFactory::FromIDValue(id)|. |
| 54 // Note that these IDs are not necessarily stable across multiple runs of | 55 // Note that these IDs are not necessarily stable across multiple runs of |
| 55 // the application, so they should not be persisted. | 56 // the application, so they should not be persisted. |
| 56 int id() const { return id_; } | 57 int id() const { return id_; } |
| 57 | 58 |
| 59 // Returns whether this category matches the given |known_category|. | |
| 58 bool IsKnownCategory(KnownCategories known_category) const; | 60 bool IsKnownCategory(KnownCategories known_category) const; |
| 59 | 61 |
| 62 // Returns whether this category is any of the known categories. | |
|
jkrcal
2016/09/13 16:08:05
Without looking in the implementation, I would not
Marc Treib
2016/09/13 16:28:50
Added, except for the "except..." part. It should
jkrcal
2016/09/13 17:22:28
Agreed, thanks.
| |
| 63 bool IsAnyKnownCategory() const; | |
| 64 | |
| 60 private: | 65 private: |
| 61 friend class CategoryFactory; | 66 friend class CategoryFactory; |
| 62 | 67 |
| 63 explicit Category(int id); | 68 explicit Category(int id); |
| 64 | 69 |
| 65 int id_; | 70 int id_; |
| 66 | 71 |
| 67 // Allow copy and assignment. | 72 // Allow copy and assignment. |
| 68 }; | 73 }; |
| 69 | 74 |
| 70 bool operator==(const Category& left, const Category& right); | 75 bool operator==(const Category& left, const Category& right); |
| 71 | 76 |
| 72 bool operator!=(const Category& left, const Category& right); | 77 bool operator!=(const Category& left, const Category& right); |
| 73 | 78 |
| 74 struct Category::CompareByID { | 79 struct Category::CompareByID { |
| 75 bool operator()(const Category& left, const Category& right) const; | 80 bool operator()(const Category& left, const Category& right) const; |
| 76 }; | 81 }; |
| 77 | 82 |
| 78 std::ostream& operator<<(std::ostream& os, const Category& obj); | 83 std::ostream& operator<<(std::ostream& os, const Category& obj); |
| 79 | 84 |
| 80 } // namespace ntp_snippets | 85 } // namespace ntp_snippets |
| 81 | 86 |
| 82 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_H_ | 87 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_H_ |
| OLD | NEW |