Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: third_party/WebKit/Source/modules/filesystem/DOMWindowFileSystem.cpp

Issue 2297043002: Web expose FileSystemFileEntry, FileSystemDirectoryEntry and friends (Closed)
Patch Set: Rebased Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 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 met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
23 * DAMAGE. 23 * DAMAGE.
24 */ 24 */
25 25
26 #include "modules/filesystem/DOMWindowFileSystem.h" 26 #include "modules/filesystem/DOMWindowFileSystem.h"
27 27
28 #include "core/dom/Document.h" 28 #include "core/dom/Document.h"
29 #include "core/fileapi/FileError.h" 29 #include "core/fileapi/FileError.h"
30 #include "core/frame/LocalDOMWindow.h" 30 #include "core/frame/LocalDOMWindow.h"
31 #include "core/frame/UseCounter.h" 31 #include "core/frame/UseCounter.h"
32 #include "modules/filesystem/DOMFileSystem.h"
33 #include "modules/filesystem/EntryCallback.h"
34 #include "modules/filesystem/ErrorCallback.h" 32 #include "modules/filesystem/ErrorCallback.h"
33 #include "modules/filesystem/FileSystem.h"
35 #include "modules/filesystem/FileSystemCallback.h" 34 #include "modules/filesystem/FileSystemCallback.h"
36 #include "modules/filesystem/FileSystemCallbacks.h" 35 #include "modules/filesystem/FileSystemCallbacks.h"
36 #include "modules/filesystem/FileSystemEntryCallback.h"
37 #include "modules/filesystem/LocalFileSystem.h" 37 #include "modules/filesystem/LocalFileSystem.h"
38 #include "platform/FileSystemType.h" 38 #include "platform/FileSystemType.h"
39 #include "platform/weborigin/SchemeRegistry.h" 39 #include "platform/weborigin/SchemeRegistry.h"
40 #include "platform/weborigin/SecurityOrigin.h" 40 #include "platform/weborigin/SecurityOrigin.h"
41 41
42 namespace blink { 42 namespace blink {
43 43
44 void DOMWindowFileSystem::webkitRequestFileSystem( 44 void DOMWindowFileSystem::webkitRequestFileSystem(
45 DOMWindow& windowArg, 45 DOMWindow& windowArg,
46 int type, 46 int type,
47 long long size, 47 long long size,
48 FileSystemCallback* successCallback, 48 FileSystemCallback* successCallback,
49 ErrorCallback* errorCallback) { 49 ErrorCallback* errorCallback) {
50 LocalDOMWindow& window = toLocalDOMWindow(windowArg); 50 LocalDOMWindow& window = toLocalDOMWindow(windowArg);
51 if (!window.isCurrentlyDisplayedInFrame()) 51 if (!window.isCurrentlyDisplayedInFrame())
52 return; 52 return;
53 53
54 Document* document = window.document(); 54 Document* document = window.document();
55 if (!document) 55 if (!document)
56 return; 56 return;
57 57
58 if (SchemeRegistry::schemeShouldBypassContentSecurityPolicy( 58 if (SchemeRegistry::schemeShouldBypassContentSecurityPolicy(
59 document->getSecurityOrigin()->protocol())) 59 document->getSecurityOrigin()->protocol()))
60 UseCounter::count(document, UseCounter::RequestFileSystemNonWebbyOrigin); 60 UseCounter::count(document, UseCounter::RequestFileSystemNonWebbyOrigin);
61 61
62 if (!document->getSecurityOrigin()->canAccessFileSystem()) { 62 if (!document->getSecurityOrigin()->canAccessFileSystem()) {
63 DOMFileSystem::reportError(document, 63 FileSystem::reportError(document, ScriptErrorCallback::wrap(errorCallback),
64 ScriptErrorCallback::wrap(errorCallback), 64 FileError::kSecurityErr);
65 FileError::kSecurityErr);
66 return; 65 return;
67 } 66 }
68 67
69 FileSystemType fileSystemType = static_cast<FileSystemType>(type); 68 FileSystemType fileSystemType = static_cast<FileSystemType>(type);
70 if (!DOMFileSystemBase::isValidType(fileSystemType)) { 69 if (!FileSystemBase::isValidType(fileSystemType)) {
71 DOMFileSystem::reportError(document, 70 FileSystem::reportError(document, ScriptErrorCallback::wrap(errorCallback),
72 ScriptErrorCallback::wrap(errorCallback), 71 FileError::kInvalidModificationErr);
73 FileError::kInvalidModificationErr);
74 return; 72 return;
75 } 73 }
76 74
77 LocalFileSystem::from(*document)->requestFileSystem( 75 LocalFileSystem::from(*document)->requestFileSystem(
78 document, fileSystemType, size, 76 document, fileSystemType, size,
79 FileSystemCallbacks::create(successCallback, 77 FileSystemCallbacks::create(successCallback,
80 ScriptErrorCallback::wrap(errorCallback), 78 ScriptErrorCallback::wrap(errorCallback),
81 document, fileSystemType)); 79 document, fileSystemType));
82 } 80 }
83 81
84 void DOMWindowFileSystem::webkitResolveLocalFileSystemURL( 82 void DOMWindowFileSystem::webkitResolveLocalFileSystemURL(
85 DOMWindow& windowArg, 83 DOMWindow& windowArg,
86 const String& url, 84 const String& url,
87 EntryCallback* successCallback, 85 FileSystemEntryCallback* successCallback,
88 ErrorCallback* errorCallback) { 86 ErrorCallback* errorCallback) {
89 LocalDOMWindow& window = toLocalDOMWindow(windowArg); 87 LocalDOMWindow& window = toLocalDOMWindow(windowArg);
90 if (!window.isCurrentlyDisplayedInFrame()) 88 if (!window.isCurrentlyDisplayedInFrame())
91 return; 89 return;
92 90
93 Document* document = window.document(); 91 Document* document = window.document();
94 if (!document) 92 if (!document)
95 return; 93 return;
96 94
97 SecurityOrigin* securityOrigin = document->getSecurityOrigin(); 95 SecurityOrigin* securityOrigin = document->getSecurityOrigin();
98 KURL completedURL = document->completeURL(url); 96 KURL completedURL = document->completeURL(url);
99 if (!securityOrigin->canAccessFileSystem() || 97 if (!securityOrigin->canAccessFileSystem() ||
100 !securityOrigin->canRequest(completedURL)) { 98 !securityOrigin->canRequest(completedURL)) {
101 DOMFileSystem::reportError(document, 99 FileSystem::reportError(document, ScriptErrorCallback::wrap(errorCallback),
102 ScriptErrorCallback::wrap(errorCallback), 100 FileError::kSecurityErr);
103 FileError::kSecurityErr);
104 return; 101 return;
105 } 102 }
106 103
107 if (!completedURL.isValid()) { 104 if (!completedURL.isValid()) {
108 DOMFileSystem::reportError(document, 105 FileSystem::reportError(document, ScriptErrorCallback::wrap(errorCallback),
109 ScriptErrorCallback::wrap(errorCallback), 106 FileError::kEncodingErr);
110 FileError::kEncodingErr);
111 return; 107 return;
112 } 108 }
113 109
114 LocalFileSystem::from(*document)->resolveURL( 110 LocalFileSystem::from(*document)->resolveURL(
115 document, completedURL, 111 document, completedURL,
116 ResolveURICallbacks::create( 112 ResolveURICallbacks::create(
117 successCallback, ScriptErrorCallback::wrap(errorCallback), document)); 113 successCallback, ScriptErrorCallback::wrap(errorCallback), document));
118 } 114 }
119 115
120 static_assert( 116 static_assert(
121 static_cast<int>(DOMWindowFileSystem::kTemporary) == 117 static_cast<int>(DOMWindowFileSystem::kTemporary) ==
122 static_cast<int>(FileSystemTypeTemporary), 118 static_cast<int>(FileSystemTypeTemporary),
123 "DOMWindowFileSystem::kTemporary should match FileSystemTypeTemporary"); 119 "DOMWindowFileSystem::kTemporary should match FileSystemTypeTemporary");
124 static_assert( 120 static_assert(
125 static_cast<int>(DOMWindowFileSystem::kPersistent) == 121 static_cast<int>(DOMWindowFileSystem::kPersistent) ==
126 static_cast<int>(FileSystemTypePersistent), 122 static_cast<int>(FileSystemTypePersistent),
127 "DOMWindowFileSystem::kPersistent should match FileSystemTypePersistent"); 123 "DOMWindowFileSystem::kPersistent should match FileSystemTypePersistent");
128 124
129 } // namespace blink 125 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698