| OLD | NEW |
| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 uint64_t sequence_number = | 50 uint64_t sequence_number = |
| 51 Platform::Current()->Clipboard()->SequenceNumber(buffer); | 51 Platform::Current()->Clipboard()->SequenceNumber(buffer); |
| 52 bool ignored; | 52 bool ignored; |
| 53 WebVector<WebString> web_types = | 53 WebVector<WebString> web_types = |
| 54 Platform::Current()->Clipboard()->ReadAvailableTypes(buffer, &ignored); | 54 Platform::Current()->Clipboard()->ReadAvailableTypes(buffer, &ignored); |
| 55 for (const WebString& type : web_types) { | 55 for (const WebString& type : web_types) { |
| 56 if (paste_mode == kPlainTextOnly && type != kMimeTypeTextPlain) | 56 if (paste_mode == kPlainTextOnly && type != kMimeTypeTextPlain) |
| 57 continue; | 57 continue; |
| 58 data_object->item_list_.push_back( | 58 data_object->item_list_.push_back( |
| 59 DataObjectItem::CreateFromPasteboard(type, sequence_number)); | 59 DataObjectItem::CreateFromPasteboard(type, sequence_number)); |
| 60 ASSERT(types_seen.insert(type).is_new_entry); | 60 #if DCHECK_IS_ON() |
| 61 DCHECK(types_seen.insert(type).is_new_entry); |
| 62 #endif |
| 61 } | 63 } |
| 62 return data_object; | 64 return data_object; |
| 63 } | 65 } |
| 64 | 66 |
| 65 DataObject* DataObject::CreateFromString(const String& data) { | 67 DataObject* DataObject::CreateFromString(const String& data) { |
| 66 DataObject* data_object = Create(); | 68 DataObject* data_object = Create(); |
| 67 data_object->Add(data, kMimeTypeTextPlain); | 69 data_object->Add(data, kMimeTypeTextPlain); |
| 68 return data_object; | 70 return data_object; |
| 69 } | 71 } |
| 70 | 72 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 Vector<String> results; | 137 Vector<String> results; |
| 136 #if DCHECK_IS_ON() | 138 #if DCHECK_IS_ON() |
| 137 HashSet<String> types_seen; | 139 HashSet<String> types_seen; |
| 138 #endif | 140 #endif |
| 139 bool contains_files = false; | 141 bool contains_files = false; |
| 140 for (const auto& item : item_list_) { | 142 for (const auto& item : item_list_) { |
| 141 switch (item->Kind()) { | 143 switch (item->Kind()) { |
| 142 case DataObjectItem::kStringKind: | 144 case DataObjectItem::kStringKind: |
| 143 // Per the spec, type must be unique among all items of kind 'string'. | 145 // Per the spec, type must be unique among all items of kind 'string'. |
| 144 results.push_back(item->GetType()); | 146 results.push_back(item->GetType()); |
| 145 ASSERT(types_seen.insert(item->GetType()).is_new_entry); | 147 #if DCHECK_IS_ON() |
| 148 DCHECK(types_seen.insert(item->GetType()).is_new_entry); |
| 149 #endif |
| 146 break; | 150 break; |
| 147 case DataObjectItem::kFileKind: | 151 case DataObjectItem::kFileKind: |
| 148 contains_files = true; | 152 contains_files = true; |
| 149 break; | 153 break; |
| 150 } | 154 } |
| 151 } | 155 } |
| 152 if (contains_files) { | 156 if (contains_files) { |
| 153 results.push_back(kMimeTypeFiles); | 157 results.push_back(kMimeTypeFiles); |
| 154 ASSERT(types_seen.insert(kMimeTypeFiles).is_new_entry); | 158 #if DCHECK_IS_ON() |
| 159 DCHECK(types_seen.insert(kMimeTypeFiles).is_new_entry); |
| 160 #endif |
| 155 } | 161 } |
| 156 return results; | 162 return results; |
| 157 } | 163 } |
| 158 | 164 |
| 159 String DataObject::GetData(const String& type) const { | 165 String DataObject::GetData(const String& type) const { |
| 160 for (size_t i = 0; i < item_list_.size(); ++i) { | 166 for (size_t i = 0; i < item_list_.size(); ++i) { |
| 161 if (item_list_[i]->Kind() == DataObjectItem::kStringKind && | 167 if (item_list_[i]->Kind() == DataObjectItem::kStringKind && |
| 162 item_list_[i]->GetType() == type) | 168 item_list_[i]->GetType() == type) |
| 163 return item_list_[i]->GetAsString(); | 169 return item_list_[i]->GetAsString(); |
| 164 } | 170 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } else { | 369 } else { |
| 364 NOTREACHED(); | 370 NOTREACHED(); |
| 365 } | 371 } |
| 366 item_list[i] = item; | 372 item_list[i] = item; |
| 367 } | 373 } |
| 368 data.SwapItems(item_list); | 374 data.SwapItems(item_list); |
| 369 return data; | 375 return data; |
| 370 } | 376 } |
| 371 | 377 |
| 372 } // namespace blink | 378 } // namespace blink |
| OLD | NEW |