2020-06-25 04:34:12 +02:00
|
|
|
// Copyright 2019 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_browser_main_extra_parts_cef.h"
|
|
|
|
|
2021-04-09 01:15:51 +02:00
|
|
|
#include "libcef/browser/chrome/chrome_context_menu_handler.h"
|
2020-07-04 04:51:17 +02:00
|
|
|
#include "libcef/browser/context.h"
|
2022-04-15 21:55:23 +02:00
|
|
|
#include "libcef/browser/file_dialog_runner.h"
|
2021-02-16 00:24:28 +01:00
|
|
|
#include "libcef/browser/net/chrome_scheme_handler.h"
|
2022-07-07 12:01:24 +02:00
|
|
|
#include "libcef/browser/permission_prompt.h"
|
2020-07-04 04:51:17 +02:00
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
#include "base/task/thread_pool.h"
|
2023-02-17 20:08:00 +01:00
|
|
|
#include "chrome/browser/profiles/profile.h"
|
2020-06-25 04:34:12 +02:00
|
|
|
|
|
|
|
ChromeBrowserMainExtraPartsCef::ChromeBrowserMainExtraPartsCef() = default;
|
|
|
|
|
|
|
|
ChromeBrowserMainExtraPartsCef::~ChromeBrowserMainExtraPartsCef() = default;
|
|
|
|
|
2022-01-25 21:26:51 +01:00
|
|
|
void ChromeBrowserMainExtraPartsCef::PostProfileInit(Profile* profile,
|
|
|
|
bool is_initial_profile) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!is_initial_profile) {
|
2022-01-25 21:26:51 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2022-01-25 21:26:51 +01:00
|
|
|
|
2020-07-04 04:51:17 +02:00
|
|
|
CefRequestContextSettings settings;
|
|
|
|
CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
|
|
|
|
|
2023-02-17 20:08:00 +01:00
|
|
|
// Use the existing path for the initial profile.
|
|
|
|
CefString(&settings.cache_path) = profile->GetPath().value();
|
|
|
|
|
2020-07-04 04:51:17 +02:00
|
|
|
// Create the global RequestContext.
|
|
|
|
global_request_context_ =
|
|
|
|
CefRequestContextImpl::CreateGlobalRequestContext(settings);
|
|
|
|
}
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
|
2021-04-21 00:52:34 +02:00
|
|
|
background_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
|
|
{base::TaskPriority::BEST_EFFORT,
|
2020-06-25 04:34:12 +02:00
|
|
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
2021-04-21 00:52:34 +02:00
|
|
|
user_visible_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
|
|
{base::TaskPriority::USER_VISIBLE,
|
2020-06-25 04:34:12 +02:00
|
|
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
2021-04-21 00:52:34 +02:00
|
|
|
user_blocking_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
|
|
|
|
{base::TaskPriority::USER_BLOCKING,
|
2020-06-25 04:34:12 +02:00
|
|
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
2021-02-16 00:24:28 +01:00
|
|
|
|
|
|
|
scheme::RegisterWebUIControllerFactory();
|
2021-04-09 01:15:51 +02:00
|
|
|
context_menu::RegisterMenuCreatedCallback();
|
2022-04-15 21:55:23 +02:00
|
|
|
file_dialog_runner::RegisterFactory();
|
2022-07-07 12:01:24 +02:00
|
|
|
permission_prompt::RegisterCreateCallback();
|
2020-06-25 04:34:12 +02:00
|
|
|
}
|