| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008, 2009 Google Inc. | 3 * Copyright (C) 2008, 2009 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 { | 55 { |
| 56 if (!m_clipboard->canReadTypes()) | 56 if (!m_clipboard->canReadTypes()) |
| 57 return 0; | 57 return 0; |
| 58 RefPtr<ChromiumDataObjectItem> item = m_dataObject->item(index); | 58 RefPtr<ChromiumDataObjectItem> item = m_dataObject->item(index); |
| 59 if (!item) | 59 if (!item) |
| 60 return 0; | 60 return 0; |
| 61 | 61 |
| 62 return DataTransferItem::create(m_clipboard, item); | 62 return DataTransferItem::create(m_clipboard, item); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void DataTransferItemList::deleteItem(unsigned long index, ExceptionState& es) | 65 void DataTransferItemList::deleteItem(unsigned long index, ExceptionState& excep
tionState) |
| 66 { | 66 { |
| 67 if (!m_clipboard->canWriteData()) { | 67 if (!m_clipboard->canWriteData()) { |
| 68 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 68 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 m_dataObject->deleteItem(index); | 71 m_dataObject->deleteItem(index); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void DataTransferItemList::clear() | 74 void DataTransferItemList::clear() |
| 75 { | 75 { |
| 76 if (!m_clipboard->canWriteData()) | 76 if (!m_clipboard->canWriteData()) |
| 77 return; | 77 return; |
| 78 m_dataObject->clearAll(); | 78 m_dataObject->clearAll(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 PassRefPtr<DataTransferItem> DataTransferItemList::add(const String& data, const
String& type, ExceptionState& es) | 81 PassRefPtr<DataTransferItem> DataTransferItemList::add(const String& data, const
String& type, ExceptionState& exceptionState) |
| 82 { | 82 { |
| 83 if (!m_clipboard->canWriteData()) | 83 if (!m_clipboard->canWriteData()) |
| 84 return 0; | 84 return 0; |
| 85 RefPtr<ChromiumDataObjectItem> item = m_dataObject->add(data, type, es); | 85 RefPtr<ChromiumDataObjectItem> item = m_dataObject->add(data, type, exceptio
nState); |
| 86 if (!item) | 86 if (!item) |
| 87 return 0; | 87 return 0; |
| 88 return DataTransferItem::create(m_clipboard, item); | 88 return DataTransferItem::create(m_clipboard, item); |
| 89 } | 89 } |
| 90 | 90 |
| 91 PassRefPtr<DataTransferItem> DataTransferItemList::add(PassRefPtr<File> file) | 91 PassRefPtr<DataTransferItem> DataTransferItemList::add(PassRefPtr<File> file) |
| 92 { | 92 { |
| 93 if (!m_clipboard->canWriteData()) | 93 if (!m_clipboard->canWriteData()) |
| 94 return 0; | 94 return 0; |
| 95 RefPtr<ChromiumDataObjectItem> item = m_dataObject->add(file); | 95 RefPtr<ChromiumDataObjectItem> item = m_dataObject->add(file); |
| 96 if (!item) | 96 if (!item) |
| 97 return 0; | 97 return 0; |
| 98 return DataTransferItem::create(m_clipboard, item); | 98 return DataTransferItem::create(m_clipboard, item); |
| 99 } | 99 } |
| 100 | 100 |
| 101 DataTransferItemList::DataTransferItemList(PassRefPtr<Clipboard> clipboard, Pass
RefPtr<ChromiumDataObject> dataObject) | 101 DataTransferItemList::DataTransferItemList(PassRefPtr<Clipboard> clipboard, Pass
RefPtr<ChromiumDataObject> dataObject) |
| 102 : m_clipboard(clipboard) | 102 : m_clipboard(clipboard) |
| 103 , m_dataObject(dataObject) | 103 , m_dataObject(dataObject) |
| 104 { | 104 { |
| 105 ScriptWrappable::init(this); | 105 ScriptWrappable::init(this); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace WebCore | 108 } // namespace WebCore |
| OLD | NEW |