OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/chrome/browser/content_suggestions/content_suggestions_mediator.h" | 5 #import "ios/chrome/browser/content_suggestions/content_suggestions_mediator.h" |
6 | 6 |
7 #include "base/mac/bind_objc_block.h" | 7 #include "base/mac/bind_objc_block.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/optional.h" | 9 #include "base/optional.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 suggestions)> callback, | 37 suggestions)> callback, |
38 ntp_snippets::Status status_code, | 38 ntp_snippets::Status status_code, |
39 std::vector<ntp_snippets::ContentSuggestion> suggestions) { | 39 std::vector<ntp_snippets::ContentSuggestion> suggestions) { |
40 if (callback) { | 40 if (callback) { |
41 callback.Run(status_code, suggestions); | 41 callback.Run(status_code, suggestions); |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 // Returns the Type for this |category|. | 45 // Returns the Type for this |category|. |
46 ContentSuggestionType TypeForCategory(ntp_snippets::Category category) { | 46 ContentSuggestionType TypeForCategory(ntp_snippets::Category category) { |
47 // For now, only Article is a relevant type. | 47 if (category.IsKnownCategory(ntp_snippets::KnownCategories::ARTICLES)) |
48 return ContentSuggestionTypeArticle; | 48 return ContentSuggestionTypeArticle; |
| 49 if (category.IsKnownCategory(ntp_snippets::KnownCategories::READING_LIST)) |
| 50 return ContentSuggestionTypeReadingList; |
| 51 |
| 52 return ContentSuggestionTypeEmpty; |
49 } | 53 } |
50 | 54 |
51 // Returns the section ID for this |category|. | 55 // Returns the section ID for this |category|. |
52 ContentSuggestionsSectionID SectionIDForCategory( | 56 ContentSuggestionsSectionID SectionIDForCategory( |
53 ntp_snippets::Category category) { | 57 ntp_snippets::Category category) { |
54 if (category.IsKnownCategory(ntp_snippets::KnownCategories::BOOKMARKS)) | 58 if (category.IsKnownCategory(ntp_snippets::KnownCategories::BOOKMARKS)) |
55 return ContentSuggestionsSectionBookmarks; | 59 return ContentSuggestionsSectionBookmarks; |
56 if (category.IsKnownCategory(ntp_snippets::KnownCategories::ARTICLES)) | 60 if (category.IsKnownCategory(ntp_snippets::KnownCategories::ARTICLES)) |
57 return ContentSuggestionsSectionArticles; | 61 return ContentSuggestionsSectionArticles; |
| 62 if (category.IsKnownCategory(ntp_snippets::KnownCategories::READING_LIST)) |
| 63 return ContentSuggestionsSectionReadingList; |
58 | 64 |
59 return ContentSuggestionsSectionUnknown; | 65 return ContentSuggestionsSectionUnknown; |
60 } | 66 } |
61 | 67 |
62 // Returns the section layout corresponding to the category |layout|. | 68 // Returns the section layout corresponding to the category |layout|. |
63 ContentSuggestionsSectionLayout SectionLayoutForLayout( | 69 ContentSuggestionsSectionLayout SectionLayoutForLayout( |
64 ntp_snippets::ContentSuggestionsCardLayout layout) { | 70 ntp_snippets::ContentSuggestionsCardLayout layout) { |
65 // For now, only cards are relevant. | 71 // For now, only cards are relevant. |
66 return ContentSuggestionsSectionLayoutCard; | 72 return ContentSuggestionsSectionLayoutCard; |
67 } | 73 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 [NSMutableArray array]; | 383 [NSMutableArray array]; |
378 ntp_snippets::Category category = suggestions[0].id().category(); | 384 ntp_snippets::Category category = suggestions[0].id().category(); |
379 [self addSuggestions:suggestions | 385 [self addSuggestions:suggestions |
380 fromCategory:category | 386 fromCategory:category |
381 toArray:contentSuggestions]; | 387 toArray:contentSuggestions]; |
382 callback(contentSuggestions); | 388 callback(contentSuggestions); |
383 } | 389 } |
384 } | 390 } |
385 | 391 |
386 @end | 392 @end |
OLD | NEW |