| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2009 Google Inc. All rights reserved. | 2  * Copyright (C) 2009 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 106 { | 106 { | 
| 107     ASSERT(document); | 107     ASSERT(document); | 
| 108     return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(documen
     t); | 108     return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(documen
     t); | 
| 109 } | 109 } | 
| 110 | 110 | 
| 111 void SharedWorkerRepositoryClientImpl::connect(SharedWorker* worker, PassOwnPtr<
     WebMessagePortChannel> port, const KURL& url, const String& name, ExceptionState
     & exceptionState) | 111 void SharedWorkerRepositoryClientImpl::connect(SharedWorker* worker, PassOwnPtr<
     WebMessagePortChannel> port, const KURL& url, const String& name, ExceptionState
     & exceptionState) | 
| 112 { | 112 { | 
| 113     ASSERT(m_client); | 113     ASSERT(m_client); | 
| 114 | 114 | 
| 115     // No nested workers (for now) - connect() should only be called from docume
     nt context. | 115     // No nested workers (for now) - connect() should only be called from docume
     nt context. | 
| 116     ASSERT(worker->executionContext()->isDocument()); | 116     ASSERT(worker->getExecutionContext()->isDocument()); | 
| 117     Document* document = toDocument(worker->executionContext()); | 117     Document* document = toDocument(worker->getExecutionContext()); | 
| 118 | 118 | 
| 119     // TODO(estark): this is broken, as it only uses the first header | 119     // TODO(estark): this is broken, as it only uses the first header | 
| 120     // when multiple might have been sent. Fix by making the | 120     // when multiple might have been sent. Fix by making the | 
| 121     // SharedWorkerConnector interface take a map that can contain | 121     // SharedWorkerConnector interface take a map that can contain | 
| 122     // multiple headers. | 122     // multiple headers. | 
| 123     OwnPtr<Vector<CSPHeaderAndType>> headers = worker->executionContext()->conte
     ntSecurityPolicy()->headers(); | 123     OwnPtr<Vector<CSPHeaderAndType>> headers = worker->getExecutionContext()->co
     ntentSecurityPolicy()->headers(); | 
| 124     WebString header; | 124     WebString header; | 
| 125     WebContentSecurityPolicyType headerType = WebContentSecurityPolicyTypeReport
     ; | 125     WebContentSecurityPolicyType headerType = WebContentSecurityPolicyTypeReport
     ; | 
| 126 | 126 | 
| 127     if (headers->size() > 0) { | 127     if (headers->size() > 0) { | 
| 128         header = (*headers)[0].first; | 128         header = (*headers)[0].first; | 
| 129         headerType = static_cast<WebContentSecurityPolicyType>((*headers)[0].sec
     ond); | 129         headerType = static_cast<WebContentSecurityPolicyType>((*headers)[0].sec
     ond); | 
| 130     } | 130     } | 
| 131 | 131 | 
| 132     WebWorkerCreationError creationError; | 132     WebWorkerCreationError creationError; | 
| 133     String unusedSecureContextError; | 133     String unusedSecureContextError; | 
| 134     bool isSecureContext = worker->executionContext()->isSecureContext(unusedSec
     ureContextError); | 134     bool isSecureContext = worker->getExecutionContext()->isSecureContext(unused
     SecureContextError); | 
| 135     OwnPtr<WebSharedWorkerConnector> webWorkerConnector = adoptPtr(m_client->cre
     ateSharedWorkerConnector(url, name, getId(document), header, headerType, worker-
     >executionContext()->securityContext().addressSpace(), isSecureContext ? WebShar
     edWorkerCreationContextTypeSecure : WebSharedWorkerCreationContextTypeNonsecure,
      &creationError)); | 135     OwnPtr<WebSharedWorkerConnector> webWorkerConnector = adoptPtr(m_client->cre
     ateSharedWorkerConnector(url, name, getId(document), header, headerType, worker-
     >getExecutionContext()->securityContext().addressSpace(), isSecureContext ? WebS
     haredWorkerCreationContextTypeSecure : WebSharedWorkerCreationContextTypeNonsecu
     re, &creationError)); | 
| 136     if (creationError != WebWorkerCreationErrorNone) { | 136     if (creationError != WebWorkerCreationErrorNone) { | 
| 137         if (creationError == WebWorkerCreationErrorURLMismatch) { | 137         if (creationError == WebWorkerCreationErrorURLMismatch) { | 
| 138             // Existing worker does not match this url, so return an error back 
     to the caller. | 138             // Existing worker does not match this url, so return an error back 
     to the caller. | 
| 139             exceptionState.throwDOMException(URLMismatchError, "The location of 
     the SharedWorker named '" + name + "' does not exactly match the provided URL ('
     " + url.elidedString() + "')."); | 139             exceptionState.throwDOMException(URLMismatchError, "The location of 
     the SharedWorker named '" + name + "' does not exactly match the provided URL ('
     " + url.elidedString() + "')."); | 
| 140             return; | 140             return; | 
| 141         } else if (creationError == WebWorkerCreationErrorSecureContextMismatch)
      { | 141         } else if (creationError == WebWorkerCreationErrorSecureContextMismatch)
      { | 
| 142             if (isSecureContext) { | 142             if (isSecureContext) { | 
| 143                 UseCounter::count(document, UseCounter::NonSecureSharedWorkerAcc
     essedFromSecureContext); | 143                 UseCounter::count(document, UseCounter::NonSecureSharedWorkerAcc
     essedFromSecureContext); | 
| 144             } else { | 144             } else { | 
| 145                 UseCounter::count(document, UseCounter::SecureSharedWorkerAccess
     edFromNonSecureContext); | 145                 UseCounter::count(document, UseCounter::SecureSharedWorkerAccess
     edFromNonSecureContext); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 158     ASSERT(m_client); | 158     ASSERT(m_client); | 
| 159     m_client->documentDetached(getId(document)); | 159     m_client->documentDetached(getId(document)); | 
| 160 } | 160 } | 
| 161 | 161 | 
| 162 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork
     erRepositoryClient* client) | 162 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork
     erRepositoryClient* client) | 
| 163     : m_client(client) | 163     : m_client(client) | 
| 164 { | 164 { | 
| 165 } | 165 } | 
| 166 | 166 | 
| 167 } // namespace blink | 167 } // namespace blink | 
| OLD | NEW | 
|---|