Beispiel #1
0
void DataObject::htmlAndBaseURL(String& html, KURL& baseURL) const {
  DataObjectItem* item = findStringItem(mimeTypeTextHTML);
  if (!item)
    return;
  html = item->getAsString();
  baseURL = item->baseURL();
}
Beispiel #2
0
void DataObject::urlAndTitle(String& url, String* title) const {
  DataObjectItem* item = findStringItem(mimeTypeTextURIList);
  if (!item)
    return;
  url = convertURIListToURL(item->getAsString());
  if (title)
    *title = item->title();
}
Beispiel #3
0
WebDragData DataObject::toWebDragData() {
  WebDragData data;
  data.initialize();
  data.setModifierKeyState(m_modifiers);
  WebVector<WebDragData::Item> itemList(length());

  for (size_t i = 0; i < length(); ++i) {
    DataObjectItem* originalItem = item(i);
    WebDragData::Item item;
    if (originalItem->kind() == DataObjectItem::StringKind) {
      item.storageType = WebDragData::Item::StorageTypeString;
      item.stringType = originalItem->type();
      item.stringData = originalItem->getAsString();
    } else if (originalItem->kind() == DataObjectItem::FileKind) {
      if (originalItem->sharedBuffer()) {
        item.storageType = WebDragData::Item::StorageTypeBinaryData;
        item.binaryData = originalItem->sharedBuffer();
      } else if (originalItem->isFilename()) {
        Blob* blob = originalItem->getAsFile();
        if (blob->isFile()) {
          File* file = toFile(blob);
          if (file->hasBackingFile()) {
            item.storageType = WebDragData::Item::StorageTypeFilename;
            item.filenameData = file->path();
            item.displayNameData = file->name();
          } else if (!file->fileSystemURL().isEmpty()) {
            item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
            item.fileSystemURL = file->fileSystemURL();
            item.fileSystemFileSize = file->size();
          } else {
            // FIXME: support dragging constructed Files across renderers, see
            // http://crbug.com/394955
            item.storageType = WebDragData::Item::StorageTypeString;
            item.stringType = "text/plain";
            item.stringData = file->name();
          }
        } else {
          ASSERT_NOT_REACHED();
        }
      } else {
        ASSERT_NOT_REACHED();
      }
    } else {
      ASSERT_NOT_REACHED();
    }
    item.title = originalItem->title();
    item.baseURL = originalItem->baseURL();
    itemList[i] = item;
  }
  data.swapItems(itemList);
  return data;
}