| OLD | NEW |
| 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 Loading... |
| 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 NSData* data, const int response_code) { |
| 3059 |
| 3058 DCHECK(data); | 3060 DCHECK(data); |
| 3059 dispatch_async(dispatch_get_main_queue(), ^{ | 3061 dispatch_async(dispatch_get_main_queue(), ^{ |
| 3060 [weakSelf searchByImageData:data atURL:image_source_url]; | 3062 [weakSelf searchByImageData:data atURL:image_source_url]; |
| 3061 }); | 3063 }); |
| 3062 }; | 3064 }; |
| 3063 _imageFetcher->FetchImageDataWebpDecoded( | 3065 _imageFetcher->FetchImageDataWebpDecoded( |
| 3064 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer), | 3066 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer), |
| 3065 web::PolicyForNavigation(url, referrer)); | 3067 web::PolicyForNavigation(url, referrer)); |
| 3066 } | 3068 } |
| 3067 | 3069 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3103 search_args, templateUrlService->search_terms_data(), &post_content)); | 3105 search_args, templateUrlService->search_terms_data(), &post_content)); |
| 3104 [self addSelectedTabWithURL:result | 3106 [self addSelectedTabWithURL:result |
| 3105 postData:&post_content | 3107 postData:&post_content |
| 3106 transition:ui::PAGE_TRANSITION_TYPED]; | 3108 transition:ui::PAGE_TRANSITION_TYPED]; |
| 3107 } | 3109 } |
| 3108 | 3110 |
| 3109 - (void)saveImageAtURL:(const GURL&)url | 3111 - (void)saveImageAtURL:(const GURL&)url |
| 3110 referrer:(const web::Referrer&)referrer { | 3112 referrer:(const web::Referrer&)referrer { |
| 3111 DCHECK(url.is_valid()); | 3113 DCHECK(url.is_valid()); |
| 3112 | 3114 |
| 3113 image_fetcher::IOSImageDataFetcherCallback callback = ^(NSData* data) { | 3115 image_fetcher::IOSImageDataFetcherCallback callback = |
| 3114 DCHECK(data); | 3116 ^(NSData* data, const int response_code) { |
| 3117 DCHECK(data); |
| 3115 | 3118 |
| 3116 [self managePermissionAndSaveImage:data]; | 3119 [self managePermissionAndSaveImage:data]; |
| 3117 }; | 3120 }; |
| 3118 _imageFetcher->FetchImageDataWebpDecoded( | 3121 _imageFetcher->FetchImageDataWebpDecoded( |
| 3119 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer), | 3122 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer), |
| 3120 web::PolicyForNavigation(url, referrer)); | 3123 web::PolicyForNavigation(url, referrer)); |
| 3121 } | 3124 } |
| 3122 | 3125 |
| 3123 - (void)managePermissionAndSaveImage:(NSData*)data { | 3126 - (void)managePermissionAndSaveImage:(NSData*)data { |
| 3124 switch ([PHPhotoLibrary authorizationStatus]) { | 3127 switch ([PHPhotoLibrary authorizationStatus]) { |
| 3125 // User was never asked for permission to access photos. | 3128 // User was never asked for permission to access photos. |
| 3126 case PHAuthorizationStatusNotDetermined: | 3129 case PHAuthorizationStatusNotDetermined: |
| 3127 [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { | 3130 [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { |
| (...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |