| 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()) {
|
|
|