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