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" |
11 #include "components/ntp_snippets/category.h" | 11 #include "components/ntp_snippets/category.h" |
| 12 #include "components/ntp_snippets/category_info.h" |
12 #include "components/ntp_snippets/content_suggestion.h" | 13 #include "components/ntp_snippets/content_suggestion.h" |
13 #import "ios/chrome/browser/content_suggestions/content_suggestions_category_wra
pper.h" | 14 #import "ios/chrome/browser/content_suggestions/content_suggestions_category_wra
pper.h" |
14 #import "ios/chrome/browser/content_suggestions/content_suggestions_service_brid
ge_observer.h" | 15 #import "ios/chrome/browser/content_suggestions/content_suggestions_service_brid
ge_observer.h" |
15 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h" | 16 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h" |
16 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion_identifier
.h" | 17 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion_identifier
.h" |
17 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_data_sink
.h" | 18 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_data_sink
.h" |
18 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_image_fet
cher.h" | 19 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_image_fet
cher.h" |
19 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_section_i
nformation.h" | 20 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_section_i
nformation.h" |
20 #include "ios/chrome/grit/ios_strings.h" | 21 #include "ios/chrome/grit/ios_strings.h" |
21 #include "ui/base/l10n/l10n_util_mac.h" | 22 #include "ui/base/l10n/l10n_util_mac.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 const ntp_snippets::Category& category) { | 94 const ntp_snippets::Category& category) { |
94 ContentSuggestionsSectionInformation* sectionInfo = | 95 ContentSuggestionsSectionInformation* sectionInfo = |
95 [[ContentSuggestionsSectionInformation alloc] | 96 [[ContentSuggestionsSectionInformation alloc] |
96 initWithSectionID:SectionIDForCategory(category)]; | 97 initWithSectionID:SectionIDForCategory(category)]; |
97 if (categoryInfo) { | 98 if (categoryInfo) { |
98 sectionInfo.layout = SectionLayoutForLayout(categoryInfo->card_layout()); | 99 sectionInfo.layout = SectionLayoutForLayout(categoryInfo->card_layout()); |
99 if (categoryInfo->show_if_empty()) { | 100 if (categoryInfo->show_if_empty()) { |
100 // TODO(crbug.com/686728): Creates an item to display information when the | 101 // TODO(crbug.com/686728): Creates an item to display information when the |
101 // section is empty. | 102 // section is empty. |
102 } | 103 } |
103 if (categoryInfo->has_fetch_action()) { | 104 if (categoryInfo->additional_action() != |
| 105 ntp_snippets::ContentSuggestionsAdditionalAction::NONE) { |
104 sectionInfo.footerTitle = | 106 sectionInfo.footerTitle = |
105 l10n_util::GetNSString(IDS_IOS_CONTENT_SUGGESTIONS_FOOTER_TITLE); | 107 l10n_util::GetNSString(IDS_IOS_CONTENT_SUGGESTIONS_FOOTER_TITLE); |
106 } | 108 } |
107 sectionInfo.title = base::SysUTF16ToNSString(categoryInfo->title()); | 109 sectionInfo.title = base::SysUTF16ToNSString(categoryInfo->title()); |
108 } | 110 } |
109 return sectionInfo; | 111 return sectionInfo; |
110 } | 112 } |
111 | 113 |
112 // Returns a ntp_snippets::ID based on a Objective-C Category and the ID in the | 114 // Returns a ntp_snippets::ID based on a Objective-C Category and the ID in the |
113 // category. | 115 // category. |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 [NSMutableArray array]; | 367 [NSMutableArray array]; |
366 ntp_snippets::Category category = suggestions[0].id().category(); | 368 ntp_snippets::Category category = suggestions[0].id().category(); |
367 [self addSuggestions:suggestions | 369 [self addSuggestions:suggestions |
368 fromCategory:category | 370 fromCategory:category |
369 toArray:contentSuggestions]; | 371 toArray:contentSuggestions]; |
370 callback(contentSuggestions); | 372 callback(contentSuggestions); |
371 } | 373 } |
372 } | 374 } |
373 | 375 |
374 @end | 376 @end |
OLD | NEW |