Add a DownloadURL method on WebContents.
This commit is contained in:
parent
85b7aa6933
commit
c311c6cf1b
2 changed files with 11 additions and 0 deletions
|
@ -634,6 +634,15 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||||
web_contents()->GetController().LoadURLWithParams(params);
|
web_contents()->GetController().LoadURLWithParams(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebContents::DownloadURL(const GURL& url) {
|
||||||
|
auto browser_context = web_contents()->GetBrowserContext();
|
||||||
|
auto download_manager =
|
||||||
|
content::BrowserContext::GetDownloadManager(browser_context);
|
||||||
|
|
||||||
|
download_manager->DownloadUrl(
|
||||||
|
content::DownloadUrlParameters::FromWebContents(web_contents(), url));
|
||||||
|
}
|
||||||
|
|
||||||
GURL WebContents::GetURL() const {
|
GURL WebContents::GetURL() const {
|
||||||
return web_contents()->GetURL();
|
return web_contents()->GetURL();
|
||||||
}
|
}
|
||||||
|
@ -996,6 +1005,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
|
||||||
.SetMethod("getId", &WebContents::GetID)
|
.SetMethod("getId", &WebContents::GetID)
|
||||||
.SetMethod("equal", &WebContents::Equal)
|
.SetMethod("equal", &WebContents::Equal)
|
||||||
.SetMethod("_loadURL", &WebContents::LoadURL)
|
.SetMethod("_loadURL", &WebContents::LoadURL)
|
||||||
|
.SetMethod("downloadURL", &WebContents::DownloadURL)
|
||||||
.SetMethod("_getURL", &WebContents::GetURL)
|
.SetMethod("_getURL", &WebContents::GetURL)
|
||||||
.SetMethod("getTitle", &WebContents::GetTitle)
|
.SetMethod("getTitle", &WebContents::GetTitle)
|
||||||
.SetMethod("isLoading", &WebContents::IsLoading)
|
.SetMethod("isLoading", &WebContents::IsLoading)
|
||||||
|
|
|
@ -60,6 +60,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
int GetID() const;
|
int GetID() const;
|
||||||
bool Equal(const WebContents* web_contents) const;
|
bool Equal(const WebContents* web_contents) const;
|
||||||
void LoadURL(const GURL& url, const mate::Dictionary& options);
|
void LoadURL(const GURL& url, const mate::Dictionary& options);
|
||||||
|
void DownloadURL(const GURL& url);
|
||||||
GURL GetURL() const;
|
GURL GetURL() const;
|
||||||
base::string16 GetTitle() const;
|
base::string16 GetTitle() const;
|
||||||
bool IsLoading() const;
|
bool IsLoading() const;
|
||||||
|
|
Loading…
Reference in a new issue