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 2607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2618 Record(ACTION_OPEN_IMAGE_IN_NEW_TAB, isImage, isLink); | 2618 Record(ACTION_OPEN_IMAGE_IN_NEW_TAB, isImage, isLink); |
2619 [weakSelf webPageOrderedOpen:imageUrl | 2619 [weakSelf webPageOrderedOpen:imageUrl |
2620 referrer:referrer | 2620 referrer:referrer |
2621 inBackground:true | 2621 inBackground:true |
2622 appendTo:kCurrentTab]; | 2622 appendTo:kCurrentTab]; |
2623 }; | 2623 }; |
2624 [_contextMenuCoordinator addItemWithTitle:title action:action]; | 2624 [_contextMenuCoordinator addItemWithTitle:title action:action]; |
2625 | 2625 |
2626 TemplateURLService* service = | 2626 TemplateURLService* service = |
2627 ios::TemplateURLServiceFactory::GetForBrowserState(_browserState); | 2627 ios::TemplateURLServiceFactory::GetForBrowserState(_browserState); |
2628 TemplateURL* defaultURL = service->GetDefaultSearchProvider(); | 2628 const TemplateURL* defaultURL = service->GetDefaultSearchProvider(); |
2629 if (defaultURL && !defaultURL->image_url().empty() && | 2629 if (defaultURL && !defaultURL->image_url().empty() && |
2630 defaultURL->image_url_ref().IsValid(service->search_terms_data())) { | 2630 defaultURL->image_url_ref().IsValid(service->search_terms_data())) { |
2631 title = l10n_util::GetNSStringF(IDS_IOS_CONTEXT_MENU_SEARCHWEBFORIMAGE, | 2631 title = l10n_util::GetNSStringF(IDS_IOS_CONTEXT_MENU_SEARCHWEBFORIMAGE, |
2632 defaultURL->short_name()); | 2632 defaultURL->short_name()); |
2633 action = ^{ | 2633 action = ^{ |
2634 Record(ACTION_SEARCH_BY_IMAGE, isImage, isLink); | 2634 Record(ACTION_SEARCH_BY_IMAGE, isImage, isLink); |
2635 [weakSelf searchByImageAtURL:imageUrl referrer:referrer]; | 2635 [weakSelf searchByImageAtURL:imageUrl referrer:referrer]; |
2636 }; | 2636 }; |
2637 [_contextMenuCoordinator addItemWithTitle:title action:action]; | 2637 [_contextMenuCoordinator addItemWithTitle:title action:action]; |
2638 } | 2638 } |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3183 preserveAspectRatio:YES | 3183 preserveAspectRatio:YES |
3184 trimToFit:NO]; | 3184 trimToFit:NO]; |
3185 imageData = UIImageJPEGRepresentation(image, 1.0); | 3185 imageData = UIImageJPEGRepresentation(image, 1.0); |
3186 } | 3186 } |
3187 | 3187 |
3188 char const* bytes = reinterpret_cast<const char*>([imageData bytes]); | 3188 char const* bytes = reinterpret_cast<const char*>([imageData bytes]); |
3189 std::string byteString(bytes, [imageData length]); | 3189 std::string byteString(bytes, [imageData length]); |
3190 | 3190 |
3191 TemplateURLService* templateUrlService = | 3191 TemplateURLService* templateUrlService = |
3192 ios::TemplateURLServiceFactory::GetForBrowserState(_browserState); | 3192 ios::TemplateURLServiceFactory::GetForBrowserState(_browserState); |
3193 TemplateURL* defaultURL = templateUrlService->GetDefaultSearchProvider(); | 3193 const TemplateURL* defaultURL = |
| 3194 templateUrlService->GetDefaultSearchProvider(); |
3194 DCHECK(!defaultURL->image_url().empty()); | 3195 DCHECK(!defaultURL->image_url().empty()); |
3195 DCHECK(defaultURL->image_url_ref().IsValid( | 3196 DCHECK(defaultURL->image_url_ref().IsValid( |
3196 templateUrlService->search_terms_data())); | 3197 templateUrlService->search_terms_data())); |
3197 TemplateURLRef::SearchTermsArgs search_args(base::ASCIIToUTF16("")); | 3198 TemplateURLRef::SearchTermsArgs search_args(base::ASCIIToUTF16("")); |
3198 search_args.image_url = imageURL; | 3199 search_args.image_url = imageURL; |
3199 search_args.image_thumbnail_content = byteString; | 3200 search_args.image_thumbnail_content = byteString; |
3200 | 3201 |
3201 // Generate the URL and populate |post_content| with the content type and | 3202 // Generate the URL and populate |post_content| with the content type and |
3202 // HTTP body for the request. | 3203 // HTTP body for the request. |
3203 TemplateURLRef::PostContent post_content; | 3204 TemplateURLRef::PostContent post_content; |
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5168 | 5169 |
5169 - (UIView*)voiceSearchButton { | 5170 - (UIView*)voiceSearchButton { |
5170 return _voiceSearchButton; | 5171 return _voiceSearchButton; |
5171 } | 5172 } |
5172 | 5173 |
5173 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5174 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
5174 return [self currentLogoAnimationControllerOwner]; | 5175 return [self currentLogoAnimationControllerOwner]; |
5175 } | 5176 } |
5176 | 5177 |
5177 @end | 5178 @end |
OLD | NEW |