Chromium Code Reviews| 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/favicon/core/large_icon_service.h" | 11 #include "components/favicon/core/large_icon_service.h" |
| 12 #include "components/ntp_snippets/category.h" | 12 #include "components/ntp_snippets/category.h" |
| 13 #include "components/ntp_snippets/category_info.h" | 13 #include "components/ntp_snippets/category_info.h" |
| 14 #include "components/ntp_snippets/content_suggestion.h" | 14 #include "components/ntp_snippets/content_suggestion.h" |
| 15 #include "components/ntp_snippets/reading_list/reading_list_distillation_state_u til.h" | |
| 15 #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" |
| 16 #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" |
| 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 "ios/chrome/grit/ios_strings.h" | 26 #include "ios/chrome/grit/ios_strings.h" |
| 24 #include "ui/base/l10n/l10n_util_mac.h" | 27 #include "ui/base/l10n/l10n_util_mac.h" |
| 25 #include "ui/gfx/image/image.h" | 28 #include "ui/gfx/image/image.h" |
| 26 | 29 |
| 27 #if !defined(__has_feature) || !__has_feature(objc_arc) | 30 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 28 #error "This file requires ARC support." | 31 #error "This file requires ARC support." |
| 29 #endif | 32 #endif |
| 30 | 33 |
| 31 namespace { | 34 namespace { |
| 32 | 35 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 } | 362 } |
| 360 | 363 |
| 361 for (auto& contentSuggestion : suggestions) { | 364 for (auto& contentSuggestion : suggestions) { |
| 362 ContentSuggestion* suggestion = ConvertContentSuggestion(contentSuggestion); | 365 ContentSuggestion* suggestion = ConvertContentSuggestion(contentSuggestion); |
| 363 | 366 |
| 364 suggestion.type = TypeForCategory(category); | 367 suggestion.type = TypeForCategory(category); |
| 365 | 368 |
| 366 suggestion.suggestionIdentifier.sectionInfo = | 369 suggestion.suggestionIdentifier.sectionInfo = |
| 367 self.sectionInformationByCategory[categoryWrapper]; | 370 self.sectionInformationByCategory[categoryWrapper]; |
| 368 | 371 |
| 372 if (category.IsKnownCategory(ntp_snippets::KnownCategories::READING_LIST)) { | |
| 373 ReadingListUIDistillationStatus status = | |
| 374 UIStatusFromModelStatus(ReadingListStateFromSuggestionState( | |
|
Olivier
2017/04/05 13:45:22
IIUC, UIStatusFromModelStatus will be a really com
gambard
2017/04/06 09:28:50
Done.
| |
| 375 contentSuggestion.reading_list_suggestion_extra() | |
| 376 ->distilled_state)); | |
|
Olivier
2017/04/05 14:03:44
I think the real problem (that confuses me most) i
gambard
2017/04/06 09:28:50
Acknowledged.
| |
| 377 suggestion.readingListExtra = | |
| 378 [ContentSuggestionReadingListExtra extraWithStatus:status]; | |
| 379 } | |
| 380 | |
| 369 [contentArray addObject:suggestion]; | 381 [contentArray addObject:suggestion]; |
| 370 } | 382 } |
| 371 | 383 |
| 372 if (suggestions.size() == 0) { | 384 if (suggestions.size() == 0) { |
| 373 ContentSuggestion* suggestion = [[ContentSuggestion alloc] init]; | 385 ContentSuggestion* suggestion = [[ContentSuggestion alloc] init]; |
| 374 suggestion.type = ContentSuggestionTypeEmpty; | 386 suggestion.type = ContentSuggestionTypeEmpty; |
| 375 suggestion.suggestionIdentifier = | 387 suggestion.suggestionIdentifier = |
| 376 [[ContentSuggestionIdentifier alloc] init]; | 388 [[ContentSuggestionIdentifier alloc] init]; |
| 377 suggestion.suggestionIdentifier.sectionInfo = | 389 suggestion.suggestionIdentifier.sectionInfo = |
| 378 self.sectionInformationByCategory[categoryWrapper]; | 390 self.sectionInformationByCategory[categoryWrapper]; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 409 [NSMutableArray array]; | 421 [NSMutableArray array]; |
| 410 ntp_snippets::Category category = suggestions[0].id().category(); | 422 ntp_snippets::Category category = suggestions[0].id().category(); |
| 411 [self addSuggestions:suggestions | 423 [self addSuggestions:suggestions |
| 412 fromCategory:category | 424 fromCategory:category |
| 413 toArray:contentSuggestions]; | 425 toArray:contentSuggestions]; |
| 414 callback(contentSuggestions); | 426 callback(contentSuggestions); |
| 415 } | 427 } |
| 416 } | 428 } |
| 417 | 429 |
| 418 @end | 430 @end |
| OLD | NEW |