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

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

Issue 2865183003: Use the same design for all suggestions (Closed)
Patch Set: Address comments Created 3 years, 7 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"
15 #include "components/ntp_tiles/most_visited_sites.h" 14 #include "components/ntp_tiles/most_visited_sites.h"
16 #include "components/ntp_tiles/ntp_tile.h" 15 #include "components/ntp_tiles/ntp_tile.h"
17 #import "ios/chrome/browser/content_suggestions/content_suggestions_category_wra pper.h" 16 #import "ios/chrome/browser/content_suggestions/content_suggestions_category_wra pper.h"
18 #import "ios/chrome/browser/content_suggestions/content_suggestions_service_brid ge_observer.h" 17 #import "ios/chrome/browser/content_suggestions/content_suggestions_service_brid ge_observer.h"
19 #import "ios/chrome/browser/content_suggestions/mediator_util.h" 18 #import "ios/chrome/browser/content_suggestions/mediator_util.h"
20 #include "ios/chrome/browser/ntp_tiles/most_visited_sites_observer_bridge.h" 19 #include "ios/chrome/browser/ntp_tiles/most_visited_sites_observer_bridge.h"
21 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h" 20 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h"
22 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands. h" 21 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands. h"
23 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_data_sink .h" 22 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_data_sink .h"
24 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_image_fet cher.h" 23 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_image_fet cher.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 363
365 for (auto& contentSuggestion : suggestions) { 364 for (auto& contentSuggestion : suggestions) {
366 ContentSuggestion* suggestion = ConvertContentSuggestion(contentSuggestion); 365 ContentSuggestion* suggestion = ConvertContentSuggestion(contentSuggestion);
367 366
368 suggestion.type = TypeForCategory(category); 367 suggestion.type = TypeForCategory(category);
369 368
370 suggestion.suggestionIdentifier.sectionInfo = 369 suggestion.suggestionIdentifier.sectionInfo =
371 self.sectionInformationByCategory[categoryWrapper]; 370 self.sectionInformationByCategory[categoryWrapper];
372 371
373 if (category.IsKnownCategory(ntp_snippets::KnownCategories::READING_LIST)) { 372 if (category.IsKnownCategory(ntp_snippets::KnownCategories::READING_LIST)) {
374 ReadingListUIDistillationStatus status = 373 suggestion.availableOffline =
375 reading_list::UIStatusFromModelStatus( 374 contentSuggestion.reading_list_suggestion_extra()->distilled;
376 ReadingListStateFromSuggestionState(
377 contentSuggestion.reading_list_suggestion_extra()
378 ->distilled_state));
379 suggestion.readingListExtra = [ContentSuggestionReadingListExtra
380 extraWithDistillationStatus:status];
381 } 375 }
382 376
383 [contentArray addObject:suggestion]; 377 [contentArray addObject:suggestion];
384 } 378 }
385 379
386 if (suggestions.size() == 0) { 380 if (suggestions.size() == 0) {
387 ContentSuggestion* suggestion = EmptySuggestion(); 381 ContentSuggestion* suggestion = EmptySuggestion();
388 suggestion.suggestionIdentifier.sectionInfo = 382 suggestion.suggestionIdentifier.sectionInfo =
389 self.sectionInformationByCategory[categoryWrapper]; 383 self.sectionInformationByCategory[categoryWrapper];
390 384
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 } 451 }
458 452
459 // Returns whether the |sectionInfo| is associated with a category from the 453 // Returns whether the |sectionInfo| is associated with a category from the
460 // content suggestions service. 454 // content suggestions service.
461 - (BOOL)isRelatedToContentSuggestionsService: 455 - (BOOL)isRelatedToContentSuggestionsService:
462 (ContentSuggestionsSectionInformation*)sectionInfo { 456 (ContentSuggestionsSectionInformation*)sectionInfo {
463 return sectionInfo != self.mostVisitedSectionInfo; 457 return sectionInfo != self.mostVisitedSectionInfo;
464 } 458 }
465 459
466 @end 460 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698