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

Side by Side Diff: Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp

Issue 14264012: Create errors (especially cancellation errors) internally to WebCore, rather (Closed) Base URL: svn://svn.chromium.org/blink/trunk/
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #include <public/WebVector.h> 93 #include <public/WebVector.h>
94 #include <v8.h> 94 #include <v8.h>
95 #include <wtf/StringExtras.h> 95 #include <wtf/StringExtras.h>
96 #include <wtf/text/CString.h> 96 #include <wtf/text/CString.h>
97 #include <wtf/text/WTFString.h> 97 #include <wtf/text/WTFString.h>
98 98
99 using namespace WebCore; 99 using namespace WebCore;
100 100
101 namespace WebKit { 101 namespace WebKit {
102 102
103 // Domain for internal error codes.
104 static const char internalErrorDomain[] = "WebKit";
105
106 // An internal error code. Used to note a policy change error resulting from
107 // dispatchDecidePolicyForMIMEType not passing the PolicyUse option.
108 enum {
109 PolicyChangeError = -10000,
110 };
111
112 FrameLoaderClientImpl::FrameLoaderClientImpl(WebFrameImpl* frame) 103 FrameLoaderClientImpl::FrameLoaderClientImpl(WebFrameImpl* frame)
113 : m_webFrame(frame) 104 : m_webFrame(frame)
114 , m_sentInitialResponseToPlugin(false) 105 , m_sentInitialResponseToPlugin(false)
115 , m_nextNavigationPolicy(WebNavigationPolicyIgnore) 106 , m_nextNavigationPolicy(WebNavigationPolicyIgnore)
116 { 107 {
117 } 108 }
118 109
119 FrameLoaderClientImpl::~FrameLoaderClientImpl() 110 FrameLoaderClientImpl::~FrameLoaderClientImpl()
120 { 111 {
121 } 112 }
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 } 743 }
753 744
754 void FrameLoaderClientImpl::dispatchDidFailProvisionalLoad( 745 void FrameLoaderClientImpl::dispatchDidFailProvisionalLoad(
755 const ResourceError& error) 746 const ResourceError& error)
756 { 747 {
757 748
758 // If a policy change occured, then we do not want to inform the plugin 749 // If a policy change occured, then we do not want to inform the plugin
759 // delegate. See http://b/907789 for details. FIXME: This means the 750 // delegate. See http://b/907789 for details. FIXME: This means the
760 // plugin won't receive NPP_URLNotify, which seems like it could result in 751 // plugin won't receive NPP_URLNotify, which seems like it could result in
761 // a memory leak in the plugin!! 752 // a memory leak in the plugin!!
762 if (error.domain() == internalErrorDomain 753 if (error.domain() == errorDomainWebKitInternal
763 && error.errorCode() == PolicyChangeError) { 754 && error.errorCode() == policyChangeError) {
764 m_webFrame->didFail(cancelledError(error.failingURL()), true); 755 m_webFrame->didFail(ResourceError::createCancelledError(error.failingURL ()), true);
765 return; 756 return;
766 } 757 }
767 758
768 OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver(); 759 OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver();
769 m_webFrame->didFail(error, true); 760 m_webFrame->didFail(error, true);
770 if (observer) 761 if (observer)
771 observer->didFailLoading(error); 762 observer->didFailLoading(error);
772 } 763 }
773 764
774 void FrameLoaderClientImpl::dispatchDidFailLoad(const ResourceError& error) 765 void FrameLoaderClientImpl::dispatchDidFailLoad(const ResourceError& error)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 WrappedResourceRequest webreq(request); 947 WrappedResourceRequest webreq(request);
957 m_webFrame->client()->loadURLExternally(m_webFrame, webreq, navi gationPolicy); 948 m_webFrame->client()->loadURLExternally(m_webFrame, webreq, navi gationPolicy);
958 } 949 }
959 policyAction = PolicyIgnore; 950 policyAction = PolicyIgnore;
960 } 951 }
961 } 952 }
962 953
963 (m_webFrame->frame()->loader()->policyChecker()->*function)(policyAction); 954 (m_webFrame->frame()->loader()->policyChecker()->*function)(policyAction);
964 } 955 }
965 956
966 void FrameLoaderClientImpl::dispatchUnableToImplementPolicy(const ResourceError& error)
967 {
968 m_webFrame->client()->unableToImplementPolicyWithError(m_webFrame, error);
969 }
970
971 void FrameLoaderClientImpl::dispatchWillRequestResource(CachedResourceRequest* r equest) 957 void FrameLoaderClientImpl::dispatchWillRequestResource(CachedResourceRequest* r equest)
972 { 958 {
973 if (m_webFrame->client()) { 959 if (m_webFrame->client()) {
974 WebCachedURLRequest urlRequest(request); 960 WebCachedURLRequest urlRequest(request);
975 m_webFrame->client()->willRequestResource(m_webFrame, urlRequest); 961 m_webFrame->client()->willRequestResource(m_webFrame, urlRequest);
976 } 962 }
977 } 963 }
978 964
979 void FrameLoaderClientImpl::dispatchWillSendSubmitEvent(PassRefPtr<FormState> pr pFormState) 965 void FrameLoaderClientImpl::dispatchWillSendSubmitEvent(PassRefPtr<FormState> pr pFormState)
980 { 966 {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 bool preventDefault = false; 1032 bool preventDefault = false;
1047 m_webFrame->client()->didReceiveDocumentData(m_webFrame, data, lengt h, preventDefault); 1033 m_webFrame->client()->didReceiveDocumentData(m_webFrame, data, lengt h, preventDefault);
1048 if (!preventDefault) 1034 if (!preventDefault)
1049 m_webFrame->commitDocumentData(data, length); 1035 m_webFrame->commitDocumentData(data, length);
1050 } 1036 }
1051 } 1037 }
1052 1038
1053 // If we are sending data to MediaDocument, we should stop here 1039 // If we are sending data to MediaDocument, we should stop here
1054 // and cancel the request. 1040 // and cancel the request.
1055 if (m_webFrame->frame()->document()->isMediaDocument()) 1041 if (m_webFrame->frame()->document()->isMediaDocument())
1056 loader->cancelMainResourceLoad(pluginWillHandleLoadError(loader->respons e())); 1042 loader->cancelMainResourceLoad(ResourceError::createCancelledError(loade r->url()));
1057 1043
1058 // The plugin widget could have been created in the m_webFrame->DidReceiveDa ta 1044 // The plugin widget could have been created in the m_webFrame->DidReceiveDa ta
1059 // function. 1045 // function.
1060 if (m_pluginWidget) { 1046 if (m_pluginWidget) {
1061 if (!m_sentInitialResponseToPlugin) { 1047 if (!m_sentInitialResponseToPlugin) {
1062 m_sentInitialResponseToPlugin = true; 1048 m_sentInitialResponseToPlugin = true;
1063 m_pluginWidget->didReceiveResponse( 1049 m_pluginWidget->didReceiveResponse(
1064 m_webFrame->frame()->loader()->activeDocumentLoader()->response( )); 1050 m_webFrame->frame()->loader()->activeDocumentLoader()->response( ));
1065 } 1051 }
1066 1052
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 if (m_webFrame->client()) 1121 if (m_webFrame->client())
1136 m_webFrame->client()->didRunInsecureContent(m_webFrame, WebSecurityOrigi n(origin), insecureURL); 1122 m_webFrame->client()->didRunInsecureContent(m_webFrame, WebSecurityOrigi n(origin), insecureURL);
1137 } 1123 }
1138 1124
1139 void FrameLoaderClientImpl::didDetectXSS(const KURL& insecureURL, bool didBlockE ntirePage) 1125 void FrameLoaderClientImpl::didDetectXSS(const KURL& insecureURL, bool didBlockE ntirePage)
1140 { 1126 {
1141 if (m_webFrame->client()) 1127 if (m_webFrame->client())
1142 m_webFrame->client()->didDetectXSS(m_webFrame, insecureURL, didBlockEnti rePage); 1128 m_webFrame->client()->didDetectXSS(m_webFrame, insecureURL, didBlockEnti rePage);
1143 } 1129 }
1144 1130
1145 ResourceError FrameLoaderClientImpl::cancelledError(const ResourceRequest& reque st)
1146 {
1147 if (!m_webFrame->client())
1148 return ResourceError();
1149
1150 return m_webFrame->client()->cancelledError(
1151 m_webFrame, WrappedResourceRequest(request));
1152 }
1153
1154 ResourceError FrameLoaderClientImpl::cannotShowURLError(const ResourceRequest& r equest)
1155 {
1156 if (!m_webFrame->client())
1157 return ResourceError();
1158
1159 return m_webFrame->client()->cannotHandleRequestError(
1160 m_webFrame, WrappedResourceRequest(request));
1161 }
1162
1163 ResourceError FrameLoaderClientImpl::interruptedForPolicyChangeError(
1164 const ResourceRequest& request)
1165 {
1166 return ResourceError(internalErrorDomain, PolicyChangeError,
1167 request.url().string(), String());
1168 }
1169
1170 ResourceError FrameLoaderClientImpl::cannotShowMIMETypeError(const ResourceRespo nse&)
1171 {
1172 // FIXME
1173 return ResourceError();
1174 }
1175
1176 ResourceError FrameLoaderClientImpl::fileDoesNotExistError(const ResourceRespons e&)
1177 {
1178 // FIXME
1179 return ResourceError();
1180 }
1181
1182 ResourceError FrameLoaderClientImpl::pluginWillHandleLoadError(const ResourceRes ponse&)
1183 {
1184 // FIXME
1185 return ResourceError();
1186 }
1187
1188 bool FrameLoaderClientImpl::shouldFallBack(const ResourceError& error)
Nate Chapin 2013/04/15 17:44:32 This function was only called once, so it is inlin
1189 {
1190 // This method is called when we fail to load the URL for an <object> tag
1191 // that has fallback content (child elements) and is being loaded as a frame .
1192 // The error parameter indicates the reason for the load failure.
1193 // We should let the fallback content load only if this wasn't a cancelled
1194 // request.
1195 // Note: The mac version also has a case for "WebKitErrorPluginWillHandleLoa d"
1196 ResourceError c = cancelledError(ResourceRequest());
1197 return error.errorCode() != c.errorCode() || error.domain() != c.domain();
1198 }
1199
1200 bool FrameLoaderClientImpl::canHandleRequest(const ResourceRequest& request) con st
1201 {
1202 return m_webFrame->client()->canHandleRequest(
1203 m_webFrame, WrappedResourceRequest(request));
1204 }
1205
1206 bool FrameLoaderClientImpl::canShowMIMEType(const String& mimeType) const 1131 bool FrameLoaderClientImpl::canShowMIMEType(const String& mimeType) const
1207 { 1132 {
1208 // This method is called to determine if the media type can be shown 1133 // This method is called to determine if the media type can be shown
1209 // "internally" (i.e. inside the browser) regardless of whether or not the 1134 // "internally" (i.e. inside the browser) regardless of whether or not the
1210 // browser or a plugin is doing the rendering. 1135 // browser or a plugin is doing the rendering.
1211 1136
1212 // mimeType strings are supposed to be ASCII, but if they are not for some 1137 // mimeType strings are supposed to be ASCII, but if they are not for some
1213 // reason, then it just means that the mime type will fail all of these "is 1138 // reason, then it just means that the mime type will fail all of these "is
1214 // supported" checks and go down the path of an unhandled mime type. 1139 // supported" checks and go down the path of an unhandled mime type.
1215 if (WebKit::Platform::current()->mimeRegistry()->supportsMIMEType(mimeType) == WebMimeRegistry::IsSupported) 1140 if (WebKit::Platform::current()->mimeRegistry()->supportsMIMEType(mimeType) == WebMimeRegistry::IsSupported)
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 m_webFrame->client()->didLoseWebGLContext(m_webFrame, arbRobustnessConte xtLostReason); 1409 m_webFrame->client()->didLoseWebGLContext(m_webFrame, arbRobustnessConte xtLostReason);
1485 } 1410 }
1486 1411
1487 void FrameLoaderClientImpl::dispatchWillInsertBody() 1412 void FrameLoaderClientImpl::dispatchWillInsertBody()
1488 { 1413 {
1489 if (m_webFrame->client()) 1414 if (m_webFrame->client())
1490 m_webFrame->client()->willInsertBody(m_webFrame); 1415 m_webFrame->client()->willInsertBody(m_webFrame);
1491 } 1416 }
1492 1417
1493 } // namespace WebKit 1418 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698