2011-08-22 03:31:55 +02:00
|
|
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "libcef/drag_data_impl.h"
|
2011-08-22 03:31:55 +02:00
|
|
|
|
|
|
|
CefDragDataImpl::CefDragDataImpl(const WebDropData& data)
|
2012-01-10 00:46:23 +01:00
|
|
|
: data_(data) {
|
2011-08-22 03:31:55 +02:00
|
|
|
}
|
2012-01-10 00:46:23 +01:00
|
|
|
|
|
|
|
bool CefDragDataImpl::IsLink() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return (data_.url.is_valid() && data_.file_extension.empty());
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
bool CefDragDataImpl::IsFragment() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return (!data_.url.is_valid() && data_.file_extension.empty() &&
|
|
|
|
data_.filenames.empty());
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
bool CefDragDataImpl::IsFile() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return (!data_.file_extension.empty() || !data_.filenames.empty());
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CefString CefDragDataImpl::GetLinkURL() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return data_.url.spec();
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CefString CefDragDataImpl::GetLinkTitle() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return data_.url_title;
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CefString CefDragDataImpl::GetLinkMetadata() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return data_.download_metadata;
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CefString CefDragDataImpl::GetFragmentText() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return data_.plain_text;
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CefString CefDragDataImpl::GetFragmentHtml() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return data_.text_html;
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CefString CefDragDataImpl::GetFragmentBaseURL() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return data_.html_base_url.spec();
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CefString CefDragDataImpl::GetFileExtension() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return data_.file_extension;
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CefString CefDragDataImpl::GetFileName() {
|
2011-08-22 03:31:55 +02:00
|
|
|
return data_.file_description_filename;
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
bool CefDragDataImpl::GetFileNames(std::vector<CefString>& names) {
|
2011-08-22 03:31:55 +02:00
|
|
|
if (data_.filenames.empty())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
std::vector<string16>::const_iterator it = data_.filenames.begin();
|
|
|
|
for (; it != data_.filenames.end(); ++it)
|
|
|
|
names.push_back(*it);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|