From 997ac91fe03b3ed2a3bd133bb27e6ce8151b4498 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 21 Sep 2015 09:38:38 +0800 Subject: [PATCH] Add `donwloadItem.getContentDisposition()` API. --- atom/browser/api/atom_api_download_item.cc | 7 ++++++- atom/browser/api/atom_api_download_item.h | 1 + docs/api/download-item.md | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index 2e3068a5d3c..b056695a20b 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -71,6 +71,10 @@ std::string DownloadItem::GetSuggestedFilename() { return download_item_->GetSuggestedFilename(); } +std::string DownloadItem::GetContentDisposition() { + return download_item_->GetContentDisposition(); +} + void DownloadItem::Pause() { download_item_->Pause(); } @@ -94,7 +98,8 @@ mate::ObjectTemplateBuilder DownloadItem::GetObjectTemplateBuilder( .SetMethod("getURL", &DownloadItem::GetURL) .SetMethod("getMimeType", &DownloadItem::GetMimeType) .SetMethod("hasUserGesture", &DownloadItem::HasUserGesture) - .SetMethod("getSuggestedFilename", &DownloadItem::GetSuggestedFilename); + .SetMethod("getSuggestedFilename", &DownloadItem::GetSuggestedFilename) + .SetMethod("getContentDisposition", &DownloadItem::GetContentDisposition); } void SetWrapDownloadItem(const WrapDownloadItemCallback& callback) { diff --git a/atom/browser/api/atom_api_download_item.h b/atom/browser/api/atom_api_download_item.h index ca87a14ae80..e12064c825e 100644 --- a/atom/browser/api/atom_api_download_item.h +++ b/atom/browser/api/atom_api_download_item.h @@ -36,6 +36,7 @@ class DownloadItem : public mate::TrackableObject, std::string GetMimeType(); bool HasUserGesture(); std::string GetSuggestedFilename(); + std::string GetContentDisposition(); const GURL& GetURL(); private: diff --git a/docs/api/download-item.md b/docs/api/download-item.md index eacff629467..afbc4aea364 100644 --- a/docs/api/download-item.md +++ b/docs/api/download-item.md @@ -81,3 +81,8 @@ Returns a `Integer` represents the total size in bytes of the download item. ### `downloadItem.getReceivedBytes()` Returns a `Integer` represents the received bytes of the download item. + +### `downloadItem.getContentDisposition()` + +Returns a `String` represents the Content-Disposition field from the response +header.