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

Side by Side Diff: ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm

Issue 2751093003: Unifies the additional actions for Categories (Closed)
Patch Set: Fix compilation on Android (hopefully) Created 3 years, 9 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
« no previous file with comments | « components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698