| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 2011, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "public/platform/WebHTTPHeaderVisitor.h" | 44 #include "public/platform/WebHTTPHeaderVisitor.h" |
| 45 #include "public/platform/WebString.h" | 45 #include "public/platform/WebString.h" |
| 46 #include "public/platform/WebURLError.h" | 46 #include "public/platform/WebURLError.h" |
| 47 #include "public/platform/WebURLLoaderClient.h" | 47 #include "public/platform/WebURLLoaderClient.h" |
| 48 #include "public/platform/WebURLRequest.h" | 48 #include "public/platform/WebURLRequest.h" |
| 49 #include "public/web/WebDataSource.h" | 49 #include "public/web/WebDataSource.h" |
| 50 #include "web/WebLocalFrameImpl.h" | 50 #include "web/WebLocalFrameImpl.h" |
| 51 #include "wtf/HashSet.h" | 51 #include "wtf/HashSet.h" |
| 52 #include "wtf/text/WTFString.h" | 52 #include "wtf/text/WTFString.h" |
| 53 | 53 |
| 54 using namespace blink; | |
| 55 using namespace WTF; | |
| 56 | |
| 57 namespace blink { | 54 namespace blink { |
| 58 | 55 |
| 59 namespace { | 56 namespace { |
| 60 | 57 |
| 61 class HTTPRequestHeaderValidator : public WebHTTPHeaderVisitor { | 58 class HTTPRequestHeaderValidator : public WebHTTPHeaderVisitor { |
| 62 WTF_MAKE_NONCOPYABLE(HTTPRequestHeaderValidator); | 59 WTF_MAKE_NONCOPYABLE(HTTPRequestHeaderValidator); |
| 63 public: | 60 public: |
| 64 HTTPRequestHeaderValidator() : m_isSafe(true) { } | 61 HTTPRequestHeaderValidator() : m_isSafe(true) { } |
| 65 | 62 |
| 66 void visitHeader(const WebString& name, const WebString& value); | 63 void visitHeader(const WebString& name, const WebString& value); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 { | 291 { |
| 295 ASSERT(m_frameImpl); | 292 ASSERT(m_frameImpl); |
| 296 } | 293 } |
| 297 | 294 |
| 298 AssociatedURLLoader::~AssociatedURLLoader() | 295 AssociatedURLLoader::~AssociatedURLLoader() |
| 299 { | 296 { |
| 300 cancel(); | 297 cancel(); |
| 301 } | 298 } |
| 302 | 299 |
| 303 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \ | 300 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \ |
| 304 COMPILE_ASSERT(static_cast<int>(blink::webkit_name) == static_cast<int>(blin
k::webcore_name), mismatching_enums) | 301 COMPILE_ASSERT(static_cast<int>(webkit_name) == static_cast<int>(webcore_nam
e), mismatching_enums) |
| 305 | 302 |
| 306 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyDeny,
DenyCrossOriginRequests); | 303 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyDeny,
DenyCrossOriginRequests); |
| 307 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyUseAcc
essControl, UseAccessControl); | 304 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyUseAcc
essControl, UseAccessControl); |
| 308 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyAllow,
AllowCrossOriginRequests); | 305 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyAllow,
AllowCrossOriginRequests); |
| 309 | 306 |
| 310 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::ConsiderPreflight, ConsiderPre
flight); | 307 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::ConsiderPreflight, ConsiderPre
flight); |
| 311 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::ForcePreflight, ForcePreflight
); | 308 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::ForcePreflight, ForcePreflight
); |
| 312 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::PreventPreflight, PreventPrefl
ight); | 309 COMPILE_ASSERT_MATCHING_ENUM(WebURLLoaderOptions::PreventPreflight, PreventPrefl
ight); |
| 313 | 310 |
| 314 void AssociatedURLLoader::loadSynchronously(const WebURLRequest& request, WebURL
Response& response, WebURLError& error, WebData& data) | 311 void AssociatedURLLoader::loadSynchronously(const WebURLRequest& request, WebURL
Response& response, WebURLError& error, WebData& data) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 333 HTTPRequestHeaderValidator validator; | 330 HTTPRequestHeaderValidator validator; |
| 334 newRequest.visitHTTPHeaderFields(&validator); | 331 newRequest.visitHTTPHeaderFields(&validator); |
| 335 allowLoad = validator.isSafe(); | 332 allowLoad = validator.isSafe(); |
| 336 } | 333 } |
| 337 } | 334 } |
| 338 | 335 |
| 339 m_clientAdapter = ClientAdapter::create(this, m_client, m_options); | 336 m_clientAdapter = ClientAdapter::create(this, m_client, m_options); |
| 340 | 337 |
| 341 if (allowLoad) { | 338 if (allowLoad) { |
| 342 ThreadableLoaderOptions options; | 339 ThreadableLoaderOptions options; |
| 343 options.preflightPolicy = static_cast<blink::PreflightPolicy>(m_options.
preflightPolicy); | 340 options.preflightPolicy = static_cast<PreflightPolicy>(m_options.preflig
htPolicy); |
| 344 options.crossOriginRequestPolicy = static_cast<blink::CrossOriginRequest
Policy>(m_options.crossOriginRequestPolicy); | 341 options.crossOriginRequestPolicy = static_cast<CrossOriginRequestPolicy>
(m_options.crossOriginRequestPolicy); |
| 345 | 342 |
| 346 ResourceLoaderOptions resourceLoaderOptions; | 343 ResourceLoaderOptions resourceLoaderOptions; |
| 347 resourceLoaderOptions.sniffContent = m_options.sniffContent ? SniffConte
nt : DoNotSniffContent; | 344 resourceLoaderOptions.sniffContent = m_options.sniffContent ? SniffConte
nt : DoNotSniffContent; |
| 348 resourceLoaderOptions.allowCredentials = m_options.allowCredentials ? Al
lowStoredCredentials : DoNotAllowStoredCredentials; | 345 resourceLoaderOptions.allowCredentials = m_options.allowCredentials ? Al
lowStoredCredentials : DoNotAllowStoredCredentials; |
| 349 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; | 346 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; |
| 350 | 347 |
| 351 const ResourceRequest& webcoreRequest = newRequest.toResourceRequest(); | 348 const ResourceRequest& webcoreRequest = newRequest.toResourceRequest(); |
| 352 if (webcoreRequest.requestContext() == blink::WebURLRequest::RequestCont
extUnspecified) { | 349 if (webcoreRequest.requestContext() == WebURLRequest::RequestContextUnsp
ecified) { |
| 353 // FIXME: We load URLs without setting a TargetType (and therefore a
request context) in several | 350 // FIXME: We load URLs without setting a TargetType (and therefore a
request context) in several |
| 354 // places in content/ (P2PPortAllocatorSession::AllocateLegacyRelayS
ession, for example). Remove | 351 // places in content/ (P2PPortAllocatorSession::AllocateLegacyRelayS
ession, for example). Remove |
| 355 // this once those places are patched up. | 352 // this once those places are patched up. |
| 356 newRequest.setRequestContext(blink::WebURLRequest::RequestContextInt
ernal); | 353 newRequest.setRequestContext(WebURLRequest::RequestContextInternal); |
| 357 } | 354 } |
| 358 | 355 |
| 359 Document* webcoreDocument = m_frameImpl->frame()->document(); | 356 Document* webcoreDocument = m_frameImpl->frame()->document(); |
| 360 ASSERT(webcoreDocument); | 357 ASSERT(webcoreDocument); |
| 361 m_loader = DocumentThreadableLoader::create(*webcoreDocument, m_clientAd
apter.get(), webcoreRequest, options, resourceLoaderOptions); | 358 m_loader = DocumentThreadableLoader::create(*webcoreDocument, m_clientAd
apter.get(), webcoreRequest, options, resourceLoaderOptions); |
| 362 } else { | 359 } else { |
| 363 // FIXME: return meaningful error codes. | 360 // FIXME: return meaningful error codes. |
| 364 m_clientAdapter->setDelayedError(ResourceError()); | 361 m_clientAdapter->setDelayedError(ResourceError()); |
| 365 } | 362 } |
| 366 m_clientAdapter->enableErrorNotifications(); | 363 m_clientAdapter->enableErrorNotifications(); |
| 367 } | 364 } |
| 368 | 365 |
| 369 void AssociatedURLLoader::cancel() | 366 void AssociatedURLLoader::cancel() |
| 370 { | 367 { |
| 371 if (m_clientAdapter) | 368 if (m_clientAdapter) |
| 372 m_clientAdapter->clearClient(); | 369 m_clientAdapter->clearClient(); |
| 373 if (m_loader) | 370 if (m_loader) |
| 374 m_loader->cancel(); | 371 m_loader->cancel(); |
| 375 } | 372 } |
| 376 | 373 |
| 377 void AssociatedURLLoader::setDefersLoading(bool defersLoading) | 374 void AssociatedURLLoader::setDefersLoading(bool defersLoading) |
| 378 { | 375 { |
| 379 if (m_loader) | 376 if (m_loader) |
| 380 m_loader->setDefersLoading(defersLoading); | 377 m_loader->setDefersLoading(defersLoading); |
| 381 } | 378 } |
| 382 | 379 |
| 383 } // namespace blink | 380 } // namespace blink |
| OLD | NEW |