1 /* 2 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 #ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_DOM_FILE_SYSTEM_H_ 31 #define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_DOM_FILE_SYSTEM_H_ 32 33 #include "third_party/blink/public/platform/web_common.h" 34 #include "third_party/blink/public/platform/web_file_system_type.h" 35 #include "third_party/blink/public/platform/web_private_ptr.h" 36 #include "third_party/blink/public/platform/web_string.h" 37 #include "third_party/blink/public/platform/web_url.h" 38 #include "third_party/blink/public/web/web_frame.h" 39 40 namespace v8 { 41 class Isolate; 42 class Object; 43 class Value; 44 template <class T> 45 class Local; 46 } 47 48 namespace blink { 49 50 class DOMFileSystem; 51 52 class WebDOMFileSystem { 53 public: 54 enum SerializableType { 55 kSerializableTypeSerializable, 56 kSerializableTypeNotSerializable, 57 }; 58 enum EntryType { 59 kEntryTypeFile, 60 kEntryTypeDirectory, 61 }; 62 ~WebDOMFileSystem()63 ~WebDOMFileSystem() { Reset(); } 64 65 WebDOMFileSystem() = default; WebDOMFileSystem(const WebDOMFileSystem & d)66 WebDOMFileSystem(const WebDOMFileSystem& d) { Assign(d); } 67 WebDOMFileSystem& operator=(const WebDOMFileSystem& d) { 68 Assign(d); 69 return *this; 70 } 71 72 BLINK_EXPORT static WebDOMFileSystem FromV8Value(v8::Local<v8::Value>); 73 // Create file system URL from the given entry. 74 BLINK_EXPORT static WebURL CreateFileSystemURL(v8::Local<v8::Value> entry); 75 76 // FIXME: Deprecate the last argument when all filesystems become 77 // serializable. 78 BLINK_EXPORT static WebDOMFileSystem Create( 79 WebLocalFrame*, 80 WebFileSystemType, 81 const WebString& name, 82 const WebURL& root_url, 83 SerializableType = kSerializableTypeNotSerializable); 84 85 BLINK_EXPORT void Reset(); 86 BLINK_EXPORT void Assign(const WebDOMFileSystem&); 87 88 BLINK_EXPORT WebString GetName() const; 89 BLINK_EXPORT WebFileSystemType GetType() const; 90 BLINK_EXPORT WebURL RootURL() const; 91 92 BLINK_EXPORT v8::Local<v8::Value> ToV8Value( 93 v8::Local<v8::Object> creation_context, 94 v8::Isolate*); 95 BLINK_EXPORT v8::Local<v8::Value> CreateV8Entry( 96 const WebString& path, 97 EntryType, 98 v8::Local<v8::Object> creation_context, 99 v8::Isolate*); 100 IsNull()101 bool IsNull() const { return private_.IsNull(); } 102 103 #if INSIDE_BLINK 104 WebDOMFileSystem(DOMFileSystem*); 105 WebDOMFileSystem& operator=(DOMFileSystem*); 106 #endif 107 108 private: 109 WebPrivatePtr<DOMFileSystem> private_; 110 }; 111 112 } // namespace blink 113 114 #endif // THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_DOM_FILE_SYSTEM_H_ 115