| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 LocalFileSystem::~LocalFileSystem() | 82 LocalFileSystem::~LocalFileSystem() |
| 83 { | 83 { |
| 84 } | 84 } |
| 85 | 85 |
| 86 void LocalFileSystem::resolveURL(ExecutionContext* context, const KURL& fileSyst
emURL, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 86 void LocalFileSystem::resolveURL(ExecutionContext* context, const KURL& fileSyst
emURL, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) |
| 87 { | 87 { |
| 88 RefPtr<CallbackWrapper> wrapper = adoptRef(new CallbackWrapper(callbacks)); | 88 RefPtr<CallbackWrapper> wrapper = adoptRef(new CallbackWrapper(callbacks)); |
| 89 requestFileSystemAccessInternal(context, | 89 requestFileSystemAccessInternal(context, |
| 90 bind(&LocalFileSystem::resolveURLInternal, this, fileSystemURL, wrapper)
, | 90 bind(&LocalFileSystem::resolveURLInternal, this, fileSystemURL, wrapper)
, |
| 91 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, PassRefPtr<Ex
ecutionContext>(context), wrapper)); | 91 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, PassRefPtrWil
lBeRawPtr<ExecutionContext>(context), wrapper)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void LocalFileSystem::requestFileSystem(ExecutionContext* context, FileSystemTyp
e type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 94 void LocalFileSystem::requestFileSystem(ExecutionContext* context, FileSystemTyp
e type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) |
| 95 { | 95 { |
| 96 RefPtr<ExecutionContext> contextPtr(context); | 96 RefPtrWillBeRawPtr<ExecutionContext> contextPtr(context); |
| 97 RefPtr<CallbackWrapper> wrapper = adoptRef(new CallbackWrapper(callbacks)); | 97 RefPtr<CallbackWrapper> wrapper = adoptRef(new CallbackWrapper(callbacks)); |
| 98 requestFileSystemAccessInternal(context, | 98 requestFileSystemAccessInternal(context, |
| 99 bind(&LocalFileSystem::fileSystemAllowedInternal, this, contextPtr, type
, wrapper), | 99 bind(&LocalFileSystem::fileSystemAllowedInternal, this, contextPtr, type
, wrapper), |
| 100 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, w
rapper)); | 100 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, w
rapper)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void LocalFileSystem::deleteFileSystem(ExecutionContext* context, FileSystemType
type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 103 void LocalFileSystem::deleteFileSystem(ExecutionContext* context, FileSystemType
type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) |
| 104 { | 104 { |
| 105 RefPtr<ExecutionContext> contextPtr(context); | 105 RefPtrWillBeRawPtr<ExecutionContext> contextPtr(context); |
| 106 ASSERT(context); | 106 ASSERT(context); |
| 107 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument()); | 107 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument()); |
| 108 | 108 |
| 109 RefPtr<CallbackWrapper> wrapper = adoptRef(new CallbackWrapper(callbacks)); | 109 RefPtr<CallbackWrapper> wrapper = adoptRef(new CallbackWrapper(callbacks)); |
| 110 requestFileSystemAccessInternal(context, | 110 requestFileSystemAccessInternal(context, |
| 111 bind(&LocalFileSystem::deleteFileSystemInternal, this, contextPtr, type,
wrapper), | 111 bind(&LocalFileSystem::deleteFileSystemInternal, this, contextPtr, type,
wrapper), |
| 112 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, w
rapper)); | 112 bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, w
rapper)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void LocalFileSystem::requestFileSystemAccessInternal(ExecutionContext* context,
const Closure& allowed, const Closure& denied) | 115 void LocalFileSystem::requestFileSystemAccessInternal(ExecutionContext* context,
const Closure& allowed, const Closure& denied) |
| 116 { | 116 { |
| 117 if (!client()) { | 117 if (!client()) { |
| 118 denied(); | 118 denied(); |
| 119 return; | 119 return; |
| 120 } | 120 } |
| 121 if (!context->isDocument()) { | 121 if (!context->isDocument()) { |
| 122 if (!client()->requestFileSystemAccessSync(context)) { | 122 if (!client()->requestFileSystemAccessSync(context)) { |
| 123 denied(); | 123 denied(); |
| 124 return; | 124 return; |
| 125 } | 125 } |
| 126 allowed(); | 126 allowed(); |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 client()->requestFileSystemAccessAsync(context, PermissionCallbacks::create(
allowed, denied)); | 129 client()->requestFileSystemAccessAsync(context, PermissionCallbacks::create(
allowed, denied)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void LocalFileSystem::fileSystemNotAllowedInternal( | 132 void LocalFileSystem::fileSystemNotAllowedInternal( |
| 133 PassRefPtr<ExecutionContext> context, | 133 PassRefPtrWillBeRawPtr<ExecutionContext> context, |
| 134 PassRefPtr<CallbackWrapper> callbacks) | 134 PassRefPtr<CallbackWrapper> callbacks) |
| 135 { | 135 { |
| 136 context->postTask(createCallbackTask(&fileSystemNotAllowed, callbacks->relea
se())); | 136 context->postTask(createCallbackTask(&fileSystemNotAllowed, callbacks->relea
se())); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void LocalFileSystem::fileSystemAllowedInternal( | 139 void LocalFileSystem::fileSystemAllowedInternal( |
| 140 PassRefPtr<ExecutionContext> context, | 140 PassRefPtrWillBeRawPtr<ExecutionContext> context, |
| 141 FileSystemType type, | 141 FileSystemType type, |
| 142 PassRefPtr<CallbackWrapper> callbacks) | 142 PassRefPtr<CallbackWrapper> callbacks) |
| 143 { | 143 { |
| 144 KURL storagePartition = KURL(KURL(), context->securityOrigin()->toString()); | 144 KURL storagePartition = KURL(KURL(), context->securityOrigin()->toString()); |
| 145 blink::Platform::current()->fileSystem()->openFileSystem(storagePartition, s
tatic_cast<blink::WebFileSystemType>(type), callbacks->release()); | 145 blink::Platform::current()->fileSystem()->openFileSystem(storagePartition, s
tatic_cast<blink::WebFileSystemType>(type), callbacks->release()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void LocalFileSystem::resolveURLInternal( | 148 void LocalFileSystem::resolveURLInternal( |
| 149 const KURL& fileSystemURL, | 149 const KURL& fileSystemURL, |
| 150 PassRefPtr<CallbackWrapper> callbacks) | 150 PassRefPtr<CallbackWrapper> callbacks) |
| 151 { | 151 { |
| 152 blink::Platform::current()->fileSystem()->resolveURL(fileSystemURL, callback
s->release()); | 152 blink::Platform::current()->fileSystem()->resolveURL(fileSystemURL, callback
s->release()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void LocalFileSystem::deleteFileSystemInternal( | 155 void LocalFileSystem::deleteFileSystemInternal( |
| 156 PassRefPtr<ExecutionContext> context, | 156 PassRefPtrWillBeRawPtr<ExecutionContext> context, |
| 157 FileSystemType type, | 157 FileSystemType type, |
| 158 PassRefPtr<CallbackWrapper> callbacks) | 158 PassRefPtr<CallbackWrapper> callbacks) |
| 159 { | 159 { |
| 160 KURL storagePartition = KURL(KURL(), context->securityOrigin()->toString()); | 160 KURL storagePartition = KURL(KURL(), context->securityOrigin()->toString()); |
| 161 blink::Platform::current()->fileSystem()->deleteFileSystem(storagePartition,
static_cast<blink::WebFileSystemType>(type), callbacks->release()); | 161 blink::Platform::current()->fileSystem()->deleteFileSystem(storagePartition,
static_cast<blink::WebFileSystemType>(type), callbacks->release()); |
| 162 } | 162 } |
| 163 | 163 |
| 164 LocalFileSystem::LocalFileSystem(PassOwnPtr<FileSystemClient> client) | 164 LocalFileSystem::LocalFileSystem(PassOwnPtr<FileSystemClient> client) |
| 165 : m_client(client) | 165 : m_client(client) |
| 166 { | 166 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 185 page.provideSupplement(LocalFileSystem::supplementName(), LocalFileSystem::c
reate(client)); | 185 page.provideSupplement(LocalFileSystem::supplementName(), LocalFileSystem::c
reate(client)); |
| 186 page.inspectorController().registerModuleAgent(InspectorFileSystemAgent::cre
ate(&page)); | 186 page.inspectorController().registerModuleAgent(InspectorFileSystemAgent::cre
ate(&page)); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void provideLocalFileSystemToWorker(WorkerClients* clients, PassOwnPtr<FileSyste
mClient> client) | 189 void provideLocalFileSystemToWorker(WorkerClients* clients, PassOwnPtr<FileSyste
mClient> client) |
| 190 { | 190 { |
| 191 clients->provideSupplement(LocalFileSystem::supplementName(), LocalFileSyste
m::create(client)); | 191 clients->provideSupplement(LocalFileSystem::supplementName(), LocalFileSyste
m::create(client)); |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace WebCore | 194 } // namespace WebCore |
| OLD | NEW |