mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add a new CefBrowserHost::StartDownload method for starting a download that can then be handled via CefDownloadHandler (issue #883).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1100 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -29,6 +29,8 @@
|
||||
#include "base/bind_helpers.h"
|
||||
#include "content/browser/renderer_host/render_view_host_impl.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/download_url_parameters.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "content/public/browser/navigation_controller.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
@ -555,6 +557,35 @@ void CefBrowserHostImpl::RunFileDialog(
|
||||
base::Bind(&CefRunFileDialogCallbackWrapper::Callback, wrapper));
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::StartDownload(const CefString& url) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBrowserHostImpl::StartDownload, this, url));
|
||||
return;
|
||||
}
|
||||
|
||||
GURL gurl = GURL(url.ToString());
|
||||
if (gurl.is_empty() || !gurl.is_valid())
|
||||
return;
|
||||
|
||||
if (!web_contents())
|
||||
return;
|
||||
|
||||
CefBrowserContext* context = _Context->browser_context();
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
scoped_refptr<content::DownloadManager> manager =
|
||||
content::BrowserContext::GetDownloadManager(context);
|
||||
if (!manager)
|
||||
return;
|
||||
|
||||
scoped_ptr<content::DownloadUrlParameters> params;
|
||||
params.reset(
|
||||
content::DownloadUrlParameters::FromWebContents(web_contents(), gurl));
|
||||
manager->DownloadUrl(params.Pass());
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::IsWindowRenderingDisabled() {
|
||||
return IsWindowRenderingDisabled(window_info_);
|
||||
}
|
||||
|
Reference in New Issue
Block a user