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

Side by Side Diff: Source/core/clipboard/DataObject.cpp

Issue 169323002: Oilpan: Move core/clipboard/ to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/clipboard/DataObject.h ('k') | Source/core/clipboard/DataObjectItem.h » ('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, 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2008, 2009, 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 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 #include "core/clipboard/DataObject.h" 32 #include "core/clipboard/DataObject.h"
33 33
34 #include "core/clipboard/Pasteboard.h" 34 #include "core/clipboard/Pasteboard.h"
35 #include "platform/clipboard/ClipboardMimeTypes.h" 35 #include "platform/clipboard/ClipboardMimeTypes.h"
36 #include "platform/clipboard/ClipboardUtilities.h" 36 #include "platform/clipboard/ClipboardUtilities.h"
37 #include "public/platform/Platform.h" 37 #include "public/platform/Platform.h"
38 #include "public/platform/WebClipboard.h" 38 #include "public/platform/WebClipboard.h"
39 39
40 namespace WebCore { 40 namespace WebCore {
41 41
42 PassRefPtr<DataObject> DataObject::createFromPasteboard(PasteMode pasteMode) 42 DEFINE_GC_INFO(DataObject);
43
44 PassRefPtrWillBeRawPtr<DataObject> DataObject::createFromPasteboard(PasteMode pa steMode)
43 { 45 {
44 RefPtr<DataObject> dataObject = create(); 46 RefPtrWillBeRawPtr<DataObject> dataObject = create();
45 blink::WebClipboard::Buffer buffer = Pasteboard::generalPasteboard()->buffer (); 47 blink::WebClipboard::Buffer buffer = Pasteboard::generalPasteboard()->buffer ();
46 uint64_t sequenceNumber = blink::Platform::current()->clipboard()->sequenceN umber(buffer); 48 uint64_t sequenceNumber = blink::Platform::current()->clipboard()->sequenceN umber(buffer);
47 bool ignored; 49 bool ignored;
48 blink::WebVector<blink::WebString> webTypes = blink::Platform::current()->cl ipboard()->readAvailableTypes(buffer, &ignored); 50 blink::WebVector<blink::WebString> webTypes = blink::Platform::current()->cl ipboard()->readAvailableTypes(buffer, &ignored);
49 ListHashSet<String> types; 51 ListHashSet<String> types;
50 for (size_t i = 0; i < webTypes.size(); ++i) 52 for (size_t i = 0; i < webTypes.size(); ++i)
51 types.add(webTypes[i]); 53 types.add(webTypes[i]);
52 for (ListHashSet<String>::const_iterator it = types.begin(); it != types.end (); ++it) { 54 for (ListHashSet<String>::const_iterator it = types.begin(); it != types.end (); ++it) {
53 if (pasteMode == PlainTextOnly && *it != mimeTypeTextPlain) 55 if (pasteMode == PlainTextOnly && *it != mimeTypeTextPlain)
54 continue; 56 continue;
55 dataObject->m_itemList.append(DataObjectItem::createFromPasteboard(*it, sequenceNumber)); 57 dataObject->m_itemList.append(DataObjectItem::createFromPasteboard(*it, sequenceNumber));
56 } 58 }
57 return dataObject.release(); 59 return dataObject.release();
58 } 60 }
59 61
60 PassRefPtr<DataObject> DataObject::create() 62 PassRefPtrWillBeRawPtr<DataObject> DataObject::create()
61 { 63 {
62 return adoptRef(new DataObject()); 64 return adoptRefWillBeNoop(new DataObject());
63 } 65 }
64 66
65 PassRefPtr<DataObject> DataObject::copy() const 67 PassRefPtrWillBeRawPtr<DataObject> DataObject::copy() const
66 { 68 {
67 return adoptRef(new DataObject(*this)); 69 return adoptRefWillBeNoop(new DataObject(*this));
68 } 70 }
69 71
70 size_t DataObject::length() const 72 size_t DataObject::length() const
71 { 73 {
72 return m_itemList.size(); 74 return m_itemList.size();
73 } 75 }
74 76
75 PassRefPtr<DataObjectItem> DataObject::item(unsigned long index) 77 PassRefPtrWillBeRawPtr<DataObjectItem> DataObject::item(unsigned long index)
76 { 78 {
77 if (index >= length()) 79 if (index >= length())
78 return nullptr; 80 return nullptr;
79 return m_itemList[index]; 81 return m_itemList[index];
80 } 82 }
81 83
82 void DataObject::deleteItem(unsigned long index) 84 void DataObject::deleteItem(unsigned long index)
83 { 85 {
84 if (index >= length()) 86 if (index >= length())
85 return; 87 return;
86 m_itemList.remove(index); 88 m_itemList.remove(index);
87 } 89 }
88 90
89 void DataObject::clearAll() 91 void DataObject::clearAll()
90 { 92 {
91 m_itemList.clear(); 93 m_itemList.clear();
92 } 94 }
93 95
94 PassRefPtr<DataObjectItem> DataObject::add(const String& data, const String& typ e) 96 PassRefPtrWillBeRawPtr<DataObjectItem> DataObject::add(const String& data, const String& type)
95 { 97 {
96 RefPtr<DataObjectItem> item = DataObjectItem::createFromString(type, data); 98 RefPtrWillBeRawPtr<DataObjectItem> item = DataObjectItem::createFromString(t ype, data);
97 if (!internalAddStringItem(item)) 99 if (!internalAddStringItem(item))
98 return nullptr; 100 return nullptr;
99 return item; 101 return item;
100 } 102 }
101 103
102 PassRefPtr<DataObjectItem> DataObject::add(PassRefPtr<File> file) 104 PassRefPtrWillBeRawPtr<DataObjectItem> DataObject::add(PassRefPtr<File> file)
103 { 105 {
104 if (!file) 106 if (!file)
105 return nullptr; 107 return nullptr;
106 108
107 RefPtr<DataObjectItem> item = DataObjectItem::createFromFile(file); 109 RefPtrWillBeRawPtr<DataObjectItem> item = DataObjectItem::createFromFile(fil e);
108 m_itemList.append(item); 110 m_itemList.append(item);
109 return item; 111 return item;
110 } 112 }
111 113
112 void DataObject::clearData(const String& type) 114 void DataObject::clearData(const String& type)
113 { 115 {
114 for (size_t i = 0; i < m_itemList.size(); ++i) { 116 for (size_t i = 0; i < m_itemList.size(); ++i) {
115 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i] ->type() == type) { 117 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i] ->type() == type) {
116 // Per the spec, type must be unique among all items of kind 'string '. 118 // Per the spec, type must be unique among all items of kind 'string '.
117 m_itemList.remove(i); 119 m_itemList.remove(i);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 bool DataObject::setData(const String& type, const String& data) 164 bool DataObject::setData(const String& type, const String& data)
163 { 165 {
164 clearData(type); 166 clearData(type);
165 if (!add(data, type)) 167 if (!add(data, type))
166 ASSERT_NOT_REACHED(); 168 ASSERT_NOT_REACHED();
167 return true; 169 return true;
168 } 170 }
169 171
170 void DataObject::urlAndTitle(String& url, String* title) const 172 void DataObject::urlAndTitle(String& url, String* title) const
171 { 173 {
172 RefPtr<DataObjectItem> item = findStringItem(mimeTypeTextURIList); 174 RefPtrWillBeRawPtr<DataObjectItem> item = findStringItem(mimeTypeTextURIList );
173 if (!item) 175 if (!item)
174 return; 176 return;
175 url = convertURIListToURL(item->getAsString()); 177 url = convertURIListToURL(item->getAsString());
176 if (title) 178 if (title)
177 *title = item->title(); 179 *title = item->title();
178 } 180 }
179 181
180 void DataObject::setURLAndTitle(const String& url, const String& title) 182 void DataObject::setURLAndTitle(const String& url, const String& title)
181 { 183 {
182 clearData(mimeTypeTextURIList); 184 clearData(mimeTypeTextURIList);
183 internalAddStringItem(DataObjectItem::createFromURL(url, title)); 185 internalAddStringItem(DataObjectItem::createFromURL(url, title));
184 } 186 }
185 187
186 void DataObject::htmlAndBaseURL(String& html, KURL& baseURL) const 188 void DataObject::htmlAndBaseURL(String& html, KURL& baseURL) const
187 { 189 {
188 RefPtr<DataObjectItem> item = findStringItem(mimeTypeTextHTML); 190 RefPtrWillBeRawPtr<DataObjectItem> item = findStringItem(mimeTypeTextHTML);
189 if (!item) 191 if (!item)
190 return; 192 return;
191 html = item->getAsString(); 193 html = item->getAsString();
192 baseURL = item->baseURL(); 194 baseURL = item->baseURL();
193 } 195 }
194 196
195 void DataObject::setHTMLAndBaseURL(const String& html, const KURL& baseURL) 197 void DataObject::setHTMLAndBaseURL(const String& html, const KURL& baseURL)
196 { 198 {
197 clearData(mimeTypeTextHTML); 199 clearData(mimeTypeTextHTML);
198 internalAddStringItem(DataObjectItem::createFromHTML(html, baseURL)); 200 internalAddStringItem(DataObjectItem::createFromHTML(html, baseURL));
(...skipping 27 matching lines...) Expand all
226 { 228 {
227 internalAddFileItem(DataObjectItem::createFromSharedBuffer(name, buffer)); 229 internalAddFileItem(DataObjectItem::createFromSharedBuffer(name, buffer));
228 } 230 }
229 231
230 DataObject::DataObject() 232 DataObject::DataObject()
231 : m_modifierKeyState(0) 233 : m_modifierKeyState(0)
232 { 234 {
233 } 235 }
234 236
235 DataObject::DataObject(const DataObject& other) 237 DataObject::DataObject(const DataObject& other)
236 : RefCounted<DataObject>() 238 : m_itemList(other.m_itemList)
237 , m_itemList(other.m_itemList)
238 , m_modifierKeyState(0) 239 , m_modifierKeyState(0)
239 { 240 {
240 } 241 }
241 242
242 PassRefPtr<DataObjectItem> DataObject::findStringItem(const String& type) const 243 PassRefPtrWillBeRawPtr<DataObjectItem> DataObject::findStringItem(const String& type) const
243 { 244 {
244 for (size_t i = 0; i < m_itemList.size(); ++i) { 245 for (size_t i = 0; i < m_itemList.size(); ++i) {
245 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i] ->type() == type) 246 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i] ->type() == type)
246 return m_itemList[i]; 247 return m_itemList[i];
247 } 248 }
248 return nullptr; 249 return nullptr;
249 } 250 }
250 251
251 bool DataObject::internalAddStringItem(PassRefPtr<DataObjectItem> item) 252 bool DataObject::internalAddStringItem(PassRefPtrWillBeRawPtr<DataObjectItem> it em)
252 { 253 {
253 ASSERT(item->kind() == DataObjectItem::StringKind); 254 ASSERT(item->kind() == DataObjectItem::StringKind);
254 for (size_t i = 0; i < m_itemList.size(); ++i) { 255 for (size_t i = 0; i < m_itemList.size(); ++i) {
255 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i] ->type() == item->type()) 256 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i] ->type() == item->type())
256 return false; 257 return false;
257 } 258 }
258 259
259 m_itemList.append(item); 260 m_itemList.append(item);
260 return true; 261 return true;
261 } 262 }
262 263
263 void DataObject::internalAddFileItem(PassRefPtr<DataObjectItem> item) 264 void DataObject::internalAddFileItem(PassRefPtrWillBeRawPtr<DataObjectItem> item )
264 { 265 {
265 ASSERT(item->kind() == DataObjectItem::FileKind); 266 ASSERT(item->kind() == DataObjectItem::FileKind);
266 m_itemList.append(item); 267 m_itemList.append(item);
267 } 268 }
268 269
270 void DataObject::trace(Visitor* visitor)
271 {
272 visitor->trace(m_itemList);
273 }
274
269 } // namespace WebCore 275 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/clipboard/DataObject.h ('k') | Source/core/clipboard/DataObjectItem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698