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

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

Issue 2677993002: Use IOSImageDataFetcherWrapper for favicon (Closed)
Patch Set: Add header 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 3031 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 } 3042 }
3043 } 3043 }
3044 3044
3045 #pragma mark - Context menu methods 3045 #pragma mark - Context menu methods
3046 3046
3047 - (void)searchByImageAtURL:(const GURL&)url 3047 - (void)searchByImageAtURL:(const GURL&)url
3048 referrer:(const web::Referrer)referrer { 3048 referrer:(const web::Referrer)referrer {
3049 DCHECK(url.is_valid()); 3049 DCHECK(url.is_valid());
3050 base::WeakNSObject<BrowserViewController> weakSelf(self); 3050 base::WeakNSObject<BrowserViewController> weakSelf(self);
3051 const GURL image_source_url = url; 3051 const GURL image_source_url = url;
3052 image_fetcher::IOSImageDataFetcherCallback callback = ^(NSData* data) { 3052 image_fetcher::IOSImageDataFetcherCallback callback = ^(
3053 NSData* data, const int response_code) {
3054
3053 DCHECK(data); 3055 DCHECK(data);
3054 dispatch_async(dispatch_get_main_queue(), ^{ 3056 dispatch_async(dispatch_get_main_queue(), ^{
3055 [weakSelf searchByImageData:data atURL:image_source_url]; 3057 [weakSelf searchByImageData:data atURL:image_source_url];
3056 }); 3058 });
3057 }; 3059 };
3058 _imageFetcher->FetchImageDataWebpDecoded( 3060 _imageFetcher->FetchImageDataWebpDecoded(
3059 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer), 3061 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer),
3060 web::PolicyForNavigation(url, referrer)); 3062 web::PolicyForNavigation(url, referrer));
3061 } 3063 }
3062 3064
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3098 search_args, templateUrlService->search_terms_data(), &post_content)); 3100 search_args, templateUrlService->search_terms_data(), &post_content));
3099 [self addSelectedTabWithURL:result 3101 [self addSelectedTabWithURL:result
3100 postData:&post_content 3102 postData:&post_content
3101 transition:ui::PAGE_TRANSITION_TYPED]; 3103 transition:ui::PAGE_TRANSITION_TYPED];
3102 } 3104 }
3103 3105
3104 - (void)saveImageAtURL:(const GURL&)url 3106 - (void)saveImageAtURL:(const GURL&)url
3105 referrer:(const web::Referrer&)referrer { 3107 referrer:(const web::Referrer&)referrer {
3106 DCHECK(url.is_valid()); 3108 DCHECK(url.is_valid());
3107 3109
3108 image_fetcher::IOSImageDataFetcherCallback callback = ^(NSData* data) { 3110 image_fetcher::IOSImageDataFetcherCallback callback =
3109 DCHECK(data); 3111 ^(NSData* data, const int response_code) {
3112 DCHECK(data);
3110 3113
3111 [self managePermissionAndSaveImage:data]; 3114 [self managePermissionAndSaveImage:data];
3112 }; 3115 };
3113 _imageFetcher->FetchImageDataWebpDecoded( 3116 _imageFetcher->FetchImageDataWebpDecoded(
3114 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer), 3117 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer),
3115 web::PolicyForNavigation(url, referrer)); 3118 web::PolicyForNavigation(url, referrer));
3116 } 3119 }
3117 3120
3118 - (void)managePermissionAndSaveImage:(NSData*)data { 3121 - (void)managePermissionAndSaveImage:(NSData*)data {
3119 switch ([PHPhotoLibrary authorizationStatus]) { 3122 switch ([PHPhotoLibrary authorizationStatus]) {
3120 // User was never asked for permission to access photos. 3123 // User was never asked for permission to access photos.
3121 case PHAuthorizationStatusNotDetermined: 3124 case PHAuthorizationStatusNotDetermined:
3122 [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { 3125 [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after
5144 5147
5145 - (UIView*)voiceSearchButton { 5148 - (UIView*)voiceSearchButton {
5146 return _voiceSearchButton; 5149 return _voiceSearchButton;
5147 } 5150 }
5148 5151
5149 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5152 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5150 return [self currentLogoAnimationControllerOwner]; 5153 return [self currentLogoAnimationControllerOwner];
5151 } 5154 }
5152 5155
5153 @end 5156 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698