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

Side by Side Diff: ios/chrome/browser/ui/browser_view_controller.mm

Issue 2677993002: Use IOSImageDataFetcherWrapper for favicon (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/ui/browser_view_controller.h" 5 #import "ios/chrome/browser/ui/browser_view_controller.h"
6 6
7 #import <AssetsLibrary/AssetsLibrary.h> 7 #import <AssetsLibrary/AssetsLibrary.h>
8 #import <MobileCoreServices/MobileCoreServices.h> 8 #import <MobileCoreServices/MobileCoreServices.h>
9 #import <PassKit/PassKit.h> 9 #import <PassKit/PassKit.h>
10 #import <Photos/Photos.h> 10 #import <Photos/Photos.h>
(...skipping 3036 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 } 3047 }
3048 } 3048 }
3049 3049
3050 #pragma mark - Context menu methods 3050 #pragma mark - Context menu methods
3051 3051
3052 - (void)searchByImageAtURL:(const GURL&)url 3052 - (void)searchByImageAtURL:(const GURL&)url
3053 referrer:(const web::Referrer)referrer { 3053 referrer:(const web::Referrer)referrer {
3054 DCHECK(url.is_valid()); 3054 DCHECK(url.is_valid());
3055 base::WeakNSObject<BrowserViewController> weakSelf(self); 3055 base::WeakNSObject<BrowserViewController> weakSelf(self);
3056 const GURL image_source_url = url; 3056 const GURL image_source_url = url;
3057 image_fetcher::IOSImageDataFetcherCallback callback = ^(NSData* data) { 3057 image_fetcher::IOSImageDataFetcherCallback callback = ^(
3058 int http_response_code, NSData* data) {
3058 DCHECK(data); 3059 DCHECK(data);
3059 dispatch_async(dispatch_get_main_queue(), ^{ 3060 dispatch_async(dispatch_get_main_queue(), ^{
3060 [weakSelf searchByImageData:data atURL:image_source_url]; 3061 [weakSelf searchByImageData:data atURL:image_source_url];
3061 }); 3062 });
3062 }; 3063 };
3063 _imageFetcher->FetchImageDataWebpDecoded( 3064 _imageFetcher->FetchImageDataWebpDecoded(
3064 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer), 3065 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer),
3065 web::PolicyForNavigation(url, referrer)); 3066 web::PolicyForNavigation(url, referrer));
3066 } 3067 }
3067 3068
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3103 search_args, templateUrlService->search_terms_data(), &post_content)); 3104 search_args, templateUrlService->search_terms_data(), &post_content));
3104 [self addSelectedTabWithURL:result 3105 [self addSelectedTabWithURL:result
3105 postData:&post_content 3106 postData:&post_content
3106 transition:ui::PAGE_TRANSITION_TYPED]; 3107 transition:ui::PAGE_TRANSITION_TYPED];
3107 } 3108 }
3108 3109
3109 - (void)saveImageAtURL:(const GURL&)url 3110 - (void)saveImageAtURL:(const GURL&)url
3110 referrer:(const web::Referrer&)referrer { 3111 referrer:(const web::Referrer&)referrer {
3111 DCHECK(url.is_valid()); 3112 DCHECK(url.is_valid());
3112 3113
3113 image_fetcher::IOSImageDataFetcherCallback callback = ^(NSData* data) { 3114 image_fetcher::IOSImageDataFetcherCallback callback =
3114 DCHECK(data); 3115 ^(int http_response_code, NSData* data) {
3116 DCHECK(data);
3115 3117
3116 [self managePermissionAndSaveImage:data]; 3118 [self managePermissionAndSaveImage:data];
3117 }; 3119 };
3118 _imageFetcher->FetchImageDataWebpDecoded( 3120 _imageFetcher->FetchImageDataWebpDecoded(
3119 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer), 3121 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer),
3120 web::PolicyForNavigation(url, referrer)); 3122 web::PolicyForNavigation(url, referrer));
3121 } 3123 }
3122 3124
3123 - (void)managePermissionAndSaveImage:(NSData*)data { 3125 - (void)managePermissionAndSaveImage:(NSData*)data {
3124 switch ([PHPhotoLibrary authorizationStatus]) { 3126 switch ([PHPhotoLibrary authorizationStatus]) {
3125 // User was never asked for permission to access photos. 3127 // User was never asked for permission to access photos.
3126 case PHAuthorizationStatusNotDetermined: 3128 case PHAuthorizationStatusNotDetermined:
3127 [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { 3129 [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
(...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after
5144 5146
5145 - (UIView*)voiceSearchButton { 5147 - (UIView*)voiceSearchButton {
5146 return _voiceSearchButton; 5148 return _voiceSearchButton;
5147 } 5149 }
5148 5150
5149 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5151 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5150 return [self currentLogoAnimationControllerOwner]; 5152 return [self currentLogoAnimationControllerOwner];
5151 } 5153 }
5152 5154
5153 @end 5155 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698