OLD | NEW |
---|---|
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 Loading... | |
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, we can only fall back to the |
Eugene But (OOO till 7-30)
2015/09/14 21:48:55
NIT: please do not use we in the comments.
| |
454 // default navigation mechanism. | |
454 web::WKBackForwardListItemHolder* holder = | 455 web::WKBackForwardListItemHolder* holder = |
455 [self currentBackForwardListItemHolder]; | 456 [self currentBackForwardListItemHolder]; |
456 if (!holder->back_forward_list_item()) { | 457 if (!holder->back_forward_list_item() || |
458 ![self isBackForwardListItemValid:holder->back_forward_list_item()]) { | |
457 defaultNavigationBlock(); | 459 defaultNavigationBlock(); |
458 return; | 460 return; |
459 } | 461 } |
460 | 462 |
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 = ^{ | 463 ProceduralBlock webViewNavigationBlock = ^{ |
466 // If the current navigation URL is the same as the URL of the visible | 464 // If the current navigation URL is the same as the URL of the visible |
467 // page, that means the user requested a reload. |goToBackForwardListItem| | 465 // 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, | 466 // will be a no-op when it is passed the current back forward list item, |
469 // so |reload| must be explicitly called. | 467 // so |reload| must be explicitly called. |
470 [self registerLoadRequest:[self currentNavigationURL] | 468 [self registerLoadRequest:[self currentNavigationURL] |
471 referrer:[self currentSessionEntryReferrer] | 469 referrer:[self currentSessionEntryReferrer] |
472 transition:[self currentTransition]]; | 470 transition:[self currentTransition]]; |
473 if ([self currentNavigationURL] == net::GURLWithNSURL([_wkWebView URL])) { | 471 if ([self currentNavigationURL] == net::GURLWithNSURL([_wkWebView URL])) { |
474 [_wkWebView reload]; | 472 [_wkWebView reload]; |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1418 placeholderText:defaultText | 1416 placeholderText:defaultText |
1419 requestURL: | 1417 requestURL: |
1420 net::GURLWithNSURL(frame.request.URL) | 1418 net::GURLWithNSURL(frame.request.URL) |
1421 completionHandler:completionHandler]; | 1419 completionHandler:completionHandler]; |
1422 } else if (completionHandler) { | 1420 } else if (completionHandler) { |
1423 completionHandler(nil); | 1421 completionHandler(nil); |
1424 } | 1422 } |
1425 } | 1423 } |
1426 | 1424 |
1427 @end | 1425 @end |
OLD | NEW |