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/web/web_state/ui/crw_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
6 | 6 |
7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
8 | 8 |
9 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "base/strings/utf_string_conversions.h" | 37 #include "base/strings/utf_string_conversions.h" |
38 #include "base/time/time.h" | 38 #include "base/time/time.h" |
39 #include "base/values.h" | 39 #include "base/values.h" |
40 #import "ios/net/http_response_headers_util.h" | 40 #import "ios/net/http_response_headers_util.h" |
41 #import "ios/net/nsurlrequest_util.h" | 41 #import "ios/net/nsurlrequest_util.h" |
42 #include "ios/web/history_state_util.h" | 42 #include "ios/web/history_state_util.h" |
43 #import "ios/web/interstitials/web_interstitial_impl.h" | 43 #import "ios/web/interstitials/web_interstitial_impl.h" |
44 #import "ios/web/navigation/crw_session_controller.h" | 44 #import "ios/web/navigation/crw_session_controller.h" |
45 #import "ios/web/navigation/navigation_item_impl.h" | 45 #import "ios/web/navigation/navigation_item_impl.h" |
46 #import "ios/web/navigation/navigation_manager_impl.h" | 46 #import "ios/web/navigation/navigation_manager_impl.h" |
| 47 #include "ios/web/navigation/navigation_manager_util.h" |
47 #include "ios/web/net/cert_host_pair.h" | 48 #include "ios/web/net/cert_host_pair.h" |
48 #import "ios/web/net/crw_cert_verification_controller.h" | 49 #import "ios/web/net/crw_cert_verification_controller.h" |
49 #import "ios/web/net/crw_ssl_status_updater.h" | 50 #import "ios/web/net/crw_ssl_status_updater.h" |
50 #include "ios/web/public/browser_state.h" | 51 #include "ios/web/public/browser_state.h" |
51 #include "ios/web/public/favicon_url.h" | 52 #include "ios/web/public/favicon_url.h" |
52 #import "ios/web/public/java_script_dialog_presenter.h" | 53 #import "ios/web/public/java_script_dialog_presenter.h" |
53 #import "ios/web/public/navigation_item.h" | 54 #import "ios/web/public/navigation_item.h" |
54 #import "ios/web/public/navigation_manager.h" | 55 #import "ios/web/public/navigation_manager.h" |
55 #import "ios/web/public/origin_util.h" | 56 #import "ios/web/public/origin_util.h" |
56 #include "ios/web/public/referrer.h" | 57 #include "ios/web/public/referrer.h" |
(...skipping 4558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4615 } | 4616 } |
4616 | 4617 |
4617 if (isLastNavigation) { | 4618 if (isLastNavigation) { |
4618 [self webPageChanged]; | 4619 [self webPageChanged]; |
4619 } else { | 4620 } else { |
4620 // WKWebView has more than one in progress navigation, and committed | 4621 // WKWebView has more than one in progress navigation, and committed |
4621 // navigation was not the latest. Change last committed item to one that | 4622 // navigation was not the latest. Change last committed item to one that |
4622 // corresponds to committed navigation. | 4623 // corresponds to committed navigation. |
4623 web::NavigationContextImpl* context = | 4624 web::NavigationContextImpl* context = |
4624 [_navigationStates contextForNavigation:navigation]; | 4625 [_navigationStates contextForNavigation:navigation]; |
4625 for (int i = 0; i < self.navigationManagerImpl->GetItemCount(); i++) { | 4626 int itemIndex = web::GetCommittedItemIndexWithUniqueID( |
4626 if (self.navigationManagerImpl->GetItemAtIndex(i)->GetUniqueID() == | 4627 self.navigationManagerImpl, context->GetNavigationItemUniqueID()); |
4627 context->GetNavigationItemUniqueID()) { | 4628 // Do not discard pending entry, because another pending navigation is still |
4628 // Do not discard pending entry, because another pending navigation is | 4629 // in progress and will commit or fail soon. |
4629 // still in progress and will commit or fail soon. | 4630 [self.sessionController goToItemAtIndex:itemIndex |
4630 [self.sessionController goToItemAtIndex:i discardNonCommittedItems:NO]; | 4631 discardNonCommittedItems:NO]; |
4631 break; | |
4632 } | |
4633 } | |
4634 } | 4632 } |
4635 | 4633 |
4636 self.webStateImpl->OnNavigationFinished(context); | 4634 self.webStateImpl->OnNavigationFinished(context); |
4637 | 4635 |
4638 [self updateSSLStatusForCurrentNavigationItem]; | 4636 [self updateSSLStatusForCurrentNavigationItem]; |
4639 | 4637 |
4640 // Attempt to update the HTML5 history state. | 4638 // Attempt to update the HTML5 history state. |
4641 [self updateHTML5HistoryState]; | 4639 [self updateHTML5HistoryState]; |
4642 | 4640 |
4643 // This is the point where pending entry has been committed, and navigation | 4641 // This is the point where pending entry has been committed, and navigation |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5241 - (NSUInteger)observerCount { | 5239 - (NSUInteger)observerCount { |
5242 DCHECK_EQ(_observerBridges.size(), [_observers count]); | 5240 DCHECK_EQ(_observerBridges.size(), [_observers count]); |
5243 return [_observers count]; | 5241 return [_observers count]; |
5244 } | 5242 } |
5245 | 5243 |
5246 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5244 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
5247 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5245 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
5248 } | 5246 } |
5249 | 5247 |
5250 @end | 5248 @end |
OLD | NEW |