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

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

Issue 2772583005: Pass UIImage instead of gfx::Image in ContentSuggestions (Closed)
Patch Set: Rebase Created 3 years, 8 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
« no previous file with comments | « no previous file | ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698