| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 300 |
| 301 - (void)contentSuggestionsServiceShutdown: | 301 - (void)contentSuggestionsServiceShutdown: |
| 302 (ntp_snippets::ContentSuggestionsService*)suggestionsService { | 302 (ntp_snippets::ContentSuggestionsService*)suggestionsService { |
| 303 // Update dataSink. | 303 // Update dataSink. |
| 304 } | 304 } |
| 305 | 305 |
| 306 #pragma mark - ContentSuggestionsImageFetcher | 306 #pragma mark - ContentSuggestionsImageFetcher |
| 307 | 307 |
| 308 - (void)fetchImageForSuggestion: | 308 - (void)fetchImageForSuggestion: |
| 309 (ContentSuggestionIdentifier*)suggestionIdentifier | 309 (ContentSuggestionIdentifier*)suggestionIdentifier |
| 310 callback:(void (^)(const gfx::Image&))callback { | 310 callback:(void (^)(UIImage*))callback { |
| 311 self.contentService->FetchSuggestionImage( | 311 self.contentService->FetchSuggestionImage( |
| 312 SuggestionIDForSectionID( | 312 SuggestionIDForSectionID( |
| 313 [self categoryWrapperForSectionInfo:suggestionIdentifier.sectionInfo], | 313 [self categoryWrapperForSectionInfo:suggestionIdentifier.sectionInfo], |
| 314 suggestionIdentifier.IDInSection), | 314 suggestionIdentifier.IDInSection), |
| 315 base::BindBlockArc(callback)); | 315 base::BindBlockArc(^(const gfx::Image& image) { |
| 316 if (image.IsEmpty() || !callback) { |
| 317 return; |
| 318 } |
| 319 |
| 320 callback([image.ToUIImage() copy]); |
| 321 })); |
| 316 } | 322 } |
| 317 | 323 |
| 318 #pragma mark - Private | 324 #pragma mark - Private |
| 319 | 325 |
| 320 - (void)addSuggestions: | 326 - (void)addSuggestions: |
| 321 (const std::vector<ntp_snippets::ContentSuggestion>&)suggestions | 327 (const std::vector<ntp_snippets::ContentSuggestion>&)suggestions |
| 322 fromCategory:(ntp_snippets::Category&)category | 328 fromCategory:(ntp_snippets::Category&)category |
| 323 toArray:(NSMutableArray<ContentSuggestion*>*)contentArray { | 329 toArray:(NSMutableArray<ContentSuggestion*>*)contentArray { |
| 324 if (!ntp_snippets::IsCategoryStatusAvailable( | 330 if (!ntp_snippets::IsCategoryStatusAvailable( |
| 325 self.contentService->GetCategoryStatus(category))) { | 331 self.contentService->GetCategoryStatus(category))) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 [NSMutableArray array]; | 389 [NSMutableArray array]; |
| 384 ntp_snippets::Category category = suggestions[0].id().category(); | 390 ntp_snippets::Category category = suggestions[0].id().category(); |
| 385 [self addSuggestions:suggestions | 391 [self addSuggestions:suggestions |
| 386 fromCategory:category | 392 fromCategory:category |
| 387 toArray:contentSuggestions]; | 393 toArray:contentSuggestions]; |
| 388 callback(contentSuggestions); | 394 callback(contentSuggestions); |
| 389 } | 395 } |
| 390 } | 396 } |
| 391 | 397 |
| 392 @end | 398 @end |
| OLD | NEW |