 Chromium Code Reviews
 Chromium Code Reviews Issue 2772583005:
  Pass UIImage instead of gfx::Image in ContentSuggestions  (Closed)
    
  
    Issue 2772583005:
  Pass UIImage instead of gfx::Image in ContentSuggestions  (Closed) 
  | 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 | 295 | 
| 296 - (void)contentSuggestionsServiceShutdown: | 296 - (void)contentSuggestionsServiceShutdown: | 
| 297 (ntp_snippets::ContentSuggestionsService*)suggestionsService { | 297 (ntp_snippets::ContentSuggestionsService*)suggestionsService { | 
| 298 // Update dataSink. | 298 // Update dataSink. | 
| 299 } | 299 } | 
| 300 | 300 | 
| 301 #pragma mark - ContentSuggestionsImageFetcher | 301 #pragma mark - ContentSuggestionsImageFetcher | 
| 302 | 302 | 
| 303 - (void)fetchImageForSuggestion: | 303 - (void)fetchImageForSuggestion: | 
| 304 (ContentSuggestionIdentifier*)suggestionIdentifier | 304 (ContentSuggestionIdentifier*)suggestionIdentifier | 
| 305 callback:(void (^)(const gfx::Image&))callback { | 305 callback:(void (^)(UIImage*))callback { | 
| 306 self.contentService->FetchSuggestionImage( | 306 self.contentService->FetchSuggestionImage( | 
| 307 SuggestionIDForSectionID( | 307 SuggestionIDForSectionID( | 
| 308 [self categoryWrapperForSectionInfo:suggestionIdentifier.sectionInfo], | 308 [self categoryWrapperForSectionInfo:suggestionIdentifier.sectionInfo], | 
| 309 suggestionIdentifier.IDInSection), | 309 suggestionIdentifier.IDInSection), | 
| 310 base::BindBlockArc(callback)); | 310 base::BindBlockArc(^(const gfx::Image& image) { | 
| 311 if (image.IsEmpty() || !callback) { | |
| 312 return; | |
| 313 } | |
| 314 | |
| 315 callback(image.CopyUIImage()); | |
| 
stkhapugin
2017/03/24 16:31:40
This returns a retained UIImage. You need to use i
 
gambard
2017/03/28 07:22:28
Done.
 | |
| 316 })); | |
| 311 } | 317 } | 
| 312 | 318 | 
| 313 #pragma mark - Private | 319 #pragma mark - Private | 
| 314 | 320 | 
| 315 - (void)addSuggestions: | 321 - (void)addSuggestions: | 
| 316 (const std::vector<ntp_snippets::ContentSuggestion>&)suggestions | 322 (const std::vector<ntp_snippets::ContentSuggestion>&)suggestions | 
| 317 fromCategory:(ntp_snippets::Category&)category | 323 fromCategory:(ntp_snippets::Category&)category | 
| 318 toArray:(NSMutableArray<ContentSuggestion*>*)contentArray { | 324 toArray:(NSMutableArray<ContentSuggestion*>*)contentArray { | 
| 319 if (self.contentService->GetCategoryStatus(category) != | 325 if (self.contentService->GetCategoryStatus(category) != | 
| 320 ntp_snippets::CategoryStatus::AVAILABLE) { | 326 ntp_snippets::CategoryStatus::AVAILABLE) { | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 [NSMutableArray array]; | 373 [NSMutableArray array]; | 
| 368 ntp_snippets::Category category = suggestions[0].id().category(); | 374 ntp_snippets::Category category = suggestions[0].id().category(); | 
| 369 [self addSuggestions:suggestions | 375 [self addSuggestions:suggestions | 
| 370 fromCategory:category | 376 fromCategory:category | 
| 371 toArray:contentSuggestions]; | 377 toArray:contentSuggestions]; | 
| 372 callback(contentSuggestions); | 378 callback(contentSuggestions); | 
| 373 } | 379 } | 
| 374 } | 380 } | 
| 375 | 381 | 
| 376 @end | 382 @end | 
| OLD | NEW |