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

Side by Side Diff: Source/WebCore/fileapi/File.h

Issue 11370004: Revert 123677 - Merge 123495 - Files from drag and file <input> should use getMIMETypeForExtension … (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1180/
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « no previous file | Source/WebCore/fileapi/File.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
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 20 matching lines...) Expand all
31 #include <wtf/PassRefPtr.h> 31 #include <wtf/PassRefPtr.h>
32 #include <wtf/RefCounted.h> 32 #include <wtf/RefCounted.h>
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 struct FileMetadata; 36 struct FileMetadata;
37 class KURL; 37 class KURL;
38 38
39 class File : public Blob { 39 class File : public Blob {
40 public: 40 public:
41 // AllContentTypes should only be used when the full path/name are trusted; otherwise, it could 41 static PassRefPtr<File> create(const String& path)
42 // allow arbitrary pages to determine what applications an user has installe d.
43 enum ContentTypeLookupPolicy {
44 WellKnownContentTypes,
45 AllContentTypes,
46 };
47
48 static PassRefPtr<File> create(const String& path, ContentTypeLookupPolicy p olicy = WellKnownContentTypes)
49 { 42 {
50 return adoptRef(new File(path, policy)); 43 return adoptRef(new File(path));
51 } 44 }
52 45
53 // For deserialization. 46 // For deserialization.
54 static PassRefPtr<File> create(const String& path, const KURL& srcURL, const String& type) 47 static PassRefPtr<File> create(const String& path, const KURL& srcURL, const String& type)
55 { 48 {
56 return adoptRef(new File(path, srcURL, type)); 49 return adoptRef(new File(path, srcURL, type));
57 } 50 }
58 51
59 #if ENABLE(DIRECTORY_UPLOAD) 52 #if ENABLE(DIRECTORY_UPLOAD)
60 static PassRefPtr<File> createWithRelativePath(const String& path, const Str ing& relativePath); 53 static PassRefPtr<File> createWithRelativePath(const String& path, const Str ing& relativePath);
61 #endif 54 #endif
62 55
63 #if ENABLE(FILE_SYSTEM) 56 #if ENABLE(FILE_SYSTEM)
64 // If filesystem files live in the remote filesystem, the port might pass th e valid metadata (whose length field is non-negative) and cache in the File obje ct. 57 // If filesystem files live in the remote filesystem, the port might pass th e valid metadata (whose length field is non-negative) and cache in the File obje ct.
65 // 58 //
66 // Otherwise calling size(), lastModifiedTime() and slice() will synchronous ly query the file metadata. 59 // Otherwise calling size(), lastModifiedTime() and slice() will synchronous ly query the file metadata.
67 static PassRefPtr<File> createForFileSystemFile(const String& name, const Fi leMetadata& metadata) 60 static PassRefPtr<File> createForFileSystemFile(const String& name, const Fi leMetadata& metadata)
68 { 61 {
69 return adoptRef(new File(name, metadata)); 62 return adoptRef(new File(name, metadata));
70 } 63 }
71 #endif 64 #endif
72 65
73 // Create a file with a name exposed to the author (via File.name and associ ated DOM properties) that differs from the one provided in the path. 66 // Create a file with a name exposed to the author (via File.name and associ ated DOM properties) that differs from the one provided in the path.
74 static PassRefPtr<File> createWithName(const String& path, const String& nam e, ContentTypeLookupPolicy policy = WellKnownContentTypes) 67 static PassRefPtr<File> createWithName(const String& path, const String& nam e)
75 { 68 {
76 if (name.isEmpty()) 69 if (name.isEmpty())
77 return adoptRef(new File(path, policy)); 70 return adoptRef(new File(path));
78 return adoptRef(new File(path, name, policy)); 71 return adoptRef(new File(path, name));
79 } 72 }
80 73
81 virtual unsigned long long size() const; 74 virtual unsigned long long size() const;
82 virtual bool isFile() const { return true; } 75 virtual bool isFile() const { return true; }
83 76
84 const String& path() const { return m_path; } 77 const String& path() const { return m_path; }
85 const String& name() const { return m_name; } 78 const String& name() const { return m_name; }
86 79
87 // This may return NaN (which is converted to null Date in javascript layer) if getFileModificationTime() platform call has failed or the information is not available. 80 // This may return NaN (which is converted to null Date in javascript layer) if getFileModificationTime() platform call has failed or the information is not available.
88 double lastModifiedDate() const; 81 double lastModifiedDate() const;
89 82
90 #if ENABLE(DIRECTORY_UPLOAD) 83 #if ENABLE(DIRECTORY_UPLOAD)
91 // Returns the relative path of this file in the context of a directory sele ction. 84 // Returns the relative path of this file in the context of a directory sele ction.
92 const String& webkitRelativePath() const { return m_relativePath; } 85 const String& webkitRelativePath() const { return m_relativePath; }
93 #endif 86 #endif
94 87
95 // Note that this involves synchronous file operation. Think twice before ca lling this function. 88 // Note that this involves synchronous file operation. Think twice before ca lling this function.
96 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi me) const; 89 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi me) const;
97 90
98 private: 91 private:
99 File(const String& path, ContentTypeLookupPolicy); 92 File(const String& path);
100 93
101 // For deserialization. 94 // For deserialization.
102 File(const String& path, const KURL& srcURL, const String& type); 95 File(const String& path, const KURL& srcURL, const String& type);
103 File(const String& path, const String& name, ContentTypeLookupPolicy); 96 File(const String& path, const String& name);
104 97
105 # if ENABLE(FILE_SYSTEM) 98 # if ENABLE(FILE_SYSTEM)
106 File(const String& name, const FileMetadata&); 99 File(const String& name, const FileMetadata&);
107 100
108 // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize > = 0). 101 // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize > = 0).
109 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; } 102 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; }
110 #endif 103 #endif
111 104
112 String m_path; 105 String m_path;
113 String m_name; 106 String m_name;
(...skipping 18 matching lines...) Expand all
132 125
133 inline const File* toFile(const Blob* blob) 126 inline const File* toFile(const Blob* blob)
134 { 127 {
135 ASSERT(!blob || blob->isFile()); 128 ASSERT(!blob || blob->isFile());
136 return static_cast<const File*>(blob); 129 return static_cast<const File*>(blob);
137 } 130 }
138 131
139 } // namespace WebCore 132 } // namespace WebCore
140 133
141 #endif // File_h 134 #endif // File_h
OLDNEW
« no previous file with comments | « no previous file | Source/WebCore/fileapi/File.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698