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

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

Issue 2796273002: Display offline availability on ContentSuggestions (Closed)
Patch Set: Adress comments Created 3 years, 8 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 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 "components/favicon/core/large_icon_service.h" 10 #include "components/favicon/core/large_icon_service.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/category_info.h"
13 #include "components/ntp_snippets/content_suggestion.h" 13 #include "components/ntp_snippets/content_suggestion.h"
14 #include "components/ntp_snippets/reading_list/reading_list_distillation_state_u til.h"
14 #import "ios/chrome/browser/content_suggestions/content_suggestions_category_wra pper.h" 15 #import "ios/chrome/browser/content_suggestions/content_suggestions_category_wra pper.h"
15 #import "ios/chrome/browser/content_suggestions/content_suggestions_service_brid ge_observer.h" 16 #import "ios/chrome/browser/content_suggestions/content_suggestions_service_brid ge_observer.h"
16 #import "ios/chrome/browser/content_suggestions/mediator_util.h" 17 #import "ios/chrome/browser/content_suggestions/mediator_util.h"
17 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h" 18 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h"
18 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_data_sink .h" 19 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_data_sink .h"
19 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_image_fet cher.h" 20 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_image_fet cher.h"
20 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion _identifier.h" 21 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion _identifier.h"
21 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion s_section_information.h" 22 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion s_section_information.h"
22 #import "ios/chrome/browser/ui/favicon/favicon_attributes_provider.h" 23 #import "ios/chrome/browser/ui/favicon/favicon_attributes_provider.h"
24 #import "ios/chrome/browser/ui/reading_list/reading_list_collection_view_item.h"
25 #import "ios/chrome/browser/ui/reading_list/reading_list_utils.h"
23 #include "ui/gfx/image/image.h" 26 #include "ui/gfx/image/image.h"
24 27
25 #if !defined(__has_feature) || !__has_feature(objc_arc) 28 #if !defined(__has_feature) || !__has_feature(objc_arc)
26 #error "This file requires ARC support." 29 #error "This file requires ARC support."
27 #endif 30 #endif
28 31
29 namespace { 32 namespace {
30 33
31 // Size of the favicon returned by the provider. 34 // Size of the favicon returned by the provider.
32 const CGFloat kDefaultFaviconSize = 16; 35 const CGFloat kDefaultFaviconSize = 16;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 264 }
262 265
263 for (auto& contentSuggestion : suggestions) { 266 for (auto& contentSuggestion : suggestions) {
264 ContentSuggestion* suggestion = ConvertContentSuggestion(contentSuggestion); 267 ContentSuggestion* suggestion = ConvertContentSuggestion(contentSuggestion);
265 268
266 suggestion.type = TypeForCategory(category); 269 suggestion.type = TypeForCategory(category);
267 270
268 suggestion.suggestionIdentifier.sectionInfo = 271 suggestion.suggestionIdentifier.sectionInfo =
269 self.sectionInformationByCategory[categoryWrapper]; 272 self.sectionInformationByCategory[categoryWrapper];
270 273
274 if (category.IsKnownCategory(ntp_snippets::KnownCategories::READING_LIST)) {
275 ReadingListUIDistillationStatus status =
276 reading_list::UIStatusFromModelStatus(
277 ReadingListStateFromSuggestionState(
278 contentSuggestion.reading_list_suggestion_extra()
279 ->distilled_state));
280 suggestion.readingListExtra = [ContentSuggestionReadingListExtra
281 extraWithDistillationStatus:status];
282 }
283
271 [contentArray addObject:suggestion]; 284 [contentArray addObject:suggestion];
272 } 285 }
273 286
274 if (suggestions.size() == 0) { 287 if (suggestions.size() == 0) {
275 ContentSuggestion* suggestion = [[ContentSuggestion alloc] init]; 288 ContentSuggestion* suggestion = [[ContentSuggestion alloc] init];
276 suggestion.type = ContentSuggestionTypeEmpty; 289 suggestion.type = ContentSuggestionTypeEmpty;
277 suggestion.suggestionIdentifier = 290 suggestion.suggestionIdentifier =
278 [[ContentSuggestionIdentifier alloc] init]; 291 [[ContentSuggestionIdentifier alloc] init];
279 suggestion.suggestionIdentifier.sectionInfo = 292 suggestion.suggestionIdentifier.sectionInfo =
280 self.sectionInformationByCategory[categoryWrapper]; 293 self.sectionInformationByCategory[categoryWrapper];
(...skipping 30 matching lines...) Expand all
311 [NSMutableArray array]; 324 [NSMutableArray array];
312 ntp_snippets::Category category = suggestions[0].id().category(); 325 ntp_snippets::Category category = suggestions[0].id().category();
313 [self addSuggestions:suggestions 326 [self addSuggestions:suggestions
314 fromCategory:category 327 fromCategory:category
315 toArray:contentSuggestions]; 328 toArray:contentSuggestions];
316 callback(contentSuggestions); 329 callback(contentSuggestions);
317 } 330 }
318 } 331 }
319 332
320 @end 333 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/content_suggestions/BUILD.gn ('k') | ios/chrome/browser/ui/content_suggestions/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698