2020-06-25 04:34:12 +02:00
|
|
|
// Copyright 2020 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
|
|
|
|
|
|
|
|
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
|
|
|
|
#include "libcef/common/cef_switches.h"
|
|
|
|
|
|
|
|
#include "base/command_line.h"
|
2020-07-06 20:14:57 +02:00
|
|
|
#include "base/path_service.h"
|
2020-06-25 04:34:12 +02:00
|
|
|
#include "chrome/browser/chrome_browser_main.h"
|
2020-07-06 20:14:57 +02:00
|
|
|
#include "chrome/common/chrome_paths.h"
|
|
|
|
#include "chrome/common/chrome_switches.h"
|
2020-06-25 04:34:12 +02:00
|
|
|
|
|
|
|
ChromeContentBrowserClientCef::ChromeContentBrowserClientCef(
|
|
|
|
StartupData* startup_data)
|
|
|
|
: ChromeContentBrowserClient(startup_data) {}
|
|
|
|
ChromeContentBrowserClientCef::~ChromeContentBrowserClientCef() = default;
|
|
|
|
|
|
|
|
std::unique_ptr<content::BrowserMainParts>
|
|
|
|
ChromeContentBrowserClientCef::CreateBrowserMainParts(
|
|
|
|
const content::MainFunctionParams& parameters) {
|
|
|
|
auto main_parts =
|
|
|
|
ChromeContentBrowserClient::CreateBrowserMainParts(parameters);
|
|
|
|
browser_main_parts_ = new ChromeBrowserMainExtraPartsCef;
|
|
|
|
static_cast<ChromeBrowserMainParts*>(main_parts.get())
|
2020-08-29 00:39:23 +02:00
|
|
|
->AddParts(
|
|
|
|
base::WrapUnique<ChromeBrowserMainExtraParts>(browser_main_parts_));
|
2020-06-25 04:34:12 +02:00
|
|
|
return main_parts;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
|
|
|
|
base::CommandLine* command_line,
|
|
|
|
int child_process_id) {
|
|
|
|
ChromeContentBrowserClient::AppendExtraCommandLineSwitches(command_line,
|
|
|
|
child_process_id);
|
|
|
|
|
|
|
|
// Necessary to launch sub-processes in the correct mode.
|
|
|
|
command_line->AppendSwitch(switches::kEnableChromeRuntime);
|
2020-07-06 20:14:57 +02:00
|
|
|
|
|
|
|
// Necessary to populate DIR_USER_DATA in sub-processes.
|
|
|
|
// See resource_util.cc GetUserDataPath.
|
|
|
|
base::FilePath user_data_dir;
|
|
|
|
if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
|
|
|
|
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
|
|
|
|
}
|
2020-06-25 04:34:12 +02:00
|
|
|
}
|
|
|
|
|
2020-07-04 04:51:17 +02:00
|
|
|
CefRefPtr<CefRequestContextImpl>
|
|
|
|
ChromeContentBrowserClientCef::request_context() const {
|
|
|
|
return browser_main_parts_->request_context();
|
|
|
|
}
|
|
|
|
|
2020-06-25 04:34:12 +02:00
|
|
|
scoped_refptr<base::SingleThreadTaskRunner>
|
|
|
|
ChromeContentBrowserClientCef::background_task_runner() const {
|
|
|
|
return browser_main_parts_->background_task_runner();
|
|
|
|
}
|
|
|
|
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner>
|
|
|
|
ChromeContentBrowserClientCef::user_visible_task_runner() const {
|
|
|
|
return browser_main_parts_->user_visible_task_runner();
|
|
|
|
}
|
|
|
|
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner>
|
|
|
|
ChromeContentBrowserClientCef::user_blocking_task_runner() const {
|
|
|
|
return browser_main_parts_->user_blocking_task_runner();
|
|
|
|
}
|