| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #include "core/dom/ExecutionContext.h" | 28 #include "core/dom/ExecutionContext.h" |
| 29 | 29 |
| 30 #include "bindings/core/v8/SourceLocation.h" | 30 #include "bindings/core/v8/SourceLocation.h" |
| 31 #include "core/dom/ExecutionContextTask.h" | 31 #include "core/dom/ExecutionContextTask.h" |
| 32 #include "core/events/ErrorEvent.h" | 32 #include "core/events/ErrorEvent.h" |
| 33 #include "core/events/EventTarget.h" | 33 #include "core/events/EventTarget.h" |
| 34 #include "core/fetch/MemoryCache.h" | 34 #include "core/fetch/MemoryCache.h" |
| 35 #include "core/frame/UseCounter.h" | 35 #include "core/frame/UseCounter.h" |
| 36 #include "core/html/PublicURLManager.h" | 36 #include "core/html/PublicURLManager.h" |
| 37 #include "core/inspector/ConsoleMessage.h" |
| 37 #include "core/inspector/InspectorInstrumentation.h" | 38 #include "core/inspector/InspectorInstrumentation.h" |
| 38 #include "core/workers/WorkerGlobalScope.h" | 39 #include "core/workers/WorkerGlobalScope.h" |
| 39 #include "core/workers/WorkerThread.h" | 40 #include "core/workers/WorkerThread.h" |
| 41 #include "platform/weborigin/SecurityPolicy.h" |
| 40 #include "wtf/PtrUtil.h" | 42 #include "wtf/PtrUtil.h" |
| 41 #include <memory> | 43 #include <memory> |
| 42 | 44 |
| 43 namespace blink { | 45 namespace blink { |
| 44 | 46 |
| 45 class ExecutionContext::PendingException { | 47 class ExecutionContext::PendingException { |
| 46 WTF_MAKE_NONCOPYABLE(PendingException); | 48 WTF_MAKE_NONCOPYABLE(PendingException); |
| 47 public: | 49 public: |
| 48 PendingException(const String& errorMessage, std::unique_ptr<SourceLocation>
location) | 50 PendingException(const String& errorMessage, std::unique_ptr<SourceLocation>
location) |
| 49 : m_errorMessage(errorMessage) | 51 : m_errorMessage(errorMessage) |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 { | 247 { |
| 246 String unusedErrorMessage; | 248 String unusedErrorMessage; |
| 247 return isSecureContext(unusedErrorMessage, privilegeContextCheck); | 249 return isSecureContext(unusedErrorMessage, privilegeContextCheck); |
| 248 } | 250 } |
| 249 | 251 |
| 250 String ExecutionContext::outgoingReferrer() const | 252 String ExecutionContext::outgoingReferrer() const |
| 251 { | 253 { |
| 252 return url().strippedForUseAsReferrer(); | 254 return url().strippedForUseAsReferrer(); |
| 253 } | 255 } |
| 254 | 256 |
| 257 void ExecutionContext::parseAndSetReferrerPolicy(const String& policies) |
| 258 { |
| 259 ReferrerPolicy referrerPolicy = ReferrerPolicyDefault; |
| 260 |
| 261 Vector<String> tokens; |
| 262 policies.split(',', true, tokens); |
| 263 for (const auto& token : tokens) { |
| 264 ReferrerPolicy currentResult; |
| 265 if (SecurityPolicy::referrerPolicyFromString(token, ¤tResult)) { |
| 266 referrerPolicy = currentResult; |
| 267 } |
| 268 } |
| 269 |
| 270 if (referrerPolicy == ReferrerPolicyDefault) { |
| 271 addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, ErrorMe
ssageLevel, "Failed to set referrer policy: The value '" + policies + "' is not
one of 'always', 'default', 'never', 'no-referrer', 'no-referrer-when-downgrade'
, 'origin', 'origin-when-crossorigin', or 'unsafe-url'. The referrer policy has
been left unchanged.")); |
| 272 return; |
| 273 } |
| 274 |
| 275 setReferrerPolicy(referrerPolicy); |
| 276 } |
| 277 |
| 255 void ExecutionContext::setReferrerPolicy(ReferrerPolicy referrerPolicy) | 278 void ExecutionContext::setReferrerPolicy(ReferrerPolicy referrerPolicy) |
| 256 { | 279 { |
| 257 // When a referrer policy has already been set, the latest value takes prece
dence. | 280 // When a referrer policy has already been set, the latest value takes prece
dence. |
| 258 UseCounter::count(this, UseCounter::SetReferrerPolicy); | 281 UseCounter::count(this, UseCounter::SetReferrerPolicy); |
| 259 if (m_referrerPolicy != ReferrerPolicyDefault) | 282 if (m_referrerPolicy != ReferrerPolicyDefault) |
| 260 UseCounter::count(this, UseCounter::ResetReferrerPolicy); | 283 UseCounter::count(this, UseCounter::ResetReferrerPolicy); |
| 261 | 284 |
| 262 m_referrerPolicy = referrerPolicy; | 285 m_referrerPolicy = referrerPolicy; |
| 263 } | 286 } |
| 264 | 287 |
| 265 void ExecutionContext::removeURLFromMemoryCache(const KURL& url) | 288 void ExecutionContext::removeURLFromMemoryCache(const KURL& url) |
| 266 { | 289 { |
| 267 memoryCache()->removeURLFromCache(url); | 290 memoryCache()->removeURLFromCache(url); |
| 268 } | 291 } |
| 269 | 292 |
| 270 DEFINE_TRACE(ExecutionContext) | 293 DEFINE_TRACE(ExecutionContext) |
| 271 { | 294 { |
| 272 visitor->trace(m_publicURLManager); | 295 visitor->trace(m_publicURLManager); |
| 273 ContextLifecycleNotifier::trace(visitor); | 296 ContextLifecycleNotifier::trace(visitor); |
| 274 Supplementable<ExecutionContext>::trace(visitor); | 297 Supplementable<ExecutionContext>::trace(visitor); |
| 275 } | 298 } |
| 276 | 299 |
| 277 } // namespace blink | 300 } // namespace blink |
| OLD | NEW |