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 15 matching lines...) Expand all Loading... |
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 "web/DatabaseClientImpl.h" | 32 #include "web/DatabaseClientImpl.h" |
33 | 33 |
34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
35 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
36 #include "core/workers/WorkerGlobalScope.h" | |
37 #include "public/web/WebPermissionClient.h" | 36 #include "public/web/WebPermissionClient.h" |
38 #include "web/WebLocalFrameImpl.h" | 37 #include "web/WebLocalFrameImpl.h" |
39 #include "web/WorkerPermissionClient.h" | |
40 | 38 |
41 namespace blink { | 39 namespace blink { |
42 | 40 |
43 PassOwnPtrWillBeRawPtr<DatabaseClientImpl> DatabaseClientImpl::create() | 41 PassOwnPtrWillBeRawPtr<DatabaseClientImpl> DatabaseClientImpl::create() |
44 { | 42 { |
45 return adoptPtrWillBeNoop(new DatabaseClientImpl()); | 43 return adoptPtrWillBeNoop(new DatabaseClientImpl()); |
46 } | 44 } |
47 | 45 |
48 DatabaseClientImpl::~DatabaseClientImpl() | 46 DatabaseClientImpl::~DatabaseClientImpl() |
49 { | 47 { |
50 } | 48 } |
51 | 49 |
52 bool DatabaseClientImpl::allowDatabase(ExecutionContext* executionContext, const
String& name, const String& displayName, unsigned long estimatedSize) | 50 bool DatabaseClientImpl::allowDatabase(ExecutionContext* executionContext, const
String& name, const String& displayName, unsigned long estimatedSize) |
53 { | 51 { |
54 ASSERT(executionContext->isContextThread()); | 52 ASSERT(executionContext->isContextThread()); |
55 ASSERT(executionContext->isDocument() || executionContext->isWorkerGlobalSco
pe()); | 53 Document* document = toDocument(executionContext); |
56 if (executionContext->isDocument()) { | 54 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()
); |
57 Document* document = toDocument(executionContext); | 55 if (!webFrame) |
58 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->fra
me()); | 56 return false; |
59 if (!webFrame) | 57 if (webFrame->permissionClient()) |
60 return false; | 58 return webFrame->permissionClient()->allowDatabase(name, displayName, es
timatedSize); |
61 if (webFrame->permissionClient()) | |
62 return webFrame->permissionClient()->allowDatabase(name, displayName
, estimatedSize); | |
63 } else { | |
64 WorkerGlobalScope& workerGlobalScope = *toWorkerGlobalScope(executionCon
text); | |
65 return WorkerPermissionClient::from(workerGlobalScope)->allowDatabase(na
me, displayName, estimatedSize); | |
66 } | |
67 return true; | 59 return true; |
68 } | 60 } |
69 | 61 |
70 DatabaseClientImpl::DatabaseClientImpl() | 62 DatabaseClientImpl::DatabaseClientImpl() |
71 { | 63 { |
72 } | 64 } |
73 | 65 |
74 } // namespace blink | 66 } // namespace blink |
OLD | NEW |