2012-06-28 19:21:18 +02:00
|
|
|
// Copyright (c) 2012 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.
|
|
|
|
|
|
|
|
#include "libcef/browser/download_item_impl.h"
|
|
|
|
|
|
|
|
#include "libcef/common/time_util.h"
|
|
|
|
|
|
|
|
#include "content/public/browser/download_item.h"
|
2013-07-24 22:15:18 +02:00
|
|
|
#include "url/gurl.h"
|
2012-06-28 19:21:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
CefDownloadItemImpl::CefDownloadItemImpl(content::DownloadItem* value)
|
|
|
|
: CefValueBase<CefDownloadItem, content::DownloadItem>(
|
|
|
|
value, NULL, kOwnerNoDelete, true,
|
|
|
|
new CefValueControllerNonThreadSafe()) {
|
|
|
|
// Indicate that this object owns the controller.
|
|
|
|
SetOwnsController();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefDownloadItemImpl::IsValid() {
|
|
|
|
return !detached();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefDownloadItemImpl::IsInProgress() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, false);
|
2013-06-22 04:06:32 +02:00
|
|
|
return const_value().GetState() == content::DownloadItem::IN_PROGRESS;
|
2012-06-28 19:21:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefDownloadItemImpl::IsComplete() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, false);
|
2013-06-22 04:06:32 +02:00
|
|
|
return const_value().GetState() == content::DownloadItem::COMPLETE;
|
2012-06-28 19:21:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefDownloadItemImpl::IsCanceled() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, false);
|
2013-06-22 04:06:32 +02:00
|
|
|
return const_value().GetState() == content::DownloadItem::CANCELLED;
|
2012-06-28 19:21:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int64 CefDownloadItemImpl::GetCurrentSpeed() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, 0);
|
|
|
|
return const_value().CurrentSpeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
int CefDownloadItemImpl::GetPercentComplete() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, -1);
|
|
|
|
return const_value().PercentComplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
int64 CefDownloadItemImpl::GetTotalBytes() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, 0);
|
|
|
|
return const_value().GetTotalBytes();
|
|
|
|
}
|
|
|
|
|
|
|
|
int64 CefDownloadItemImpl::GetReceivedBytes() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, 0);
|
|
|
|
return const_value().GetReceivedBytes();
|
|
|
|
}
|
|
|
|
|
|
|
|
CefTime CefDownloadItemImpl::GetStartTime() {
|
|
|
|
CefTime time;
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, time);
|
|
|
|
cef_time_from_basetime(const_value().GetStartTime(), time);
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefTime CefDownloadItemImpl::GetEndTime() {
|
|
|
|
CefTime time;
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, time);
|
|
|
|
cef_time_from_basetime(const_value().GetEndTime(), time);
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefString CefDownloadItemImpl::GetFullPath() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
|
|
|
return const_value().GetFullPath().value();
|
|
|
|
}
|
|
|
|
|
2013-07-24 22:15:18 +02:00
|
|
|
uint32 CefDownloadItemImpl::GetId() {
|
2012-06-28 19:21:18 +02:00
|
|
|
CEF_VALUE_VERIFY_RETURN(false, 0);
|
|
|
|
return const_value().GetId();
|
|
|
|
}
|
|
|
|
|
|
|
|
CefString CefDownloadItemImpl::GetURL() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
|
|
|
return const_value().GetURL().spec();
|
|
|
|
}
|
|
|
|
|
|
|
|
CefString CefDownloadItemImpl::GetSuggestedFileName() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
|
|
|
return const_value().GetSuggestedFilename();
|
|
|
|
}
|
|
|
|
|
|
|
|
CefString CefDownloadItemImpl::GetContentDisposition() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
|
|
|
return const_value().GetContentDisposition();
|
|
|
|
}
|
|
|
|
|
|
|
|
CefString CefDownloadItemImpl::GetMimeType() {
|
|
|
|
CEF_VALUE_VERIFY_RETURN(false, CefString());
|
|
|
|
return const_value().GetMimeType();
|
|
|
|
}
|