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

Side by Side Diff: third_party/WebKit/Source/core/clipboard/DataObject.h

Issue 2875013002: DataTransfer: Make |types| be a FrozenArray<DOMString>. (Closed)
Patch Set: Use an observer to be notified of changes 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) 2008, 2009, Google Inc. All rights reserved. 2 * Copyright (c) 2008, 2009, 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 class WebDragData; 48 class WebDragData;
49 49
50 // A data object for holding data that would be in a clipboard or moved 50 // A data object for holding data that would be in a clipboard or moved
51 // during a drag-n-drop operation. This is the data that WebCore is aware 51 // during a drag-n-drop operation. This is the data that WebCore is aware
52 // of and is not specific to a platform. 52 // of and is not specific to a platform.
53 class CORE_EXPORT DataObject : public GarbageCollectedFinalized<DataObject>, 53 class CORE_EXPORT DataObject : public GarbageCollectedFinalized<DataObject>,
54 public Supplementable<DataObject> { 54 public Supplementable<DataObject> {
55 USING_GARBAGE_COLLECTED_MIXIN(DataObject); 55 USING_GARBAGE_COLLECTED_MIXIN(DataObject);
56 56
57 public: 57 public:
58 struct Observer : public GarbageCollectedMixin {
59 virtual void OnItemListChanged() {}
jsbell 2017/05/15 20:49:28 Make this pure virtual? i.e. replace `{}` with `=
Raphael Kubo da Costa (rakuco) 2017/05/16 08:51:51 Done.
60 };
61
58 static DataObject* CreateFromPasteboard(PasteMode); 62 static DataObject* CreateFromPasteboard(PasteMode);
59 static DataObject* CreateFromString(const String&); 63 static DataObject* CreateFromString(const String&);
60 static DataObject* Create(); 64 static DataObject* Create();
61 static DataObject* Create(WebDragData); 65 static DataObject* Create(WebDragData);
62 66
63 virtual ~DataObject(); 67 virtual ~DataObject();
64 68
65 // DataTransferItemList support. 69 // DataTransferItemList support.
66 size_t length() const; 70 size_t length() const;
67 DataObjectItem* Item(unsigned long index); 71 DataObjectItem* Item(unsigned long index);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 108
105 // Used to handle files (images) being dragged out. 109 // Used to handle files (images) being dragged out.
106 void AddSharedBuffer(PassRefPtr<SharedBuffer>, 110 void AddSharedBuffer(PassRefPtr<SharedBuffer>,
107 const KURL&, 111 const KURL&,
108 const String& filename_extension, 112 const String& filename_extension,
109 const AtomicString& content_disposition); 113 const AtomicString& content_disposition);
110 114
111 int GetModifiers() const { return modifiers_; } 115 int GetModifiers() const { return modifiers_; }
112 void SetModifiers(int modifiers) { modifiers_ = modifiers; } 116 void SetModifiers(int modifiers) { modifiers_ = modifiers; }
113 117
118 // Adds an observer (and retains a reference to it) that is notified
119 // whenever the underlying item_list_ changes.
120 void AddObserver(Observer*);
121
114 DECLARE_TRACE(); 122 DECLARE_TRACE();
115 123
116 WebDragData ToWebDragData(); 124 WebDragData ToWebDragData();
117 125
118 private: 126 private:
119 DataObject(); 127 DataObject();
120 128
121 DataObjectItem* FindStringItem(const String& type) const; 129 DataObjectItem* FindStringItem(const String& type) const;
122 bool InternalAddStringItem(DataObjectItem*); 130 bool InternalAddStringItem(DataObjectItem*);
123 void InternalAddFileItem(DataObjectItem*); 131 void InternalAddFileItem(DataObjectItem*);
124 132
133 void NotifyItemListChanged() const;
134
125 HeapVector<Member<DataObjectItem>> item_list_; 135 HeapVector<Member<DataObjectItem>> item_list_;
136 HeapHashSet<Member<Observer>> observers_;
126 137
127 // State of Shift/Ctrl/Alt/Meta keys and Left/Right/Middle mouse buttons 138 // State of Shift/Ctrl/Alt/Meta keys and Left/Right/Middle mouse buttons
128 int modifiers_; 139 int modifiers_;
129 String filesystem_id_; 140 String filesystem_id_;
130 }; 141 };
131 142
132 } // namespace blink 143 } // namespace blink
133 144
134 #endif 145 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698