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"
|
2012-02-18 01:19:52 +01:00
|
|
|
#include "base/file_path.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() {
|
2012-02-18 01:19:52 +01:00
|
|
|
return (data_.url.is_valid() && data_.file_description_filename.empty());
|
2011-08-22 03:31:55 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
bool CefDragDataImpl::IsFragment() {
|
2012-02-18 01:19:52 +01:00
|
|
|
return (!data_.url.is_valid() && data_.file_description_filename.empty() &&
|
2011-08-22 03:31:55 +02:00
|
|
|
data_.filenames.empty());
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
bool CefDragDataImpl::IsFile() {
|
2012-02-18 01:19:52 +01:00
|
|
|
return (!data_.file_description_filename.empty() || !data_.filenames.empty());
|
2011-08-22 03:31:55 +02:00
|
|
|
}
|
|
|
|
|
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() {
|
2012-06-22 21:25:44 +02:00
|
|
|
return data_.text.is_null() ? CefString() : CefString(data_.text.string());
|
2011-08-22 03:31:55 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CefString CefDragDataImpl::GetFragmentHtml() {
|
2012-06-22 21:25:44 +02:00
|
|
|
return data_.html.is_null() ? CefString() : CefString(data_.html.string());
|
2011-08-22 03:31:55 +02:00
|
|
|
}
|
|
|
|
|
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::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;
|
|
|
|
|
2012-05-23 21:01:04 +02:00
|
|
|
std::vector<WebDropData::FileInfo>::const_iterator it =
|
|
|
|
data_.filenames.begin();
|
2011-08-22 03:31:55 +02:00
|
|
|
for (; it != data_.filenames.end(); ++it)
|
2012-05-23 21:01:04 +02:00
|
|
|
names.push_back(it->path);
|
2011-08-22 03:31:55 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|