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

Unified Diff: third_party/WebKit/Source/core/clipboard/DataObject.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/clipboard/DataObject.cpp
diff --git a/third_party/WebKit/Source/core/clipboard/DataObject.cpp b/third_party/WebKit/Source/core/clipboard/DataObject.cpp
index 480e775cbb1b1fceb3fb0315b2f471605f8905c7..799c43096751a5c5713d7462949bde2f78526c6f 100644
--- a/third_party/WebKit/Source/core/clipboard/DataObject.cpp
+++ b/third_party/WebKit/Source/core/clipboard/DataObject.cpp
@@ -90,10 +90,14 @@ void DataObject::DeleteItem(unsigned long index) {
if (index >= length())
return;
item_list_.erase(index);
+ NotifyItemListChanged();
}
void DataObject::ClearAll() {
+ if (item_list_.IsEmpty())
+ return;
item_list_.clear();
+ NotifyItemListChanged();
}
DataObjectItem* DataObject::Add(const String& data, const String& type) {
@@ -128,6 +132,7 @@ void DataObject::ClearData(const String& type) {
item_list_[i]->GetType() == type) {
// Per the spec, type must be unique among all items of kind 'string'.
item_list_.erase(i);
+ NotifyItemListChanged();
return;
}
}
@@ -256,16 +261,29 @@ bool DataObject::InternalAddStringItem(DataObjectItem* item) {
}
item_list_.push_back(item);
+ NotifyItemListChanged();
return true;
}
void DataObject::InternalAddFileItem(DataObjectItem* item) {
DCHECK_EQ(item->Kind(), DataObjectItem::kFileKind);
item_list_.push_back(item);
+ NotifyItemListChanged();
+}
+
+void DataObject::AddObserver(Observer* observer) {
+ DCHECK(!observers_.Contains(observer));
+ observers_.insert(observer);
+}
+
+void DataObject::NotifyItemListChanged() const {
+ for (const auto& observer : observers_)
+ observer->OnItemListChanged();
}
DEFINE_TRACE(DataObject) {
visitor->Trace(item_list_);
+ visitor->Trace(observers_);
Supplementable<DataObject>::Trace(visitor);
}
« no previous file with comments | « third_party/WebKit/Source/core/clipboard/DataObject.h ('k') | third_party/WebKit/Source/core/clipboard/DataObjectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698