| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 11 matching lines...) Expand all Loading... |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/crypto/DOMWindowCrypto.h" | 32 #include "modules/crypto/WorkerContextCrypto.h" |
| 33 | 33 |
| 34 #include "core/page/DOMWindow.h" | 34 #include "core/dom/ScriptExecutionContext.h" |
| 35 #include "core/page/Frame.h" | 35 #include "modules/crypto/RandomSource.h" |
| 36 #include "modules/crypto/Crypto.h" | |
| 37 | 36 |
| 38 namespace WebCore { | 37 namespace WebCore { |
| 39 | 38 |
| 40 DOMWindowCrypto::DOMWindowCrypto(DOMWindow* window) | 39 WorkerContextCrypto::WorkerContextCrypto() |
| 41 : DOMWindowProperty(window->frame()) | |
| 42 { | 40 { |
| 43 } | 41 } |
| 44 | 42 |
| 45 DOMWindowCrypto::~DOMWindowCrypto() | 43 WorkerContextCrypto::~WorkerContextCrypto() |
| 46 { | 44 { |
| 47 } | 45 } |
| 48 | 46 |
| 49 const char* DOMWindowCrypto::supplementName() | 47 const char* WorkerContextCrypto::supplementName() |
| 50 { | 48 { |
| 51 return "DOMWindowCrypto"; | 49 return "WorkerContextCrypto"; |
| 52 } | 50 } |
| 53 | 51 |
| 54 // static | 52 // static |
| 55 DOMWindowCrypto* DOMWindowCrypto::from(DOMWindow* window) | 53 WorkerContextCrypto* WorkerContextCrypto::from(ScriptExecutionContext* context) |
| 56 { | 54 { |
| 57 DOMWindowCrypto* supplement = static_cast<DOMWindowCrypto*>(Supplement<DOMWi
ndow>::from(window, supplementName())); | 55 WorkerContextCrypto* supplement = static_cast<WorkerContextCrypto*>(Suppleme
nt<ScriptExecutionContext>::from(context, supplementName())); |
| 58 if (!supplement) { | 56 if (!supplement) { |
| 59 supplement = new DOMWindowCrypto(window); | 57 supplement = new WorkerContextCrypto(); |
| 60 provideTo(window, supplementName(), adoptPtr(supplement)); | 58 provideTo(context, supplementName(), adoptPtr(supplement)); |
| 61 } | 59 } |
| 62 return supplement; | 60 return supplement; |
| 63 } | 61 } |
| 64 | 62 |
| 65 // static | 63 // static |
| 66 Crypto* DOMWindowCrypto::crypto(DOMWindow* window) | 64 RandomSource* WorkerContextCrypto::crypto(ScriptExecutionContext* context) |
| 67 { | 65 { |
| 68 return DOMWindowCrypto::from(window)->crypto(); | 66 return WorkerContextCrypto::from(context)->crypto(); |
| 69 } | 67 } |
| 70 | 68 |
| 71 Crypto* DOMWindowCrypto::crypto() const | 69 RandomSource* WorkerContextCrypto::crypto() const |
| 72 { | 70 { |
| 73 if (!m_crypto && frame()) | 71 if (!m_crypto) |
| 74 m_crypto = Crypto::create(); | 72 m_crypto = RandomSource::create(); |
| 75 return m_crypto.get(); | 73 return m_crypto.get(); |
| 76 } | 74 } |
| 77 | 75 |
| 78 } // namespace WebCore | 76 } // namespace WebCore |
| OLD | NEW |