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 "WebDOMError.h" | 32 #include "WorkerPermissionClient.h" |
33 | 33 |
34 #include "V8DOMError.h" | 34 #include "core/workers/WorkerGlobalScope.h" |
35 #include "bindings/v8/V8Binding.h" | 35 #include "public/platform/WebString.h" |
36 #include "core/dom/DOMError.h" | 36 #include "public/web/WebWorkerPermissionClientProxy.h" |
37 #include "wtf/PassOwnPtr.h" | 37 #include "wtf/PassOwnPtr.h" |
38 | 38 |
39 using namespace WebCore; | 39 using namespace WebCore; |
40 | 40 |
41 namespace WebKit { | 41 namespace WebKit { |
42 | 42 |
43 WebDOMError WebDOMError::create(const WebString& name, const WebString& message) | 43 PassOwnPtr<WorkerPermissionClient> WorkerPermissionClient::create(PassOwnPtr<Web
WorkerPermissionClientProxy> proxy) |
44 { | 44 { |
45 return WebDOMError(DOMError::create(name, message)); | 45 return adoptPtr(new WorkerPermissionClient(proxy)); |
46 } | 46 } |
47 | 47 |
48 void WebDOMError::reset() | 48 WorkerPermissionClient::~WorkerPermissionClient() |
49 { | |
50 m_private.reset(); | |
51 } | |
52 | |
53 void WebDOMError::assign(const WebDOMError& other) | |
54 { | |
55 m_private = other.m_private; | |
56 } | |
57 | |
58 WebString WebDOMError::name() const | |
59 { | |
60 if (!m_private.get()) | |
61 return WebString(); | |
62 return m_private->name(); | |
63 } | |
64 | |
65 WebString WebDOMError::message() const | |
66 { | |
67 if (!m_private.get()) | |
68 return WebString(); | |
69 return m_private->message(); | |
70 } | |
71 | |
72 v8::Handle<v8::Value> WebDOMError::toV8Value() | |
73 { | |
74 if (!m_private.get()) | |
75 return v8::Handle<v8::Value>(); | |
76 return toV8(m_private.get(), v8::Handle<v8::Object>(), v8::Isolate::GetCurre
nt()); | |
77 } | |
78 | |
79 WebDOMError::WebDOMError(const WTF::PassRefPtr<WebCore::DOMError>& error) | |
80 : m_private(error) | |
81 { | 49 { |
82 } | 50 } |
83 | 51 |
84 WebDOMError& WebDOMError::operator=(const WTF::PassRefPtr<WebCore::DOMError>& er
ror) | 52 bool WorkerPermissionClient::allowDatabase(const WebString& name, const WebStrin
g& displayName, unsigned long estimatedSize) |
85 { | 53 { |
86 m_private = error; | 54 if (!m_proxy) |
87 return *this; | 55 return false; |
| 56 return m_proxy->allowDatabase(name, displayName, estimatedSize); |
88 } | 57 } |
89 | 58 |
90 WebDOMError::operator WTF::PassRefPtr<WebCore::DOMError>() const | 59 bool WorkerPermissionClient::allowFileSystem() |
91 { | 60 { |
92 return m_private.get(); | 61 if (!m_proxy) |
| 62 return false; |
| 63 return m_proxy->allowFileSystem(); |
| 64 } |
| 65 |
| 66 bool WorkerPermissionClient::allowIndexedDB(const WebString& name) |
| 67 { |
| 68 if (!m_proxy) |
| 69 return false; |
| 70 return m_proxy->allowIndexedDB(name); |
| 71 } |
| 72 |
| 73 const char* WorkerPermissionClient::supplementName() |
| 74 { |
| 75 return "WorkerPermissionClient"; |
| 76 } |
| 77 |
| 78 WorkerPermissionClient* WorkerPermissionClient::from(ExecutionContext* context) |
| 79 { |
| 80 return static_cast<WorkerPermissionClient*>(Supplement<WorkerClients>::from(
toWorkerGlobalScope(context)->clients(), supplementName())); |
| 81 } |
| 82 |
| 83 WorkerPermissionClient::WorkerPermissionClient(PassOwnPtr<WebWorkerPermissionCli
entProxy> proxy) |
| 84 : m_proxy(proxy) |
| 85 { |
| 86 } |
| 87 |
| 88 void providePermissionClientToWorker(WorkerClients* clients, PassOwnPtr<WebWorke
rPermissionClientProxy> proxy) |
| 89 { |
| 90 WorkerPermissionClient::provideTo(clients, WorkerPermissionClient::supplemen
tName(), WorkerPermissionClient::create(proxy)); |
93 } | 91 } |
94 | 92 |
95 } // namespace WebKit | 93 } // namespace WebKit |
OLD | NEW |