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

Side by Side Diff: third_party/WebKit/Source/core/dom/ExecutionContext.cpp

Issue 2674973006: Move parsing of referrer policy header values to SecurityPolicy (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2012 Google Inc. All Rights Reserved. 3 * Copyright (C) 2012 Google 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 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 String unusedErrorMessage; 186 String unusedErrorMessage;
187 return isSecureContext(unusedErrorMessage, privilegeContextCheck); 187 return isSecureContext(unusedErrorMessage, privilegeContextCheck);
188 } 188 }
189 189
190 String ExecutionContext::outgoingReferrer() const { 190 String ExecutionContext::outgoingReferrer() const {
191 return url().strippedForUseAsReferrer(); 191 return url().strippedForUseAsReferrer();
192 } 192 }
193 193
194 void ExecutionContext::parseAndSetReferrerPolicy(const String& policies, 194 void ExecutionContext::parseAndSetReferrerPolicy(const String& policies,
195 bool supportLegacyKeywords) { 195 bool supportLegacyKeywords) {
196 ReferrerPolicy referrerPolicy = ReferrerPolicyDefault; 196 ReferrerPolicy referrerPolicy;
197 197
198 Vector<String> tokens; 198 if (!SecurityPolicy::referrerPolicyFromHeaderValue(
199 policies.split(',', true, tokens); 199 policies,
200 for (const auto& token : tokens) { 200 supportLegacyKeywords ? SupportReferrerPolicyLegacyKeywords
201 ReferrerPolicy currentResult; 201 : DoNotSupportReferrerPolicyLegacyKeywords,
202 if ((supportLegacyKeywords 202 &referrerPolicy)) {
203 ? SecurityPolicy::referrerPolicyFromStringWithLegacyKeywords(
204 token, &currentResult)
205 : SecurityPolicy::referrerPolicyFromString(token,
206 &currentResult))) {
207 referrerPolicy = currentResult;
208 }
209 }
210
211 if (referrerPolicy == ReferrerPolicyDefault) {
212 addConsoleMessage(ConsoleMessage::create( 203 addConsoleMessage(ConsoleMessage::create(
213 RenderingMessageSource, ErrorMessageLevel, 204 RenderingMessageSource, ErrorMessageLevel,
214 "Failed to set referrer policy: The value '" + policies + 205 "Failed to set referrer policy: The value '" + policies +
215 "' is not one of " + 206 "' is not one of " +
216 (supportLegacyKeywords 207 (supportLegacyKeywords
217 ? "'always', 'default', 'never', 'origin-when-crossorigin', " 208 ? "'always', 'default', 'never', 'origin-when-crossorigin', "
218 : "") + 209 : "") +
219 "'no-referrer', 'no-referrer-when-downgrade', 'origin', " 210 "'no-referrer', 'no-referrer-when-downgrade', 'origin', "
220 "'origin-when-cross-origin', or 'unsafe-url'. The referrer policy " 211 "'origin-when-cross-origin', or 'unsafe-url'. The referrer policy "
221 "has been left unchanged.")); 212 "has been left unchanged."));
(...skipping 18 matching lines...) Expand all
240 } 231 }
241 232
242 DEFINE_TRACE(ExecutionContext) { 233 DEFINE_TRACE(ExecutionContext) {
243 visitor->trace(m_publicURLManager); 234 visitor->trace(m_publicURLManager);
244 visitor->trace(m_pendingExceptions); 235 visitor->trace(m_pendingExceptions);
245 ContextLifecycleNotifier::trace(visitor); 236 ContextLifecycleNotifier::trace(visitor);
246 Supplementable<ExecutionContext>::trace(visitor); 237 Supplementable<ExecutionContext>::trace(visitor);
247 } 238 }
248 239
249 } // namespace blink 240 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698