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

Unified Diff: headless/app/headless_shell.cc

Issue 2181413002: [headless] Remove default browser context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 years, 4 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/app/headless_shell.cc
diff --git a/headless/app/headless_shell.cc b/headless/app/headless_shell.cc
index a3e0b7435f6dbd5bc48bfba297f9df45501c68e8..1bcf70eb8d598da14cb46ff16d6f0d359d5da107 100644
--- a/headless/app/headless_shell.cc
+++ b/headless/app/headless_shell.cc
@@ -31,6 +31,7 @@
#include "ui/gfx/geometry/size.h"
using headless::HeadlessBrowser;
+using headless::HeadlessBrowserContext;
using headless::HeadlessDevToolsClient;
using headless::HeadlessWebContents;
namespace page = headless::page;
@@ -56,7 +57,10 @@ class HeadlessShell : public HeadlessWebContents::Observer, page::Observer {
void OnStart(HeadlessBrowser* browser) {
browser_ = browser;
- HeadlessWebContents::Builder builder(browser_->CreateWebContentsBuilder());
+ browser_context_ = browser_->CreateBrowserContextBuilder().Build();
+
+ HeadlessWebContents::Builder builder(
+ browser_context_->CreateWebContentsBuilder());
base::CommandLine::StringVector args =
base::CommandLine::ForCurrentProcess()->GetArgs();
@@ -81,6 +85,7 @@ class HeadlessShell : public HeadlessWebContents::Observer, page::Observer {
}
web_contents_->RemoveObserver(this);
web_contents_ = nullptr;
+ browser_context_.reset();
browser_->Shutdown();
}
@@ -280,6 +285,7 @@ class HeadlessShell : public HeadlessWebContents::Observer, page::Observer {
HeadlessWebContents* web_contents_;
bool processed_page_ready_;
std::unique_ptr<net::FileStream> screenshot_file_stream_;
+ std::unique_ptr<HeadlessBrowserContext> browser_context_;
DISALLOW_COPY_AND_ASSIGN(HeadlessShell);
};
@@ -339,6 +345,11 @@ int main(int argc, const char** argv) {
command_line.GetSwitchValueASCII(headless::switches::kUseGL));
}
+ if (command_line.HasSwitch(headless::switches::kUserDataDir)) {
+ builder.SetUserDataDir(
+ command_line.GetSwitchValuePath(headless::switches::kUserDataDir));
+ }
+
return HeadlessBrowserMain(
builder.Build(),
base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell)));

Powered by Google App Engine
This is Rietveld 408576698