| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google, Inc. All rights reserved. | 2 * Copyright (C) 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 , m_defer(NoDefer) | 65 , m_defer(NoDefer) |
| 66 , m_originRestriction(UseDefaultOriginRestrictionForType) | 66 , m_originRestriction(UseDefaultOriginRestrictionForType) |
| 67 { | 67 { |
| 68 m_options.initiatorInfo = initiator; | 68 m_options.initiatorInfo = initiator; |
| 69 } | 69 } |
| 70 | 70 |
| 71 FetchRequest::~FetchRequest() | 71 FetchRequest::~FetchRequest() |
| 72 { | 72 { |
| 73 } | 73 } |
| 74 | 74 |
| 75 void FetchRequest::setCrossOriginAccessControl(SecurityOrigin* origin, StoredCre
dentials allowCredentials, CredentialRequest requested) | 75 void FetchRequest::setCrossOriginAccessControl(SecurityOrigin* origin, CrossOrig
inAttributeValue crossOrigin) |
| 76 { | 76 { |
| 77 ASSERT(requested == ClientDidNotRequestCredentials || allowCredentials == Al
lowStoredCredentials); | 77 ASSERT(crossOrigin != CrossOriginAttributeNotSet); |
| 78 const bool useCredentials = crossOrigin == CrossOriginAttributeUseCredential
s; |
| 79 const bool isSameOriginRequest = origin && origin->canRequestNoSuborigin(m_r
esourceRequest.url()); |
| 80 |
| 81 // Currently FetchRequestMode and FetchCredentialsMode are only used when th
e request goes to Service Worker. |
| 78 m_resourceRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS); | 82 m_resourceRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS); |
| 79 updateRequestForAccessControl(m_resourceRequest, origin, allowCredentials); | 83 m_resourceRequest.setFetchCredentialsMode(useCredentials ? WebURLRequest::Fe
tchCredentialsModeInclude : WebURLRequest::FetchCredentialsModeSameOrigin); |
| 80 m_options.allowCredentials = allowCredentials; | 84 |
| 85 m_options.allowCredentials = (isSameOriginRequest || useCredentials) ? Allow
StoredCredentials : DoNotAllowStoredCredentials; |
| 81 m_options.corsEnabled = IsCORSEnabled; | 86 m_options.corsEnabled = IsCORSEnabled; |
| 82 m_options.securityOrigin = origin; | 87 m_options.securityOrigin = origin; |
| 83 m_options.credentialsRequested = requested; | 88 m_options.credentialsRequested = useCredentials ? ClientRequestedCredentials
: ClientDidNotRequestCredentials; |
| 89 |
| 90 updateRequestForAccessControl(m_resourceRequest, origin, m_options.allowCred
entials); |
| 84 } | 91 } |
| 85 | 92 |
| 86 void FetchRequest::setCrossOriginAccessControl(SecurityOrigin* origin, StoredCre
dentials allowCredentials) | |
| 87 { | |
| 88 setCrossOriginAccessControl(origin, allowCredentials, allowCredentials == Al
lowStoredCredentials ? ClientRequestedCredentials : ClientDidNotRequestCredentia
ls); | |
| 89 } | |
| 90 | |
| 91 void FetchRequest::setCrossOriginAccessControl(SecurityOrigin* origin, const Ato
micString& crossOriginMode) | |
| 92 { | |
| 93 setCrossOriginAccessControl(origin, equalIgnoringCase(crossOriginMode, "use-
credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials); | |
| 94 } | |
| 95 | 93 |
| 96 void FetchRequest::setResourceWidth(ResourceWidth resourceWidth) | 94 void FetchRequest::setResourceWidth(ResourceWidth resourceWidth) |
| 97 { | 95 { |
| 98 if (resourceWidth.isSet) { | 96 if (resourceWidth.isSet) { |
| 99 m_resourceWidth.width = resourceWidth.width; | 97 m_resourceWidth.width = resourceWidth.width; |
| 100 m_resourceWidth.isSet = true; | 98 m_resourceWidth.isSet = true; |
| 101 } | 99 } |
| 102 } | 100 } |
| 103 | 101 |
| 104 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |