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

Side by Side Diff: third_party/WebKit/Source/core/clipboard/DataTransfer.cpp

Issue 2875013002: DataTransfer: Make |types| be a FrozenArray<DOMString>. (Closed)
Patch Set: Fix win_chromium_compile_dbg_ng Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 return ConvertURIListToURL(data); 185 return ConvertURIListToURL(data);
186 } 186 }
187 187
188 void DataTransfer::setData(const String& type, const String& data) { 188 void DataTransfer::setData(const String& type, const String& data) {
189 if (!CanWriteData()) 189 if (!CanWriteData())
190 return; 190 return;
191 191
192 data_object_->SetData(NormalizeType(type), data); 192 data_object_->SetData(NormalizeType(type), data);
193 } 193 }
194 194
195 // extensions beyond IE's API 195 bool DataTransfer::hasDataStoreItemListChanged() const {
196 Vector<String> DataTransfer::types() const { 196 return data_store_item_list_changed_ || !CanReadTypes();
197 Vector<String> types; 197 }
198
199 void DataTransfer::OnItemListChanged() {
200 data_store_item_list_changed_ = true;
201 }
202
203 Vector<String> DataTransfer::types() {
198 if (!CanReadTypes()) 204 if (!CanReadTypes())
199 return types; 205 return Vector<String>();
200 206
207 data_store_item_list_changed_ = false;
201 return data_object_->Types(); 208 return data_object_->Types();
202 } 209 }
203 210
204 FileList* DataTransfer::files() const { 211 FileList* DataTransfer::files() const {
205 FileList* files = FileList::Create(); 212 FileList* files = FileList::Create();
206 if (!CanReadData()) 213 if (!CanReadData())
207 return files; 214 return files;
208 215
209 for (size_t i = 0; i < data_object_->length(); ++i) { 216 for (size_t i = 0; i < data_object_->length(); ++i) {
210 if (data_object_->Item(i)->Kind() == DataObjectItem::kFileKind) { 217 if (data_object_->Item(i)->Kind() == DataObjectItem::kFileKind) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 return data_object_; 429 return data_object_;
423 } 430 }
424 431
425 DataTransfer::DataTransfer(DataTransferType type, 432 DataTransfer::DataTransfer(DataTransferType type,
426 DataTransferAccessPolicy policy, 433 DataTransferAccessPolicy policy,
427 DataObject* data_object) 434 DataObject* data_object)
428 : policy_(policy), 435 : policy_(policy),
429 drop_effect_("uninitialized"), 436 drop_effect_("uninitialized"),
430 effect_allowed_("uninitialized"), 437 effect_allowed_("uninitialized"),
431 transfer_type_(type), 438 transfer_type_(type),
432 data_object_(data_object) {} 439 data_object_(data_object),
440 data_store_item_list_changed_(true) {
441 data_object_->AddObserver(this);
442 }
433 443
434 void DataTransfer::setDragImage(ImageResourceContent* image, 444 void DataTransfer::setDragImage(ImageResourceContent* image,
435 Node* node, 445 Node* node,
436 const IntPoint& loc) { 446 const IntPoint& loc) {
437 if (!CanSetDragImage()) 447 if (!CanSetDragImage())
438 return; 448 return;
439 449
440 drag_image_ = image; 450 drag_image_ = image;
441 drag_loc_ = loc; 451 drag_loc_ = loc;
442 drag_image_element_ = node; 452 drag_image_element_ = node;
(...skipping 11 matching lines...) Expand all
454 return true; 464 return true;
455 } 465 }
456 } 466 }
457 return false; 467 return false;
458 } 468 }
459 469
460 bool DataTransfer::HasStringOfType(const String& type) const { 470 bool DataTransfer::HasStringOfType(const String& type) const {
461 if (!CanReadTypes()) 471 if (!CanReadTypes())
462 return false; 472 return false;
463 473
464 return types().Contains(type); 474 return data_object_->Types().Contains(type);
465 } 475 }
466 476
467 DragOperation ConvertDropZoneOperationToDragOperation( 477 DragOperation ConvertDropZoneOperationToDragOperation(
468 const String& drag_operation) { 478 const String& drag_operation) {
469 if (drag_operation == "copy") 479 if (drag_operation == "copy")
470 return kDragOperationCopy; 480 return kDragOperationCopy;
471 if (drag_operation == "move") 481 if (drag_operation == "move")
472 return kDragOperationMove; 482 return kDragOperationMove;
473 if (drag_operation == "link") 483 if (drag_operation == "link")
474 return kDragOperationLink; 484 return kDragOperationLink;
(...skipping 13 matching lines...) Expand all
488 } 498 }
489 } 499 }
490 500
491 DEFINE_TRACE(DataTransfer) { 501 DEFINE_TRACE(DataTransfer) {
492 visitor->Trace(data_object_); 502 visitor->Trace(data_object_);
493 visitor->Trace(drag_image_); 503 visitor->Trace(drag_image_);
494 visitor->Trace(drag_image_element_); 504 visitor->Trace(drag_image_element_);
495 } 505 }
496 506
497 } // namespace blink 507 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/clipboard/DataTransfer.h ('k') | third_party/WebKit/Source/core/clipboard/DataTransfer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698