| 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" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Converts a ntp_snippets::ContentSuggestion to an Objective-C | 51 // Converts a ntp_snippets::ContentSuggestion to an Objective-C |
| 52 // ContentSuggestion. | 52 // ContentSuggestion. |
| 53 ContentSuggestion* ConvertContentSuggestion( | 53 ContentSuggestion* ConvertContentSuggestion( |
| 54 const ntp_snippets::ContentSuggestion& contentSuggestion) { | 54 const ntp_snippets::ContentSuggestion& contentSuggestion) { |
| 55 ContentSuggestion* suggestion = [[ContentSuggestion alloc] init]; | 55 ContentSuggestion* suggestion = [[ContentSuggestion alloc] init]; |
| 56 suggestion.title = base::SysUTF16ToNSString(contentSuggestion.title()); | 56 suggestion.title = base::SysUTF16ToNSString(contentSuggestion.title()); |
| 57 suggestion.text = base::SysUTF16ToNSString(contentSuggestion.snippet_text()); | 57 suggestion.text = base::SysUTF16ToNSString(contentSuggestion.snippet_text()); |
| 58 suggestion.url = contentSuggestion.url(); | 58 suggestion.url = contentSuggestion.url(); |
| 59 suggestion.publisher = |
| 60 base::SysUTF16ToNSString(contentSuggestion.publisher_name()); |
| 61 suggestion.publishDate = contentSuggestion.publish_date(); |
| 59 | 62 |
| 60 return suggestion; | 63 return suggestion; |
| 61 } | 64 } |
| 62 | 65 |
| 63 // Returns a SectionInformation for a |category|, filled with the | 66 // Returns a SectionInformation for a |category|, filled with the |
| 64 // |categoryInfo|. | 67 // |categoryInfo|. |
| 65 ContentSuggestionsSectionInformation* SectionInformationFromCategoryInfo( | 68 ContentSuggestionsSectionInformation* SectionInformationFromCategoryInfo( |
| 66 const base::Optional<ntp_snippets::CategoryInfo>& categoryInfo, | 69 const base::Optional<ntp_snippets::CategoryInfo>& categoryInfo, |
| 67 const ntp_snippets::Category& category) { | 70 const ntp_snippets::Category& category) { |
| 68 ContentSuggestionsSectionInformation* sectionInfo = | 71 ContentSuggestionsSectionInformation* sectionInfo = |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 self.contentService->GetCategoryInfo(category); | 201 self.contentService->GetCategoryInfo(category); |
| 199 | 202 |
| 200 ContentSuggestionsSectionInformation* sectionInfo = | 203 ContentSuggestionsSectionInformation* sectionInfo = |
| 201 SectionInformationFromCategoryInfo(categoryInfo, category); | 204 SectionInformationFromCategoryInfo(categoryInfo, category); |
| 202 | 205 |
| 203 self.sectionInformationByCategory[[ContentSuggestionsCategoryWrapper | 206 self.sectionInformationByCategory[[ContentSuggestionsCategoryWrapper |
| 204 wrapperWithCategory:category]] = sectionInfo; | 207 wrapperWithCategory:category]] = sectionInfo; |
| 205 } | 208 } |
| 206 | 209 |
| 207 @end | 210 @end |
| OLD | NEW |