OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
6 * (http://www.torchmobile.com/) | 6 * (http://www.torchmobile.com/) |
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
10 * Copyright (C) 2011 Google Inc. All rights reserved. | 10 * Copyright (C) 2011 Google Inc. All rights reserved. |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 const FrameLoadRequest& request, | 962 const FrameLoadRequest& request, |
963 NavigationPolicy policy) { | 963 NavigationPolicy policy) { |
964 if (!targetFrame && !request.frameName().isEmpty()) | 964 if (!targetFrame && !request.frameName().isEmpty()) |
965 return true; | 965 return true; |
966 // FIXME: This case is a workaround for the fact that ctrl+clicking a form | 966 // FIXME: This case is a workaround for the fact that ctrl+clicking a form |
967 // submission incorrectly sends as a GET rather than a POST if it creates a | 967 // submission incorrectly sends as a GET rather than a POST if it creates a |
968 // new window in a different process. | 968 // new window in a different process. |
969 return request.form() && policy != NavigationPolicyCurrentTab; | 969 return request.form() && policy != NavigationPolicyCurrentTab; |
970 } | 970 } |
971 | 971 |
| 972 static bool shouldNavigateTargetFrame(NavigationPolicy policy) { |
| 973 switch (policy) { |
| 974 case NavigationPolicyCurrentTab: |
| 975 return true; |
| 976 |
| 977 // Navigation will target a *new* frame (e.g. because of a ctrl-click), |
| 978 // so the target frame can be ignored. |
| 979 case NavigationPolicyNewBackgroundTab: |
| 980 case NavigationPolicyNewForegroundTab: |
| 981 case NavigationPolicyNewWindow: |
| 982 case NavigationPolicyNewPopup: |
| 983 return false; |
| 984 |
| 985 // Navigation won't really target any specific frame, |
| 986 // so the target frame can be ignored. |
| 987 case NavigationPolicyIgnore: |
| 988 case NavigationPolicyDownload: |
| 989 return false; |
| 990 |
| 991 case NavigationPolicyHandledByClient: |
| 992 // Impossible, because at this point we shouldn't yet have called |
| 993 // client()->decidePolicyForNavigation(...). |
| 994 NOTREACHED(); |
| 995 return true; |
| 996 |
| 997 default: |
| 998 NOTREACHED() << policy; |
| 999 return true; |
| 1000 } |
| 1001 } |
| 1002 |
972 static NavigationType determineNavigationType(FrameLoadType frameLoadType, | 1003 static NavigationType determineNavigationType(FrameLoadType frameLoadType, |
973 bool isFormSubmission, | 1004 bool isFormSubmission, |
974 bool haveEvent) { | 1005 bool haveEvent) { |
975 bool isReload = isReloadLoadType(frameLoadType); | 1006 bool isReload = isReloadLoadType(frameLoadType); |
976 bool isBackForward = isBackForwardLoadType(frameLoadType); | 1007 bool isBackForward = isBackForwardLoadType(frameLoadType); |
977 if (isFormSubmission) | 1008 if (isFormSubmission) |
978 return (isReload || isBackForward) ? NavigationTypeFormResubmitted | 1009 return (isReload || isBackForward) ? NavigationTypeFormResubmitted |
979 : NavigationTypeFormSubmitted; | 1010 : NavigationTypeFormSubmitted; |
980 if (haveEvent) | 1011 if (haveEvent) |
981 return NavigationTypeLinkClicked; | 1012 return NavigationTypeLinkClicked; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 return; | 1089 return; |
1059 } | 1090 } |
1060 | 1091 |
1061 FrameLoadRequest request(passedRequest); | 1092 FrameLoadRequest request(passedRequest); |
1062 request.resourceRequest().setHasUserGesture( | 1093 request.resourceRequest().setHasUserGesture( |
1063 UserGestureIndicator::processingUserGesture()); | 1094 UserGestureIndicator::processingUserGesture()); |
1064 | 1095 |
1065 if (!prepareRequestForThisFrame(request)) | 1096 if (!prepareRequestForThisFrame(request)) |
1066 return; | 1097 return; |
1067 | 1098 |
1068 Frame* targetFrame = request.form() | |
1069 ? nullptr | |
1070 : m_frame->findFrameForNavigation( | |
1071 AtomicString(request.frameName()), *m_frame); | |
1072 | |
1073 if (isBackForwardLoadType(frameLoadType)) { | 1099 if (isBackForwardLoadType(frameLoadType)) { |
1074 DCHECK(historyItem); | 1100 DCHECK(historyItem); |
1075 m_provisionalItem = historyItem; | 1101 m_provisionalItem = historyItem; |
1076 } | 1102 } |
1077 | 1103 |
1078 if (targetFrame && targetFrame != m_frame) { | 1104 Frame* targetFrame = request.form() |
| 1105 ? nullptr |
| 1106 : m_frame->findFrameForNavigation( |
| 1107 AtomicString(request.frameName()), *m_frame); |
| 1108 NavigationPolicy policy = navigationPolicyForRequest(request); |
| 1109 if (targetFrame && targetFrame != m_frame && |
| 1110 shouldNavigateTargetFrame(policy)) { |
1079 bool wasInSamePage = targetFrame->page() == m_frame->page(); | 1111 bool wasInSamePage = targetFrame->page() == m_frame->page(); |
1080 | 1112 |
1081 request.setFrameName("_self"); | 1113 request.setFrameName("_self"); |
1082 targetFrame->navigate(request); | 1114 targetFrame->navigate(request); |
1083 Page* page = targetFrame->page(); | 1115 Page* page = targetFrame->page(); |
1084 if (!wasInSamePage && page) | 1116 if (!wasInSamePage && page) |
1085 page->chromeClient().focus(); | 1117 page->chromeClient().focus(); |
1086 return; | 1118 return; |
1087 } | 1119 } |
1088 | 1120 |
1089 setReferrerForFrameRequest(request); | 1121 setReferrerForFrameRequest(request); |
1090 | 1122 |
1091 FrameLoadType newLoadType = (frameLoadType == FrameLoadTypeStandard) | |
1092 ? determineFrameLoadType(request) | |
1093 : frameLoadType; | |
1094 NavigationPolicy policy = navigationPolicyForRequest(request); | |
1095 if (shouldOpenInNewWindow(targetFrame, request, policy)) { | 1123 if (shouldOpenInNewWindow(targetFrame, request, policy)) { |
1096 if (policy == NavigationPolicyDownload) { | 1124 if (policy == NavigationPolicyDownload) { |
1097 client()->loadURLExternally(request.resourceRequest(), | 1125 client()->loadURLExternally(request.resourceRequest(), |
1098 NavigationPolicyDownload, String(), false); | 1126 NavigationPolicyDownload, String(), false); |
1099 } else { | 1127 } else { |
1100 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliary); | 1128 request.resourceRequest().setFrameType(WebURLRequest::FrameTypeAuxiliary); |
1101 createWindowForRequest(request, *m_frame, policy); | 1129 createWindowForRequest(request, *m_frame, policy); |
1102 } | 1130 } |
1103 return; | 1131 return; |
1104 } | 1132 } |
1105 | 1133 |
1106 const KURL& url = request.resourceRequest().url(); | 1134 const KURL& url = request.resourceRequest().url(); |
| 1135 FrameLoadType newLoadType = (frameLoadType == FrameLoadTypeStandard) |
| 1136 ? determineFrameLoadType(request) |
| 1137 : frameLoadType; |
1107 bool sameDocumentHistoryNavigation = | 1138 bool sameDocumentHistoryNavigation = |
1108 isBackForwardLoadType(newLoadType) && | 1139 isBackForwardLoadType(newLoadType) && |
1109 historyLoadType == HistorySameDocumentLoad; | 1140 historyLoadType == HistorySameDocumentLoad; |
1110 bool sameDocumentNavigation = | 1141 bool sameDocumentNavigation = |
1111 policy == NavigationPolicyCurrentTab && | 1142 policy == NavigationPolicyCurrentTab && |
1112 shouldPerformFragmentNavigation(request.form(), | 1143 shouldPerformFragmentNavigation(request.form(), |
1113 request.resourceRequest().httpMethod(), | 1144 request.resourceRequest().httpMethod(), |
1114 newLoadType, url); | 1145 newLoadType, url); |
1115 | 1146 |
1116 // Perform same document navigation. | 1147 // Perform same document navigation. |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 m_documentLoader ? m_documentLoader->url() : String()); | 1937 m_documentLoader ? m_documentLoader->url() : String()); |
1907 return tracedValue; | 1938 return tracedValue; |
1908 } | 1939 } |
1909 | 1940 |
1910 inline void FrameLoader::takeObjectSnapshot() const { | 1941 inline void FrameLoader::takeObjectSnapshot() const { |
1911 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, | 1942 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, |
1912 toTracedValue()); | 1943 toTracedValue()); |
1913 } | 1944 } |
1914 | 1945 |
1915 } // namespace blink | 1946 } // namespace blink |
OLD | NEW |