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

Unified Diff: Source/core/fileapi/File.h

Issue 235373005: Handle JS-created files in <input type="file">. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed visibility bug. Created 6 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/core/v8/SerializedScriptValue.cpp ('k') | Source/core/fileapi/File.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fileapi/File.h
diff --git a/Source/core/fileapi/File.h b/Source/core/fileapi/File.h
index 41741c3e29145a4291fb0c05048b605d3a4e81d6..ea288d891e5d38461a4525be925796d8b64524af 100644
--- a/Source/core/fileapi/File.h
+++ b/Source/core/fileapi/File.h
@@ -47,9 +47,13 @@ public:
AllContentTypes,
};
+ // The user should not be able to browse to some files, such as the ones
+ // generated by the Filesystem API.
+ enum UserVisibility { IsUserVisible, IsNotUserVisible };
+
static PassRefPtrWillBeRawPtr<File> create(const String& path, ContentTypeLookupPolicy policy = WellKnownContentTypes)
{
- return adoptRefWillBeNoop(new File(path, policy));
+ return adoptRefWillBeNoop(new File(path, policy, File::IsUserVisible));
}
static PassRefPtrWillBeRawPtr<File> create(const String& name, double modificationTime, PassRefPtr<BlobDataHandle> blobDataHandle)
@@ -58,11 +62,11 @@ public:
}
// For deserialization.
- static PassRefPtrWillBeRawPtr<File> create(const String& path, const String& name, const String& relativePath, bool hasSnaphotData, uint64_t size, double lastModified, PassRefPtr<BlobDataHandle> blobDataHandle)
+ static PassRefPtrWillBeRawPtr<File> createFromSerialization(const String& path, const String& name, const String& relativePath, bool hasSnaphotData, uint64_t size, double lastModified, PassRefPtr<BlobDataHandle> blobDataHandle)
{
return adoptRefWillBeNoop(new File(path, name, relativePath, hasSnaphotData, size, lastModified, blobDataHandle));
}
- static PassRefPtrWillBeRawPtr<File> create(const String& path, const String& name, uint64_t size, double lastModified, PassRefPtr<BlobDataHandle> blobDataHandle)
+ static PassRefPtrWillBeRawPtr<File> createFromIndexedSerialization(const String& path, const String& name, uint64_t size, double lastModified, PassRefPtr<BlobDataHandle> blobDataHandle)
{
return adoptRefWillBeNoop(new File(path, name, String(), true, size, lastModified, blobDataHandle));
}
@@ -88,8 +92,15 @@ public:
static PassRefPtrWillBeRawPtr<File> createWithName(const String& path, const String& name, ContentTypeLookupPolicy policy = WellKnownContentTypes)
{
if (name.isEmpty())
- return adoptRefWillBeNoop(new File(path, policy));
- return adoptRefWillBeNoop(new File(path, name, policy));
+ return adoptRefWillBeNoop(new File(path, policy, File::IsNotUserVisible));
+ return adoptRefWillBeNoop(new File(path, name, policy, File::IsNotUserVisible));
+ }
+
+ static PassRefPtrWillBeRawPtr<File> createForFileSystemFile(const String& path, const String& name, ContentTypeLookupPolicy policy = WellKnownContentTypes)
+ {
+ if (name.isEmpty())
+ return adoptRefWillBeNoop(new File(path, policy, File::IsNotUserVisible));
+ return adoptRefWillBeNoop(new File(path, name, policy, File::IsNotUserVisible));
}
virtual unsigned long long size() const OVERRIDE;
@@ -107,6 +118,8 @@ public:
// This returns the current date and time if the file's last modification date is not known (per spec: http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate).
double lastModifiedDate() const;
+ UserVisibility userVisibility() const { return m_userVisibility; }
+
// Returns the relative path of this file in the context of a directory selection.
const String& webkitRelativePath() const { return m_relativePath; }
@@ -117,8 +130,8 @@ public:
bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; }
private:
- File(const String& path, ContentTypeLookupPolicy);
- File(const String& path, const String& name, ContentTypeLookupPolicy);
+ File(const String& path, ContentTypeLookupPolicy, UserVisibility);
+ File(const String& path, const String& name, ContentTypeLookupPolicy, UserVisibility);
File(const String& path, const String& name, const String& relativePath, bool hasSnaphotData, uint64_t size, double lastModified, PassRefPtr<BlobDataHandle>);
File(const String& name, double modificationTime, PassRefPtr<BlobDataHandle>);
File(const String& name, const FileMetadata&);
@@ -133,6 +146,7 @@ private:
#endif
bool m_hasBackingFile;
+ UserVisibility m_userVisibility;
String m_path;
String m_name;
« no previous file with comments | « Source/bindings/core/v8/SerializedScriptValue.cpp ('k') | Source/core/fileapi/File.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698