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

Side by Side Diff: Source/modules/websockets/WebSocket.cpp

Issue 353873003: Clean up usage of CSP functions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix to apply Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/page/EventSource.cpp ('k') | no next file » | 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 exceptionState.throwDOMException(SyntaxError, "The URL contains a fragme nt identifier ('" + m_url.fragmentIdentifier() + "'). Fragment identifiers are n ot allowed in WebSocket URLs."); 300 exceptionState.throwDOMException(SyntaxError, "The URL contains a fragme nt identifier ('" + m_url.fragmentIdentifier() + "'). Fragment identifiers are n ot allowed in WebSocket URLs.");
301 return; 301 return;
302 } 302 }
303 if (!portAllowed(m_url)) { 303 if (!portAllowed(m_url)) {
304 m_state = CLOSED; 304 m_state = CLOSED;
305 exceptionState.throwSecurityError("The port " + String::number(m_url.por t()) + " is not allowed."); 305 exceptionState.throwSecurityError("The port " + String::number(m_url.por t()) + " is not allowed.");
306 return; 306 return;
307 } 307 }
308 308
309 // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved. 309 // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
310 bool shouldBypassMainWorldContentSecurityPolicy = false; 310 bool shouldBypassMainWorldCSP = false;
311 if (executionContext()->isDocument()) { 311 if (executionContext()->isDocument()) {
312 Document* document = toDocument(executionContext()); 312 Document* document = toDocument(executionContext());
313 shouldBypassMainWorldContentSecurityPolicy = document->frame()->script() .shouldBypassMainWorldContentSecurityPolicy(); 313 shouldBypassMainWorldCSP = document->frame()->script().shouldBypassMainW orldCSP();
314 } 314 }
315 if (!shouldBypassMainWorldContentSecurityPolicy && !executionContext()->cont entSecurityPolicy()->allowConnectToSource(m_url)) { 315 if (!shouldBypassMainWorldCSP && !executionContext()->contentSecurityPolicy( )->allowConnectToSource(m_url)) {
316 m_state = CLOSED; 316 m_state = CLOSED;
317 // The URL is safe to expose to JavaScript, as this check happens synchr onously before redirection. 317 // The URL is safe to expose to JavaScript, as this check happens synchr onously before redirection.
318 exceptionState.throwSecurityError("Refused to connect to '" + m_url.elid edString() + "' because it violates the document's Content Security Policy."); 318 exceptionState.throwSecurityError("Refused to connect to '" + m_url.elid edString() + "' because it violates the document's Content Security Policy.");
319 return; 319 return;
320 } 320 }
321 321
322 m_channel = createChannel(executionContext(), this); 322 m_channel = createChannel(executionContext(), this);
323 323
324 for (size_t i = 0; i < protocols.size(); ++i) { 324 for (size_t i = 0; i < protocols.size(); ++i) {
325 if (!isValidSubprotocolString(protocols[i])) { 325 if (!isValidSubprotocolString(protocols[i])) {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 701
702 void WebSocket::trace(Visitor* visitor) 702 void WebSocket::trace(Visitor* visitor)
703 { 703 {
704 visitor->trace(m_channel); 704 visitor->trace(m_channel);
705 visitor->trace(m_eventQueue); 705 visitor->trace(m_eventQueue);
706 WebSocketChannelClient::trace(visitor); 706 WebSocketChannelClient::trace(visitor);
707 EventTargetWithInlineData::trace(visitor); 707 EventTargetWithInlineData::trace(visitor);
708 } 708 }
709 709
710 } // namespace WebCore 710 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/EventSource.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698