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 13 matching lines...) Expand all Loading... |
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 "LocalFileSystemClient.h" | 32 #include "LocalFileSystemClient.h" |
33 | 33 |
34 #include "WebFrameImpl.h" | 34 #include "WebLocalFrameImpl.h" |
35 #include "WorkerPermissionClient.h" | 35 #include "WorkerPermissionClient.h" |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
37 #include "core/workers/WorkerGlobalScope.h" | 37 #include "core/workers/WorkerGlobalScope.h" |
38 #include "platform/PermissionCallbacks.h" | 38 #include "platform/PermissionCallbacks.h" |
39 #include "platform/weborigin/SecurityOrigin.h" | 39 #include "platform/weborigin/SecurityOrigin.h" |
40 #include "public/platform/WebPermissionCallbacks.h" | 40 #include "public/platform/WebPermissionCallbacks.h" |
41 #include "public/web/WebPermissionClient.h" | 41 #include "public/web/WebPermissionClient.h" |
42 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
43 | 43 |
44 using namespace WebCore; | 44 using namespace WebCore; |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 PassOwnPtr<FileSystemClient> LocalFileSystemClient::create() | 48 PassOwnPtr<FileSystemClient> LocalFileSystemClient::create() |
49 { | 49 { |
50 return adoptPtr(static_cast<FileSystemClient*>(new LocalFileSystemClient()))
; | 50 return adoptPtr(static_cast<FileSystemClient*>(new LocalFileSystemClient()))
; |
51 } | 51 } |
52 | 52 |
53 LocalFileSystemClient::~LocalFileSystemClient() | 53 LocalFileSystemClient::~LocalFileSystemClient() |
54 { | 54 { |
55 } | 55 } |
56 | 56 |
57 bool LocalFileSystemClient::allowFileSystem(ExecutionContext* context) | 57 bool LocalFileSystemClient::allowFileSystem(ExecutionContext* context) |
58 { | 58 { |
59 ASSERT(context); | 59 ASSERT(context); |
60 if (context->isDocument()) { | 60 if (context->isDocument()) { |
61 Document* document = toDocument(context); | 61 Document* document = toDocument(context); |
62 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); | 62 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->fra
me()); |
63 return !webFrame->permissionClient() || webFrame->permissionClient()->al
lowFileSystem(); | 63 return !webFrame->permissionClient() || webFrame->permissionClient()->al
lowFileSystem(); |
64 } | 64 } |
65 ASSERT(context->isWorkerGlobalScope()); | 65 ASSERT(context->isWorkerGlobalScope()); |
66 return WorkerPermissionClient::from(*toWorkerGlobalScope(context))->allowFil
eSystem(); | 66 return WorkerPermissionClient::from(*toWorkerGlobalScope(context))->allowFil
eSystem(); |
67 } | 67 } |
68 | 68 |
69 void LocalFileSystemClient::requestFileSystemAccess(ExecutionContext* context, P
assOwnPtr<WebCore::PermissionCallbacks> callbacks) | 69 void LocalFileSystemClient::requestFileSystemAccess(ExecutionContext* context, P
assOwnPtr<WebCore::PermissionCallbacks> callbacks) |
70 { | 70 { |
71 ASSERT(context); | 71 ASSERT(context); |
72 if (context->isDocument()) { | 72 if (context->isDocument()) { |
73 Document* document = toDocument(context); | 73 Document* document = toDocument(context); |
74 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); | 74 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->fra
me()); |
75 if (!webFrame->permissionClient()) { | 75 if (!webFrame->permissionClient()) { |
76 callbacks->onAllowed(); | 76 callbacks->onAllowed(); |
77 return; | 77 return; |
78 } | 78 } |
79 webFrame->permissionClient()->requestFileSystemAccess(callbacks); | 79 webFrame->permissionClient()->requestFileSystemAccess(callbacks); |
80 return; | 80 return; |
81 } | 81 } |
82 ASSERT(context->isWorkerGlobalScope()); | 82 ASSERT(context->isWorkerGlobalScope()); |
83 WorkerPermissionClient::from(*toWorkerGlobalScope(context))->requestFileSyst
emAccess(callbacks); | 83 WorkerPermissionClient::from(*toWorkerGlobalScope(context))->requestFileSyst
emAccess(callbacks); |
84 } | 84 } |
85 | 85 |
86 LocalFileSystemClient::LocalFileSystemClient() | 86 LocalFileSystemClient::LocalFileSystemClient() |
87 { | 87 { |
88 } | 88 } |
89 | 89 |
90 } // namespace blink | 90 } // namespace blink |
OLD | NEW |