Chromium Code Reviews| 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 e21fadfdadf89efad825ecd15c9a9f71492b0ff4..dbc60307386d51bdf1eee8a9bea45db8852e0d85 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() { |
| + const size_t old_length = item_list_.size(); |
|
jsbell
2017/05/15 20:49:28
We don't care about the size specifically, just th
Raphael Kubo da Costa (rakuco)
2017/05/16 08:51:51
Done.
|
| item_list_.clear(); |
| + if (old_length != item_list_.size()) |
| + 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) { |
| ASSERT(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); |
| } |