bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const { if (m_platformDragData) return SUCCEEDED(m_platformDragData->QueryGetData(urlWFormat())) || SUCCEEDED(m_platformDragData->QueryGetData(urlFormat())) || (filenamePolicy == ConvertFilenames && (SUCCEEDED(m_platformDragData->QueryGetData(filenameWFormat())) || SUCCEEDED(m_platformDragData->QueryGetData(filenameFormat())))); return m_dragDataMap.contains(urlWFormat()->cfFormat) || m_dragDataMap.contains(urlFormat()->cfFormat) || (filenamePolicy == ConvertFilenames && (m_dragDataMap.contains(filenameWFormat()->cfFormat) || m_dragDataMap.contains(filenameFormat()->cfFormat))); }
bool DragData::containsURL() const { return SUCCEEDED(m_platformDragData->QueryGetData(urlWFormat())) || SUCCEEDED(m_platformDragData->QueryGetData(urlFormat())) || SUCCEEDED(m_platformDragData->QueryGetData(filenameWFormat())) || SUCCEEDED(m_platformDragData->QueryGetData(filenameFormat())); }
String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filenamePolicy, bool& success, String* title) { STGMEDIUM store; String url; success = false; if (getWebLocData(dataObject, url, title)) success = true; else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { // URL using Unicode UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal)); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) { // URL using ASCII char* data = static_cast<char*>(GlobalLock(store.hGlobal)); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } #if PLATFORM(CF) else if (filenamePolicy == DragData::ConvertFilenames) { if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) { // file using unicode wchar_t* data = static_cast<wchar_t*>(GlobalLock(store.hGlobal)); if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)data, wcslen(data))); if (urlFromPath(pathAsCFString.get(), url)) { if (title) *title = url; success = true; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) { // filename using ascii char* data = static_cast<char*>(GlobalLock(store.hGlobal)); if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, data, kCFStringEncodingASCII)); if (urlFromPath(pathAsCFString.get(), url)) { if (title) *title = url; success = true; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); } } #endif return url; }
String getURL(IDataObject* dataObject, bool& success, String* title) { STGMEDIUM store; String url; success = false; if (getWebLocData(dataObject, url, title)) { success = true; return url; } else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { //URL using unicode UChar* data = (UChar*)GlobalLock(store.hGlobal); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) { //URL using ascii char* data = (char*)GlobalLock(store.hGlobal); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) { //file using unicode wchar_t* data = (wchar_t*)GlobalLock(store.hGlobal); if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) { wchar_t fileURL[INTERNET_MAX_URL_LENGTH]; DWORD fileURLLength = sizeof(fileURL) / sizeof(fileURL[0]); if (SUCCEEDED(::UrlCreateFromPathW(data, fileURL, &fileURLLength, 0))) { url = String((UChar*)fileURL); if (title) *title = url; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) { //filename using ascii char* data = (char*)GlobalLock(store.hGlobal); if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) { char fileURL[INTERNET_MAX_URL_LENGTH]; DWORD fileURLLength = sizeof(fileURL) / sizeof(fileURL[0]); if (SUCCEEDED(::UrlCreateFromPathA(data, fileURL, &fileURLLength, 0))) { url = fileURL; if (title) *title = url; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } return url; }
String getURL(IDataObject* dataObject, bool& success, String* title) { STGMEDIUM store; String url; success = false; if (getWebLocData(dataObject, url, title)) { success = true; return url; } else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { //URL using unicode UChar* data = (UChar*)GlobalLock(store.hGlobal); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) { //URL using ascii char* data = (char*)GlobalLock(store.hGlobal); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) { //file using unicode wchar_t* data = (wchar_t*)GlobalLock(store.hGlobal); if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)data, wcslen(data))); if (urlFromPath(pathAsCFString.get(), url)) { if (title) *title = url; success = true; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) { //filename using ascii char* data = (char*)GlobalLock(store.hGlobal); if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, data, kCFStringEncodingASCII)); if (urlFromPath(pathAsCFString.get(), url)) { if (title) *title = url; success = true; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); } return url; }