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

Unified Diff: ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.mm

Issue 2669173002: Use IOSImageDataFetcherWrapper (Closed)
Patch Set: Update comments Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.mm
diff --git a/ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.mm b/ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.mm
index 732a94f363737eb2dd96929afa90a2f269fd3281..de6648bbaa27850d2749ffdb9901f6554d29ada1 100644
--- a/ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.mm
+++ b/ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.mm
@@ -12,6 +12,7 @@
#include "base/metrics/user_metrics.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#import "components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h"
#include "components/omnibox/browser/autocomplete_input.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/autocomplete_result.h"
@@ -29,7 +30,6 @@
#include "ios/chrome/grit/ios_theme_resources.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
#import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoFontLoader.h"
-#include "ios/web/public/image_fetcher/image_data_fetcher.h"
#include "net/base/escape.h"
namespace {
@@ -91,7 +91,7 @@ UIColor* BackgroundColorIncognito() {
OmniboxPopupViewIOS* _popupView; // weak, owns us
// Fetcher for Answers in Suggest images.
- std::unique_ptr<web::ImageDataFetcher> imageFetcher_;
+ std::unique_ptr<image_fetcher::IOSImageDataFetcherWrapper> imageFetcher_;
// The data source.
AutocompleteResult _currentResult;
@@ -113,9 +113,10 @@ UIColor* BackgroundColorIncognito() {
#pragma mark -
#pragma mark Initialization
-- (instancetype)initWithPopupView:(OmniboxPopupViewIOS*)view
- withFetcher:
- (std::unique_ptr<web::ImageDataFetcher>)imageFetcher {
+- (instancetype)
+initWithPopupView:(OmniboxPopupViewIOS*)view
+ withFetcher:(std::unique_ptr<image_fetcher::IOSImageDataFetcherWrapper>)
+ imageFetcher {
if ((self = [super init])) {
_popupView = view;
imageFetcher_ = std::move(imageFetcher);
@@ -254,18 +255,17 @@ UIColor* BackgroundColorIncognito() {
const BOOL answerImagePresent =
answerPresent && match.answer->second_line().image_url().is_valid();
if (answerImagePresent) {
- web::ImageFetchedCallback callback =
- ^(const GURL& original_url, int response_code, NSData* data) {
- if (data) {
- UIImage* image =
- [UIImage imageWithData:data scale:[UIScreen mainScreen].scale];
- if (image) {
- row.answerImageView.image = image;
- }
- }
- };
- imageFetcher_->StartDownload(match.answer->second_line().image_url(),
- callback);
+ image_fetcher::IOSImageDataFetcherCallback callback = ^(NSData* data) {
+ if (data) {
+ UIImage* image =
+ [UIImage imageWithData:data scale:[UIScreen mainScreen].scale];
+ if (image) {
+ row.answerImageView.image = image;
+ }
+ }
+ };
+ imageFetcher_->FetchImageDataWebpDecoded(
+ match.answer->second_line().image_url(), callback);
// Answers in suggest do not support RTL, left align only.
CGFloat imageLeftPadding =

Powered by Google App Engine
This is Rietveld 408576698