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

Side by Side Diff: ios/web/web_state/ui/crw_wk_web_view_web_controller.mm

Issue 1307103004: Fixing WKWebView QuickBack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing comment Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/web/web_state/ui/crw_wk_web_view_web_controller.h" 5 #import "ios/web/web_state/ui/crw_wk_web_view_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #include "base/ios/ios_util.h" 9 #include "base/ios/ios_util.h"
10 #include "base/ios/weak_nsobject.h" 10 #include "base/ios/weak_nsobject.h"
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 - (void)loadRequestForCurrentNavigationItem { 442 - (void)loadRequestForCurrentNavigationItem {
443 DCHECK(self.webView && !self.nativeController); 443 DCHECK(self.webView && !self.nativeController);
444 444
445 ProceduralBlock defaultNavigationBlock = ^{ 445 ProceduralBlock defaultNavigationBlock = ^{
446 [self registerLoadRequest:[self currentNavigationURL] 446 [self registerLoadRequest:[self currentNavigationURL]
447 referrer:[self currentSessionEntryReferrer] 447 referrer:[self currentSessionEntryReferrer]
448 transition:[self currentTransition]]; 448 transition:[self currentTransition]];
449 [self loadRequest:[self requestForCurrentNavigationItem]]; 449 [self loadRequest:[self requestForCurrentNavigationItem]];
450 }; 450 };
451 451
452 // If there is no corresponding WKBackForwardListItem, fall back to 452 // If there is no corresponding WKBackForwardListItem, or the item is not in
453 // the standard loading mechanism. 453 // the current WKWebView's back-forward list, navigating using WKWebView API
454 // is not possible. In this case, fall back to the default navigation
455 // mechanism.
454 web::WKBackForwardListItemHolder* holder = 456 web::WKBackForwardListItemHolder* holder =
455 [self currentBackForwardListItemHolder]; 457 [self currentBackForwardListItemHolder];
456 if (!holder->back_forward_list_item()) { 458 if (!holder->back_forward_list_item() ||
459 ![self isBackForwardListItemValid:holder->back_forward_list_item()]) {
457 defaultNavigationBlock(); 460 defaultNavigationBlock();
458 return; 461 return;
459 } 462 }
460 463
461 // The current back-forward list item MUST be in the WKWebView's back-forward
462 // list to be valid.
463 DCHECK([self isBackForwardListItemValid:holder->back_forward_list_item()]);
464
465 ProceduralBlock webViewNavigationBlock = ^{ 464 ProceduralBlock webViewNavigationBlock = ^{
466 // If the current navigation URL is the same as the URL of the visible 465 // If the current navigation URL is the same as the URL of the visible
467 // page, that means the user requested a reload. |goToBackForwardListItem| 466 // page, that means the user requested a reload. |goToBackForwardListItem|
468 // will be a no-op when it is passed the current back forward list item, 467 // will be a no-op when it is passed the current back forward list item,
469 // so |reload| must be explicitly called. 468 // so |reload| must be explicitly called.
470 [self registerLoadRequest:[self currentNavigationURL] 469 [self registerLoadRequest:[self currentNavigationURL]
471 referrer:[self currentSessionEntryReferrer] 470 referrer:[self currentSessionEntryReferrer]
472 transition:[self currentTransition]]; 471 transition:[self currentTransition]];
473 if ([self currentNavigationURL] == net::GURLWithNSURL([_wkWebView URL])) { 472 if ([self currentNavigationURL] == net::GURLWithNSURL([_wkWebView URL])) {
474 [_wkWebView reload]; 473 [_wkWebView reload];
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 placeholderText:defaultText 1417 placeholderText:defaultText
1419 requestURL: 1418 requestURL:
1420 net::GURLWithNSURL(frame.request.URL) 1419 net::GURLWithNSURL(frame.request.URL)
1421 completionHandler:completionHandler]; 1420 completionHandler:completionHandler];
1422 } else if (completionHandler) { 1421 } else if (completionHandler) {
1423 completionHandler(nil); 1422 completionHandler(nil);
1424 } 1423 }
1425 } 1424 }
1426 1425
1427 @end 1426 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698