| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Ericsson AB. All rights reserved. | 2 * Copyright (C) 2009, 2012 Ericsson AB. All rights reserved. |
| 3 * Copyright (C) 2010 Apple Inc. All rights reserved. | 3 * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2011, Code Aurora Forum. All rights reserved. | 4 * Copyright (C) 2011, Code Aurora Forum. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 KURL fullURL = context->completeURL(url); | 92 KURL fullURL = context->completeURL(url); |
| 93 if (!fullURL.isValid()) { | 93 if (!fullURL.isValid()) { |
| 94 exceptionState.throwDOMException( | 94 exceptionState.throwDOMException( |
| 95 SyntaxError, | 95 SyntaxError, |
| 96 "Cannot open an EventSource to '" + url + "'. The URL is invalid."); | 96 "Cannot open an EventSource to '" + url + "'. The URL is invalid."); |
| 97 return nullptr; | 97 return nullptr; |
| 98 } | 98 } |
| 99 | 99 |
| 100 // FIXME: Convert this to check the isolated world's Content Security Policy | |
| 101 // once webkit.org/b/104520 is solved. | |
| 102 if (!ContentSecurityPolicy::shouldBypassMainWorld(context) && | |
| 103 !context->contentSecurityPolicy()->allowConnectToSource(fullURL)) { | |
| 104 // We can safely expose the URL to JavaScript, as this exception is generate | |
| 105 // synchronously before any redirects take place. | |
| 106 exceptionState.throwSecurityError( | |
| 107 "Refused to connect to '" + fullURL.elidedString() + | |
| 108 "' because it violates the document's Content Security Policy."); | |
| 109 return nullptr; | |
| 110 } | |
| 111 | |
| 112 EventSource* source = new EventSource(context, fullURL, eventSourceInit); | 100 EventSource* source = new EventSource(context, fullURL, eventSourceInit); |
| 113 | 101 |
| 114 source->scheduleInitialConnect(); | 102 source->scheduleInitialConnect(); |
| 115 source->suspendIfNeeded(); | 103 source->suspendIfNeeded(); |
| 116 return source; | 104 return source; |
| 117 } | 105 } |
| 118 | 106 |
| 119 EventSource::~EventSource() { | 107 EventSource::~EventSource() { |
| 120 DCHECK_EQ(kClosed, m_state); | 108 DCHECK_EQ(kClosed, m_state); |
| 121 DCHECK(!m_loader); | 109 DCHECK(!m_loader); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 DCHECK_EQ(kOpen, m_state); | 300 DCHECK_EQ(kOpen, m_state); |
| 313 DCHECK(m_loader); | 301 DCHECK(m_loader); |
| 314 | 302 |
| 315 networkRequestEnded(); | 303 networkRequestEnded(); |
| 316 } | 304 } |
| 317 | 305 |
| 318 void EventSource::didFail(const ResourceError& error) { | 306 void EventSource::didFail(const ResourceError& error) { |
| 319 DCHECK_NE(kClosed, m_state); | 307 DCHECK_NE(kClosed, m_state); |
| 320 DCHECK(m_loader); | 308 DCHECK(m_loader); |
| 321 | 309 |
| 310 if (error.isAccessCheck()) { |
| 311 didFailAccessControlCheck(error); |
| 312 return; |
| 313 } |
| 314 |
| 322 if (error.isCancellation()) | 315 if (error.isCancellation()) |
| 323 m_state = kClosed; | 316 m_state = kClosed; |
| 324 networkRequestEnded(); | 317 networkRequestEnded(); |
| 325 } | 318 } |
| 326 | 319 |
| 327 void EventSource::didFailAccessControlCheck(const ResourceError& error) { | 320 void EventSource::didFailAccessControlCheck(const ResourceError& error) { |
| 328 DCHECK(m_loader); | 321 DCHECK(m_loader); |
| 329 | 322 |
| 330 String message = "EventSource cannot load " + error.failingURL() + ". " + | 323 String message = "EventSource cannot load " + error.failingURL() + ". " + |
| 331 error.localizedDescription(); | 324 error.localizedDescription(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 371 |
| 379 DEFINE_TRACE(EventSource) { | 372 DEFINE_TRACE(EventSource) { |
| 380 visitor->trace(m_parser); | 373 visitor->trace(m_parser); |
| 381 visitor->trace(m_loader); | 374 visitor->trace(m_loader); |
| 382 EventTargetWithInlineData::trace(visitor); | 375 EventTargetWithInlineData::trace(visitor); |
| 383 ActiveDOMObject::trace(visitor); | 376 ActiveDOMObject::trace(visitor); |
| 384 EventSourceParser::Client::trace(visitor); | 377 EventSourceParser::Client::trace(visitor); |
| 385 } | 378 } |
| 386 | 379 |
| 387 } // namespace blink | 380 } // namespace blink |
| OLD | NEW |