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

Side by Side Diff: third_party/WebKit/Source/core/fetch/FetchRequest.cpp

Issue 2420603003: Make DocumentThreadableLoader's cross origin logic clearer in terms of layering (Closed)
Patch Set: Rebase Created 4 years, 1 month 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
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const bool isSameOriginRequest = 98 const bool isSameOriginRequest =
99 origin && origin->canRequestNoSuborigin(m_resourceRequest.url()); 99 origin && origin->canRequestNoSuborigin(m_resourceRequest.url());
100 100
101 // Currently FetchRequestMode and FetchCredentialsMode are only used when the 101 // Currently FetchRequestMode and FetchCredentialsMode are only used when the
102 // request goes to Service Worker. 102 // request goes to Service Worker.
103 m_resourceRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS); 103 m_resourceRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS);
104 m_resourceRequest.setFetchCredentialsMode( 104 m_resourceRequest.setFetchCredentialsMode(
105 useCredentials ? WebURLRequest::FetchCredentialsModeInclude 105 useCredentials ? WebURLRequest::FetchCredentialsModeInclude
106 : WebURLRequest::FetchCredentialsModeSameOrigin); 106 : WebURLRequest::FetchCredentialsModeSameOrigin);
107 107
108 m_options.allowCredentials = (isSameOriginRequest || useCredentials) 108 if (isSameOriginRequest || useCredentials) {
109 ? AllowStoredCredentials 109 m_options.allowCredentials = AllowStoredCredentials;
110 : DoNotAllowStoredCredentials; 110 m_resourceRequest.setAllowStoredCredentials(true);
111 } else {
112 m_options.allowCredentials = DoNotAllowStoredCredentials;
113 m_resourceRequest.setAllowStoredCredentials(false);
114 }
111 m_options.corsEnabled = IsCORSEnabled; 115 m_options.corsEnabled = IsCORSEnabled;
112 m_options.securityOrigin = origin; 116 m_options.securityOrigin = origin;
113 m_options.credentialsRequested = useCredentials 117 m_options.credentialsRequested = useCredentials
114 ? ClientRequestedCredentials 118 ? ClientRequestedCredentials
115 : ClientDidNotRequestCredentials; 119 : ClientDidNotRequestCredentials;
116 120
117 updateRequestForAccessControl(m_resourceRequest, origin, 121 // TODO: Credentials should be removed only when the request is cross origin.
118 m_options.allowCredentials); 122 m_resourceRequest.removeCredentials();
123
124 if (origin)
125 m_resourceRequest.setHTTPOrigin(origin);
119 } 126 }
120 127
121 void FetchRequest::setResourceWidth(ResourceWidth resourceWidth) { 128 void FetchRequest::setResourceWidth(ResourceWidth resourceWidth) {
122 if (resourceWidth.isSet) { 129 if (resourceWidth.isSet) {
123 m_resourceWidth.width = resourceWidth.width; 130 m_resourceWidth.width = resourceWidth.width;
124 m_resourceWidth.isSet = true; 131 m_resourceWidth.isSet = true;
125 } 132 }
126 } 133 }
127 134
128 void FetchRequest::setForPreload(bool forPreload, double discoveryTime) { 135 void FetchRequest::setForPreload(bool forPreload, double discoveryTime) {
(...skipping 24 matching lines...) Expand all
153 // the dimensions for larger images. 160 // the dimensions for larger images.
154 // TODO(sclittle): Calculate the optimal value for this number. 161 // TODO(sclittle): Calculate the optimal value for this number.
155 m_resourceRequest.setHTTPHeaderField("range", "bytes=0-2047"); 162 m_resourceRequest.setHTTPHeaderField("range", "bytes=0-2047");
156 163
157 // TODO(sclittle): Indicate somehow (e.g. through a new request bit) to the 164 // TODO(sclittle): Indicate somehow (e.g. through a new request bit) to the
158 // embedder that it should return the full resource if the entire resource is 165 // embedder that it should return the full resource if the entire resource is
159 // fresh in the cache. 166 // fresh in the cache.
160 } 167 }
161 168
162 } // namespace blink 169 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698