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

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

Issue 2692803004: Refactor callbacks for opening a new window. (Closed)
Patch Set: Addressed review comment 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 4290 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 } 4301 }
4302 } 4302 }
4303 4303
4304 #if !defined(NDEBUG) 4304 #if !defined(NDEBUG)
4305 - (void)viewSource { 4305 - (void)viewSource {
4306 Tab* tab = [_model currentTab]; 4306 Tab* tab = [_model currentTab];
4307 DCHECK(tab); 4307 DCHECK(tab);
4308 CRWWebController* webController = tab.webController; 4308 CRWWebController* webController = tab.webController;
4309 NSString* script = @"document.documentElement.outerHTML;"; 4309 NSString* script = @"document.documentElement.outerHTML;";
4310 base::WeakNSObject<Tab> weakTab(tab); 4310 base::WeakNSObject<Tab> weakTab(tab);
4311 base::WeakNSObject<BrowserViewController> weakSelf(self);
4311 web::JavaScriptResultBlock completionHandlerBlock = ^(id result, NSError*) { 4312 web::JavaScriptResultBlock completionHandlerBlock = ^(id result, NSError*) {
4312 base::scoped_nsobject<Tab> strongTab([weakTab retain]); 4313 base::scoped_nsobject<Tab> strongTab([weakTab retain]);
4313 if (!strongTab) 4314 if (!strongTab)
4314 return; 4315 return;
4315 if (![result isKindOfClass:[NSString class]]) 4316 if (![result isKindOfClass:[NSString class]])
4316 result = @"Not an HTML page"; 4317 result = @"Not an HTML page";
4317 std::string base64HTML; 4318 std::string base64HTML;
4318 base::Base64Encode(base::SysNSStringToUTF8(result), &base64HTML); 4319 base::Base64Encode(base::SysNSStringToUTF8(result), &base64HTML);
4319 GURL URL(std::string("data:text/plain;charset=utf-8;base64,") + base64HTML); 4320 GURL URL(std::string("data:text/plain;charset=utf-8;base64,") + base64HTML);
4320 web::Referrer referrer([strongTab url], web::ReferrerPolicyDefault); 4321 web::Referrer referrer([strongTab url], web::ReferrerPolicyDefault);
4321 [strongTab webPageOrderedOpen:URL 4322
4322 referrer:referrer 4323 [[weakSelf tabModel]
4323 windowName:nil 4324 insertOrUpdateTabWithURL:URL
4324 inBackground:NO]; 4325 referrer:referrer
4326 transition:ui::PAGE_TRANSITION_LINK
4327 windowName:nil
4328 opener:strongTab
4329 openedByDOM:YES
4330 atIndex:TabModelConstants::kTabPositionAutomatically
4331 inBackground:NO];
4325 }; 4332 };
4326 [webController executeJavaScript:script 4333 [webController executeJavaScript:script
4327 completionHandler:completionHandlerBlock]; 4334 completionHandler:completionHandlerBlock];
4328 } 4335 }
4329 #endif // !defined(NDEBUG) 4336 #endif // !defined(NDEBUG)
4330 4337
4331 - (void)startVoiceSearch { 4338 - (void)startVoiceSearch {
4332 // Delay Voice Search until new tab animations have finished. 4339 // Delay Voice Search until new tab animations have finished.
4333 if (_inNewTabAnimation) { 4340 if (_inNewTabAnimation) {
4334 _startVoiceSearchAfterNewTabAnimation = YES; 4341 _startVoiceSearchAfterNewTabAnimation = YES;
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
4997 5004
4998 - (UIView*)voiceSearchButton { 5005 - (UIView*)voiceSearchButton {
4999 return _voiceSearchButton; 5006 return _voiceSearchButton;
5000 } 5007 }
5001 5008
5002 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5009 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5003 return [self currentLogoAnimationControllerOwner]; 5010 return [self currentLogoAnimationControllerOwner];
5004 } 5011 }
5005 5012
5006 @end 5013 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698