void HeadlessShell::OnBrowserStart(HeadlessBrowser* browser) {
browser_ = browser;
#if defined(HEADLESS_USE_POLICY)
if (policy::HeadlessModePolicy::IsHeadlessDisabled(
static_cast<HeadlessBrowserImpl*>(browser)->GetPrefs())) {
LOG(ERROR) << "Headless mode is disabled by policy.";
ShutdownSoon();
return;
}
#endif
file_task_runner_ = base::ThreadPool::CreateSequencedTaskRunner(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT});
HeadlessBrowserContext::Builder context_builder =
browser_->CreateBrowserContextBuilder();
// Retrieve the locale set by InitApplicationLocale() in
// headless_content_main_delegate.cc in a way that is free of side-effects.
context_builder.SetAcceptLanguage(base::i18n::GetConfiguredLocale());
#if 0//disable incognito
context_builder.SetIncognitoMode(false);
#endif
browser_context_ = context_builder.Build();
browser_->SetDefaultBrowserContext(browser_context_);
base::CommandLine::StringVector args =
base::CommandLine::ForCurrentProcess()->GetArgs();
// If no explicit URL is present, navigate to about:blank, unless we're being
// driven by a debugger.
if (args.empty() && !IsRemoteDebuggingEnabled())
args.push_back(kAboutBlank);
if (!args.empty()) {
file_task_runner_->PostTaskAndReplyWithResult(
FROM_HERE, base::BindOnce(&ConvertArgumentToURL, args.front()),
base::BindOnce(&HeadlessShell::OnCommandLineURL,
weak_factory_.GetWeakPtr()));
}
}
设置不是隐身模式:
context_builder.SetIncognitoMode(false);
标签:浏览器,设置,builder,args,base,context,隐身,browser From: https://www.cnblogs.com/bigben0123/p/18210244