Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Unified Diff: headless/lib/browser/headless_browser_impl.cc

Issue 2886693002: initial version of the headless download manager delegate
Patch Set: initial version of the headless download manager delegate Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: headless/lib/browser/headless_browser_impl.cc
diff --git a/headless/lib/browser/headless_browser_impl.cc b/headless/lib/browser/headless_browser_impl.cc
index c3c2f2570a1a7be848ee33247e82cbf9dc690588..8c8ce590646a27bc8c8689b00a4bd45fe4d3f888 100644
--- a/headless/lib/browser/headless_browser_impl.cc
+++ b/headless/lib/browser/headless_browser_impl.cc
@@ -161,6 +161,16 @@ HeadlessBrowserContext* HeadlessBrowserImpl::CreateBrowserContext(
browser_contexts_[browser_context->Id()] = std::move(browser_context);
+ HeadlessDownloadManagerDelegate* download_delegate =
+ static_cast<HeadlessDownloadManagerDelegate*>(
+ browser_context->GetDownloadManagerDelegate());
+
+ if (download_behavior_.has_value())
+ download_delegate->SetDownloadBehavior(download_behavior_.value());
+
+ if (download_path_.has_value())
+ download_delegate->SetDownloadDirectory(download_path_.value());
+
return result;
}
@@ -189,6 +199,37 @@ base::WeakPtr<HeadlessBrowserImpl> HeadlessBrowserImpl::GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
+void HeadlessBrowserImpl::SetDownloadBehavior(
+ HeadlessDownloadManagerDelegate::DownloadBehavior behavior) {
+ download_behavior_ = behavior;
+
+ for (HeadlessBrowserContext* hbc : GetAllBrowserContexts()) {
+ HeadlessBrowserContextImpl* hbci =
+ static_cast<HeadlessBrowserContextImpl*>(hbc);
+
+ HeadlessDownloadManagerDelegate* download_delegate =
+ static_cast<HeadlessDownloadManagerDelegate*>(
+ hbci->GetDownloadManagerDelegate());
+
+ download_delegate->SetDownloadBehavior(behavior);
+ }
+}
+
+void HeadlessBrowserImpl::SetDownloadDirectory(const base::FilePath& path) {
+ download_path_ = path;
+
+ for (HeadlessBrowserContext* hbc : GetAllBrowserContexts()) {
+ HeadlessBrowserContextImpl* hbci =
+ static_cast<HeadlessBrowserContextImpl*>(hbc);
+
+ HeadlessDownloadManagerDelegate* download_delegate =
+ static_cast<HeadlessDownloadManagerDelegate*>(
+ hbci->GetDownloadManagerDelegate());
+
+ download_delegate->SetDownloadDirectory(path);
+ }
+}
+
HeadlessWebContents* HeadlessBrowserImpl::GetWebContentsForDevToolsAgentHostId(
const std::string& devtools_agent_host_id) {
for (HeadlessBrowserContext* context : GetAllBrowserContexts()) {
« no previous file with comments | « headless/lib/browser/headless_browser_impl.h ('k') | headless/lib/browser/headless_devtools_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698