From c71cae325f19465632796ed23129e3c73e59fe11 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 20 Jan 2015 22:48:32 +0000 Subject: [PATCH] Add CefDownloadItem::GetOriginalUrl method (issue #1201). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1976 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- include/capi/cef_download_item_capi.h | 7 +++++++ include/cef_download_item.h | 6 ++++++ libcef/browser/download_item_impl.cc | 5 +++++ libcef/browser/download_item_impl.h | 1 + libcef_dll/cpptoc/download_item_cpptoc.cc | 16 ++++++++++++++++ libcef_dll/ctocpp/download_item_ctocpp.cc | 15 +++++++++++++++ libcef_dll/ctocpp/download_item_ctocpp.h | 1 + 7 files changed, 51 insertions(+) diff --git a/include/capi/cef_download_item_capi.h b/include/capi/cef_download_item_capi.h index fde2776dc..6da4c684b 100644 --- a/include/capi/cef_download_item_capi.h +++ b/include/capi/cef_download_item_capi.h @@ -125,6 +125,13 @@ typedef struct _cef_download_item_t { cef_string_userfree_t (CEF_CALLBACK *get_url)( struct _cef_download_item_t* self); + /// + // Returns the original URL before any redirections. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_original_url)( + struct _cef_download_item_t* self); + /// // Returns the suggested file name. /// diff --git a/include/cef_download_item.h b/include/cef_download_item.h index 6f76ff5e4..988ef6bde 100644 --- a/include/cef_download_item.h +++ b/include/cef_download_item.h @@ -126,6 +126,12 @@ class CefDownloadItem : public virtual CefBase { /*--cef()--*/ virtual CefString GetURL() =0; + /// + // Returns the original URL before any redirections. + /// + /*--cef()--*/ + virtual CefString GetOriginalUrl() =0; + /// // Returns the suggested file name. /// diff --git a/libcef/browser/download_item_impl.cc b/libcef/browser/download_item_impl.cc index ae8787744..f0f340d67 100644 --- a/libcef/browser/download_item_impl.cc +++ b/libcef/browser/download_item_impl.cc @@ -86,6 +86,11 @@ CefString CefDownloadItemImpl::GetURL() { return const_value().GetURL().spec(); } +CefString CefDownloadItemImpl::GetOriginalUrl() { + CEF_VALUE_VERIFY_RETURN(false, CefString()); + return const_value().GetOriginalUrl().spec(); +} + CefString CefDownloadItemImpl::GetSuggestedFileName() { CEF_VALUE_VERIFY_RETURN(false, CefString()); return const_value().GetSuggestedFilename(); diff --git a/libcef/browser/download_item_impl.h b/libcef/browser/download_item_impl.h index d3a6bb059..adc3d01c8 100644 --- a/libcef/browser/download_item_impl.h +++ b/libcef/browser/download_item_impl.h @@ -33,6 +33,7 @@ class CefDownloadItemImpl CefString GetFullPath() override; uint32 GetId() override; CefString GetURL() override; + CefString GetOriginalUrl() override; CefString GetSuggestedFileName() override; CefString GetContentDisposition() override; CefString GetMimeType() override; diff --git a/libcef_dll/cpptoc/download_item_cpptoc.cc b/libcef_dll/cpptoc/download_item_cpptoc.cc index 58b392585..d060e81bc 100644 --- a/libcef_dll/cpptoc/download_item_cpptoc.cc +++ b/libcef_dll/cpptoc/download_item_cpptoc.cc @@ -206,6 +206,21 @@ cef_string_userfree_t CEF_CALLBACK download_item_get_url( return _retval.DetachToUserFree(); } +cef_string_userfree_t CEF_CALLBACK download_item_get_original_url( + struct _cef_download_item_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefDownloadItemCppToC::Get(self)->GetOriginalUrl(); + + // Return type: string + return _retval.DetachToUserFree(); +} + cef_string_userfree_t CEF_CALLBACK download_item_get_suggested_file_name( struct _cef_download_item_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -270,6 +285,7 @@ CefDownloadItemCppToC::CefDownloadItemCppToC(CefDownloadItem* cls) struct_.struct_.get_full_path = download_item_get_full_path; struct_.struct_.get_id = download_item_get_id; struct_.struct_.get_url = download_item_get_url; + struct_.struct_.get_original_url = download_item_get_original_url; struct_.struct_.get_suggested_file_name = download_item_get_suggested_file_name; struct_.struct_.get_content_disposition = diff --git a/libcef_dll/ctocpp/download_item_ctocpp.cc b/libcef_dll/ctocpp/download_item_ctocpp.cc index f8763d629..908739a89 100644 --- a/libcef_dll/ctocpp/download_item_ctocpp.cc +++ b/libcef_dll/ctocpp/download_item_ctocpp.cc @@ -188,6 +188,21 @@ CefString CefDownloadItemCToCpp::GetURL() { return _retvalStr; } +CefString CefDownloadItemCToCpp::GetOriginalUrl() { + if (CEF_MEMBER_MISSING(struct_, get_original_url)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_original_url(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + CefString CefDownloadItemCToCpp::GetSuggestedFileName() { if (CEF_MEMBER_MISSING(struct_, get_suggested_file_name)) return CefString(); diff --git a/libcef_dll/ctocpp/download_item_ctocpp.h b/libcef_dll/ctocpp/download_item_ctocpp.h index a8d567ae4..af0cb5f05 100644 --- a/libcef_dll/ctocpp/download_item_ctocpp.h +++ b/libcef_dll/ctocpp/download_item_ctocpp.h @@ -46,6 +46,7 @@ class CefDownloadItemCToCpp virtual CefString GetFullPath() OVERRIDE; virtual uint32 GetId() OVERRIDE; virtual CefString GetURL() OVERRIDE; + virtual CefString GetOriginalUrl() OVERRIDE; virtual CefString GetSuggestedFileName() OVERRIDE; virtual CefString GetContentDisposition() OVERRIDE; virtual CefString GetMimeType() OVERRIDE;