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

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

Powered by Google App Engine
This is Rietveld 408576698