OSDN Git Service

Merge WebKit at r78450: Initial merge by git.
[android-x86/external-webkit.git] / Source / WebCore / platform / chromium / ChromiumDataObject.cpp
1 /*
2  * Copyright (c) 2010, 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
31 #include "config.h"
32 #include "ChromiumDataObject.h"
33
34 namespace WebCore {
35
36 ChromiumDataObject::ChromiumDataObject(PassRefPtr<ChromiumDataObjectLegacy> data)
37     : RefCounted<ChromiumDataObject>()
38     , m_legacyData(data)
39 {
40 }
41
42 ChromiumDataObject::ChromiumDataObject(PassRefPtr<ReadableDataObject> data)
43     : RefCounted<ChromiumDataObject>()
44     , m_readableData(data)
45 {
46 }
47
48 ChromiumDataObject::ChromiumDataObject(PassRefPtr<WritableDataObject> data)
49     : RefCounted<ChromiumDataObject>()
50     , m_writableData(data)
51 {
52 }
53
54 PassRefPtr<ChromiumDataObject> ChromiumDataObject::create(PassRefPtr<ChromiumDataObjectLegacy> data)
55 {
56     return adoptRef(new ChromiumDataObject(data));
57 }
58
59 PassRefPtr<ChromiumDataObject> ChromiumDataObject::createReadable(const Frame* frame, Clipboard::ClipboardType clipboardType)
60 {
61     return adoptRef(new ChromiumDataObject(ReadableDataObject::create(frame, clipboardType)));
62 }
63
64 PassRefPtr<ChromiumDataObject> ChromiumDataObject::createWritable(Clipboard::ClipboardType clipboardType)
65 {
66     return adoptRef(new ChromiumDataObject(WritableDataObject::create(clipboardType)));
67 }
68
69 void ChromiumDataObject::clearData(const String& type)
70 {
71     if (m_legacyData)
72         m_legacyData->clearData(type);
73     else
74         m_writableData->clearData(type);
75 }
76
77 void ChromiumDataObject::clearAll()
78 {
79     if (m_legacyData)
80         m_legacyData->clearAll();
81     else
82         m_writableData->clearAll();
83 }
84
85 void ChromiumDataObject::clearAllExceptFiles()
86 {
87     if (m_legacyData)
88         m_legacyData->clearAllExceptFiles();
89     else
90         m_writableData->clearAllExceptFiles();
91 }
92
93 bool ChromiumDataObject::hasData() const
94 {
95     if (m_legacyData)
96         return m_legacyData->hasData();
97     return m_readableData->hasData();
98 }
99
100 HashSet<String> ChromiumDataObject::types() const
101 {
102     if (m_legacyData)
103         return m_legacyData->types();
104     return m_readableData->types();
105 }
106
107 String ChromiumDataObject::getData(const String& type, bool& success)
108 {
109     if (m_legacyData)
110         return m_legacyData->getData(type, success);
111     return m_readableData->getData(type, success);
112 }
113
114 bool ChromiumDataObject::setData(const String& type, const String& data)
115 {
116     if (m_legacyData)
117         return m_legacyData->setData(type, data);
118     return m_writableData->setData(type, data);
119 }
120
121 String ChromiumDataObject::urlTitle() const
122 {
123     if (m_legacyData)
124         return m_legacyData->urlTitle();
125     return m_readableData->urlTitle();
126 }
127
128 void ChromiumDataObject::setUrlTitle(const String& urlTitle)
129 {
130     if (m_legacyData)
131         m_legacyData->setUrlTitle(urlTitle);
132     else
133         m_writableData->setUrlTitle(urlTitle);
134 }
135
136 KURL ChromiumDataObject::htmlBaseUrl() const
137 {
138     if (m_legacyData)
139         return m_legacyData->htmlBaseUrl();
140     return m_readableData->htmlBaseUrl();
141 }
142
143 void ChromiumDataObject::setHtmlBaseUrl(const KURL& url)
144 {
145     if (m_legacyData)
146         m_legacyData->setHtmlBaseUrl(url);
147     else
148         m_writableData->setHtmlBaseUrl(url);
149 }
150
151 bool ChromiumDataObject::containsFilenames() const
152 {
153     if (m_legacyData)
154         return m_legacyData->containsFilenames();
155     return m_readableData->containsFilenames();
156 }
157
158 Vector<String> ChromiumDataObject::filenames() const
159 {
160     if (m_legacyData)
161         return m_legacyData->filenames();
162     return m_readableData->filenames();
163 }
164
165 void ChromiumDataObject::setFilenames(const Vector<String>& filenames)
166 {
167     if (m_legacyData)
168         m_legacyData->setFilenames(filenames);
169     else
170         ASSERT_NOT_REACHED();
171 }
172
173 String ChromiumDataObject::fileExtension() const
174 {
175     if (m_legacyData)
176         return m_legacyData->fileExtension();
177     return m_writableData->fileExtension();
178 }
179
180 void ChromiumDataObject::setFileExtension(const String& fileExtension)
181 {
182     if (m_legacyData)
183         m_legacyData->setFileExtension(fileExtension);
184     else
185         m_writableData->setFileExtension(fileExtension);
186 }
187
188 String ChromiumDataObject::fileContentFilename() const
189 {
190     if (m_legacyData)
191         return m_legacyData->fileContentFilename();
192     return m_writableData->fileContentFilename();
193 }
194
195 void ChromiumDataObject::setFileContentFilename(const String& fileContentFilename)
196 {
197     if (m_legacyData)
198           m_legacyData->setFileContentFilename(fileContentFilename);
199     else
200           m_writableData->setFileContentFilename(fileContentFilename);
201 }
202
203 PassRefPtr<SharedBuffer> ChromiumDataObject::fileContent() const
204 {
205     if (m_legacyData)
206         return m_legacyData->fileContent();
207     return m_writableData->fileContent();
208 }
209
210 void ChromiumDataObject::setFileContent(PassRefPtr<SharedBuffer> fileContent)
211 {
212     if (m_legacyData)
213         m_legacyData->setFileContent(fileContent);
214     else
215         m_writableData->setFileContent(fileContent);
216 }
217
218 }
219