| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 RefPtr<RequestFileSystemRootCallback> m_requestCallback; | 144 RefPtr<RequestFileSystemRootCallback> m_requestCallback; |
| 145 String m_type; | 145 String m_type; |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 void FileSystemRootRequest::start(ScriptExecutionContext* scriptExecutionContext
) | 148 void FileSystemRootRequest::start(ScriptExecutionContext* scriptExecutionContext
) |
| 149 { | 149 { |
| 150 ASSERT(scriptExecutionContext); | 150 ASSERT(scriptExecutionContext); |
| 151 | 151 |
| 152 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &FileSystemRootRequest::didHitError); | 152 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &FileSystemRootRequest::didHitError); |
| 153 |
| 153 FileSystemType type; | 154 FileSystemType type; |
| 154 if (m_type == DOMFileSystemBase::persistentPathPrefix) | 155 if (!DOMFileSystemBase::pathPrefixToFileSystemType(m_type, type)) { |
| 155 type = FileSystemTypePersistent; | 156 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get(
)); |
| 156 else if (m_type == DOMFileSystemBase::temporaryPathPrefix) | 157 return; |
| 157 type = FileSystemTypeTemporary; | 158 } |
| 158 else { | 159 |
| 160 KURL rootURL = DOMFileSystemBase::createFileSystemRootURL(scriptExecutionCon
text->securityOrigin()->toString(), type); |
| 161 if (!rootURL.isValid()) { |
| 159 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get(
)); | 162 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get(
)); |
| 160 return; | 163 return; |
| 161 } | 164 } |
| 162 | 165 |
| 163 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &FileSystemRootRequest::didGetEntry); | 166 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &FileSystemRootRequest::didGetEntry); |
| 164 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback, errorCallback, scriptExecutionContext, type, "/"); | 167 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback, errorCallback, scriptExecutionContext); |
| 165 | 168 LocalFileSystem::from(scriptExecutionContext)->resolveURL(scriptExecutionCon
text, rootURL, fileSystemCallbacks.release()); |
| 166 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio
nContext, type, fileSystemCallbacks.release()); | |
| 167 } | 169 } |
| 168 | 170 |
| 169 bool FileSystemRootRequest::didGetEntry(Entry* entry) | 171 bool FileSystemRootRequest::didGetEntry(Entry* entry) |
| 170 { | 172 { |
| 171 RefPtr<TypeBuilder::FileSystem::Entry> result = TypeBuilder::FileSystem::Ent
ry::create() | 173 RefPtr<TypeBuilder::FileSystem::Entry> result = TypeBuilder::FileSystem::Ent
ry::create() |
| 172 .setUrl(entry->toURL()) | 174 .setUrl(entry->toURL()) |
| 173 .setName("/") | 175 .setName("/") |
| 174 .setIsDirectory(true); | 176 .setIsDirectory(true); |
| 175 reportResult(static_cast<FileError::ErrorCode>(0), result); | 177 reportResult(static_cast<FileError::ErrorCode>(0), result); |
| 176 return true; | 178 return true; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 KURL m_url; | 218 KURL m_url; |
| 217 RefPtr<Array<TypeBuilder::FileSystem::Entry> > m_entries; | 219 RefPtr<Array<TypeBuilder::FileSystem::Entry> > m_entries; |
| 218 RefPtr<DirectoryReader> m_directoryReader; | 220 RefPtr<DirectoryReader> m_directoryReader; |
| 219 }; | 221 }; |
| 220 | 222 |
| 221 void DirectoryContentRequest::start(ScriptExecutionContext* scriptExecutionConte
xt) | 223 void DirectoryContentRequest::start(ScriptExecutionContext* scriptExecutionConte
xt) |
| 222 { | 224 { |
| 223 ASSERT(scriptExecutionContext); | 225 ASSERT(scriptExecutionContext); |
| 224 | 226 |
| 225 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &DirectoryContentRequest::didHitError); | 227 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &DirectoryContentRequest::didHitError); |
| 226 FileSystemType type; | 228 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &DirectoryContentRequest::didGetEntry); |
| 227 String path; | |
| 228 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) { | |
| 229 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get(
)); | |
| 230 return; | |
| 231 } | |
| 232 | 229 |
| 233 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &DirectoryContentRequest::didGetEntry); | 230 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback, errorCallback, scriptExecutionContext); |
| 234 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback, errorCallback, scriptExecutionContext, type, path); | |
| 235 | 231 |
| 236 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio
nContext, type, fileSystemCallbacks.release()); | 232 LocalFileSystem::from(scriptExecutionContext)->resolveURL(scriptExecutionCon
text, m_url, fileSystemCallbacks.release()); |
| 237 } | 233 } |
| 238 | 234 |
| 239 bool DirectoryContentRequest::didGetEntry(Entry* entry) | 235 bool DirectoryContentRequest::didGetEntry(Entry* entry) |
| 240 { | 236 { |
| 241 if (!entry->isDirectory()) { | 237 if (!entry->isDirectory()) { |
| 242 reportResult(FileError::TYPE_MISMATCH_ERR); | 238 reportResult(FileError::TYPE_MISMATCH_ERR); |
| 243 return true; | 239 return true; |
| 244 } | 240 } |
| 245 | 241 |
| 246 m_directoryReader = static_cast<DirectoryEntry*>(entry)->createReader(); | 242 m_directoryReader = static_cast<DirectoryEntry*>(entry)->createReader(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 { | 328 { |
| 333 m_requestCallback->sendSuccess(static_cast<int>(errorCode), metadata); | 329 m_requestCallback->sendSuccess(static_cast<int>(errorCode), metadata); |
| 334 } | 330 } |
| 335 | 331 |
| 336 MetadataRequest(PassRefPtr<RequestMetadataCallback> requestCallback, const S
tring& url) | 332 MetadataRequest(PassRefPtr<RequestMetadataCallback> requestCallback, const S
tring& url) |
| 337 : m_requestCallback(requestCallback) | 333 : m_requestCallback(requestCallback) |
| 338 , m_url(ParsedURLString, url) { } | 334 , m_url(ParsedURLString, url) { } |
| 339 | 335 |
| 340 RefPtr<RequestMetadataCallback> m_requestCallback; | 336 RefPtr<RequestMetadataCallback> m_requestCallback; |
| 341 KURL m_url; | 337 KURL m_url; |
| 342 String m_path; | |
| 343 bool m_isDirectory; | 338 bool m_isDirectory; |
| 344 }; | 339 }; |
| 345 | 340 |
| 346 void MetadataRequest::start(ScriptExecutionContext* scriptExecutionContext) | 341 void MetadataRequest::start(ScriptExecutionContext* scriptExecutionContext) |
| 347 { | 342 { |
| 348 ASSERT(scriptExecutionContext); | 343 ASSERT(scriptExecutionContext); |
| 349 | 344 |
| 350 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &MetadataRequest::didHitError); | 345 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &MetadataRequest::didHitError); |
| 351 | |
| 352 FileSystemType type; | |
| 353 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, m_path)) { | |
| 354 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get(
)); | |
| 355 return; | |
| 356 } | |
| 357 | |
| 358 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &MetadataRequest::didGetEntry); | 346 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &MetadataRequest::didGetEntry); |
| 359 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback, errorCallback, scriptExecutionContext, type, m_path); | 347 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback, errorCallback, scriptExecutionContext); |
| 360 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio
nContext, type, fileSystemCallbacks.release()); | 348 LocalFileSystem::from(scriptExecutionContext)->resolveURL(scriptExecutionCon
text, m_url, fileSystemCallbacks.release()); |
| 361 } | 349 } |
| 362 | 350 |
| 363 bool MetadataRequest::didGetEntry(Entry* entry) | 351 bool MetadataRequest::didGetEntry(Entry* entry) |
| 364 { | 352 { |
| 365 if (!entry->filesystem()->scriptExecutionContext()) { | 353 if (!entry->filesystem()->scriptExecutionContext()) { |
| 366 reportResult(FileError::ABORT_ERR); | 354 reportResult(FileError::ABORT_ERR); |
| 367 return true; | 355 return true; |
| 368 } | 356 } |
| 369 | 357 |
| 370 RefPtr<MetadataCallback> successCallback = CallbackDispatcherFactory<Metadat
aCallback>::create(this, &MetadataRequest::didGetMetadata); | 358 RefPtr<MetadataCallback> successCallback = CallbackDispatcherFactory<Metadat
aCallback>::create(this, &MetadataRequest::didGetMetadata); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 String m_charset; | 434 String m_charset; |
| 447 | 435 |
| 448 RefPtr<FileReader> m_reader; | 436 RefPtr<FileReader> m_reader; |
| 449 }; | 437 }; |
| 450 | 438 |
| 451 void FileContentRequest::start(ScriptExecutionContext* scriptExecutionContext) | 439 void FileContentRequest::start(ScriptExecutionContext* scriptExecutionContext) |
| 452 { | 440 { |
| 453 ASSERT(scriptExecutionContext); | 441 ASSERT(scriptExecutionContext); |
| 454 | 442 |
| 455 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &FileContentRequest::didHitError); | 443 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &FileContentRequest::didHitError); |
| 444 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &FileContentRequest::didGetEntry); |
| 456 | 445 |
| 457 FileSystemType type; | 446 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback, errorCallback, scriptExecutionContext); |
| 458 String path; | 447 LocalFileSystem::from(scriptExecutionContext)->resolveURL(scriptExecutionCon
text, m_url, fileSystemCallbacks.release()); |
| 459 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) { | |
| 460 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get(
)); | |
| 461 return; | |
| 462 } | |
| 463 | |
| 464 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallb
ack>::create(this, &FileContentRequest::didGetEntry); | |
| 465 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbacks::
create(successCallback, errorCallback, scriptExecutionContext, type, path); | |
| 466 | |
| 467 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExecutio
nContext, type, fileSystemCallbacks.release()); | |
| 468 } | 448 } |
| 469 | 449 |
| 470 bool FileContentRequest::didGetEntry(Entry* entry) | 450 bool FileContentRequest::didGetEntry(Entry* entry) |
| 471 { | 451 { |
| 472 if (entry->isDirectory()) { | 452 if (entry->isDirectory()) { |
| 473 reportResult(FileError::TYPE_MISMATCH_ERR); | 453 reportResult(FileError::TYPE_MISMATCH_ERR); |
| 474 return true; | 454 return true; |
| 475 } | 455 } |
| 476 | 456 |
| 477 if (!entry->filesystem()->scriptExecutionContext()) { | 457 if (!entry->filesystem()->scriptExecutionContext()) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) { | 549 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) { |
| 570 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get(
)); | 550 errorCallback->handleEvent(FileError::create(FileError::SYNTAX_ERR).get(
)); |
| 571 return; | 551 return; |
| 572 } | 552 } |
| 573 | 553 |
| 574 if (path == "/") { | 554 if (path == "/") { |
| 575 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = VoidCallbacks::cr
eate(this, errorCallback, 0); | 555 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = VoidCallbacks::cr
eate(this, errorCallback, 0); |
| 576 LocalFileSystem::from(scriptExecutionContext)->deleteFileSystem(scriptEx
ecutionContext, type, fileSystemCallbacks.release()); | 556 LocalFileSystem::from(scriptExecutionContext)->deleteFileSystem(scriptEx
ecutionContext, type, fileSystemCallbacks.release()); |
| 577 } else { | 557 } else { |
| 578 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryC
allback>::create(this, &DeleteEntryRequest::didGetEntry); | 558 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryC
allback>::create(this, &DeleteEntryRequest::didGetEntry); |
| 579 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbac
ks::create(successCallback, errorCallback, scriptExecutionContext, type, path); | 559 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = ResolveURICallbac
ks::create(successCallback, errorCallback, scriptExecutionContext); |
| 580 LocalFileSystem::from(scriptExecutionContext)->readFileSystem(scriptExec
utionContext, type, fileSystemCallbacks.release()); | 560 LocalFileSystem::from(scriptExecutionContext)->resolveURL(scriptExecutio
nContext, m_url, fileSystemCallbacks.release()); |
| 581 } | 561 } |
| 582 } | 562 } |
| 583 | 563 |
| 584 bool DeleteEntryRequest::didGetEntry(Entry* entry) | 564 bool DeleteEntryRequest::didGetEntry(Entry* entry) |
| 585 { | 565 { |
| 586 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &DeleteEntryRequest::didHitError); | 566 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallbac
k>::create(this, &DeleteEntryRequest::didHitError); |
| 587 if (entry->isDirectory()) { | 567 if (entry->isDirectory()) { |
| 588 DirectoryEntry* directoryEntry = static_cast<DirectoryEntry*>(entry); | 568 DirectoryEntry* directoryEntry = static_cast<DirectoryEntry*>(entry); |
| 589 directoryEntry->removeRecursively(this, errorCallback); | 569 directoryEntry->removeRecursively(this, errorCallback); |
| 590 } else | 570 } else |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 for (Frame* frame = m_pageAgent->mainFrame(); frame; frame = frame->tree()->
traverseNext()) { | 705 for (Frame* frame = m_pageAgent->mainFrame(); frame; frame = frame->tree()->
traverseNext()) { |
| 726 if (frame->document() && frame->document()->securityOrigin()->isSameSche
meHostPort(origin)) | 706 if (frame->document() && frame->document()->securityOrigin()->isSameSche
meHostPort(origin)) |
| 727 return frame->document(); | 707 return frame->document(); |
| 728 } | 708 } |
| 729 | 709 |
| 730 *error = "No frame is available for the request"; | 710 *error = "No frame is available for the request"; |
| 731 return 0; | 711 return 0; |
| 732 } | 712 } |
| 733 | 713 |
| 734 } // namespace WebCore | 714 } // namespace WebCore |
| OLD | NEW |