OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "modules/filesystem/SyncCallbackHelper.h" | 41 #include "modules/filesystem/SyncCallbackHelper.h" |
42 #include "platform/FileSystemType.h" | 42 #include "platform/FileSystemType.h" |
43 #include "platform/weborigin/SecurityOrigin.h" | 43 #include "platform/weborigin/SecurityOrigin.h" |
44 | 44 |
45 namespace blink { | 45 namespace blink { |
46 | 46 |
47 void WorkerGlobalScopeFileSystem::webkitRequestFileSystem(WorkerGlobalScope& wor
ker, int type, long long size, FileSystemCallback* successCallback, ErrorCallbac
k* errorCallback) | 47 void WorkerGlobalScopeFileSystem::webkitRequestFileSystem(WorkerGlobalScope& wor
ker, int type, long long size, FileSystemCallback* successCallback, ErrorCallbac
k* errorCallback) |
48 { | 48 { |
49 ExecutionContext* secureContext = worker.getExecutionContext(); | 49 ExecutionContext* secureContext = worker.getExecutionContext(); |
50 if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) { | 50 if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) { |
51 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::SECURITY_ERR)); | 51 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::SECUR
ITY_ERR); |
52 return; | 52 return; |
53 } | 53 } |
54 | 54 |
55 FileSystemType fileSystemType = static_cast<FileSystemType>(type); | 55 FileSystemType fileSystemType = static_cast<FileSystemType>(type); |
56 if (!DOMFileSystemBase::isValidType(fileSystemType)) { | 56 if (!DOMFileSystemBase::isValidType(fileSystemType)) { |
57 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::INVALID_MODIFICATION_ERR)); | 57 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::INVAL
ID_MODIFICATION_ERR); |
58 return; | 58 return; |
59 } | 59 } |
60 | 60 |
61 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si
ze, FileSystemCallbacks::create(successCallback, errorCallback, &worker, fileSys
temType)); | 61 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si
ze, FileSystemCallbacks::create(successCallback, errorCallback, &worker, fileSys
temType)); |
62 } | 62 } |
63 | 63 |
64 DOMFileSystemSync* WorkerGlobalScopeFileSystem::webkitRequestFileSystemSync(Work
erGlobalScope& worker, int type, long long size, ExceptionState& exceptionState) | 64 DOMFileSystemSync* WorkerGlobalScopeFileSystem::webkitRequestFileSystemSync(Work
erGlobalScope& worker, int type, long long size, ExceptionState& exceptionState) |
65 { | 65 { |
66 ExecutionContext* secureContext = worker.getExecutionContext(); | 66 ExecutionContext* secureContext = worker.getExecutionContext(); |
67 if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) { | 67 if (!secureContext->getSecurityOrigin()->canAccessFileSystem()) { |
(...skipping 13 matching lines...) Expand all Loading... |
81 | 81 |
82 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si
ze, std::move(callbacks)); | 82 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si
ze, std::move(callbacks)); |
83 return helper->getResult(exceptionState); | 83 return helper->getResult(exceptionState); |
84 } | 84 } |
85 | 85 |
86 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc
ope& worker, const String& url, EntryCallback* successCallback, ErrorCallback* e
rrorCallback) | 86 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc
ope& worker, const String& url, EntryCallback* successCallback, ErrorCallback* e
rrorCallback) |
87 { | 87 { |
88 KURL completedURL = worker.completeURL(url); | 88 KURL completedURL = worker.completeURL(url); |
89 ExecutionContext* secureContext = worker.getExecutionContext(); | 89 ExecutionContext* secureContext = worker.getExecutionContext(); |
90 if (!secureContext->getSecurityOrigin()->canAccessFileSystem() || !secureCon
text->getSecurityOrigin()->canRequest(completedURL)) { | 90 if (!secureContext->getSecurityOrigin()->canAccessFileSystem() || !secureCon
text->getSecurityOrigin()->canRequest(completedURL)) { |
91 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::SECURITY_ERR)); | 91 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::SECUR
ITY_ERR); |
92 return; | 92 return; |
93 } | 93 } |
94 | 94 |
95 if (!completedURL.isValid()) { | 95 if (!completedURL.isValid()) { |
96 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::ENCODING_ERR)); | 96 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::ENCOD
ING_ERR); |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
100 LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, ResolveURIC
allbacks::create(successCallback, errorCallback, &worker)); | 100 LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, ResolveURIC
allbacks::create(successCallback, errorCallback, &worker)); |
101 } | 101 } |
102 | 102 |
103 EntrySync* WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemSyncURL(Work
erGlobalScope& worker, const String& url, ExceptionState& exceptionState) | 103 EntrySync* WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemSyncURL(Work
erGlobalScope& worker, const String& url, ExceptionState& exceptionState) |
104 { | 104 { |
105 KURL completedURL = worker.completeURL(url); | 105 KURL completedURL = worker.completeURL(url); |
106 ExecutionContext* secureContext = worker.getExecutionContext(); | 106 ExecutionContext* secureContext = worker.getExecutionContext(); |
(...skipping 13 matching lines...) Expand all Loading... |
120 | 120 |
121 LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, std::move(c
allbacks)); | 121 LocalFileSystem::from(worker)->resolveURL(&worker, completedURL, std::move(c
allbacks)); |
122 | 122 |
123 return resolveURLHelper->getResult(exceptionState); | 123 return resolveURLHelper->getResult(exceptionState); |
124 } | 124 } |
125 | 125 |
126 static_assert(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == static
_cast<int>(FileSystemTypeTemporary), "WorkerGlobalScopeFileSystem::TEMPORARY sho
uld match FileSystemTypeTemporary"); | 126 static_assert(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == static
_cast<int>(FileSystemTypeTemporary), "WorkerGlobalScopeFileSystem::TEMPORARY sho
uld match FileSystemTypeTemporary"); |
127 static_assert(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stati
c_cast<int>(FileSystemTypePersistent), "WorkerGlobalScopeFileSystem::PERSISTENT
should match FileSystemTypePersistent"); | 127 static_assert(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stati
c_cast<int>(FileSystemTypePersistent), "WorkerGlobalScopeFileSystem::PERSISTENT
should match FileSystemTypePersistent"); |
128 | 128 |
129 } // namespace blink | 129 } // namespace blink |
OLD | NEW |