• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
6 
7 #include "libcef/browser/chrome/chrome_context_menu_handler.h"
8 #include "libcef/browser/context.h"
9 #include "libcef/browser/net/chrome_scheme_handler.h"
10 
11 #include "base/task/post_task.h"
12 #include "base/task/thread_pool.h"
13 
14 ChromeBrowserMainExtraPartsCef::ChromeBrowserMainExtraPartsCef() = default;
15 
16 ChromeBrowserMainExtraPartsCef::~ChromeBrowserMainExtraPartsCef() = default;
17 
PostProfileInit(Profile * profile,bool is_initial_profile)18 void ChromeBrowserMainExtraPartsCef::PostProfileInit(Profile* profile,
19                                                      bool is_initial_profile) {
20   if (!is_initial_profile)
21     return;
22 
23   CefRequestContextSettings settings;
24   CefContext::Get()->PopulateGlobalRequestContextSettings(&settings);
25 
26   // Create the global RequestContext.
27   global_request_context_ =
28       CefRequestContextImpl::CreateGlobalRequestContext(settings);
29 }
30 
PreMainMessageLoopRun()31 void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
32   background_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
33       {base::TaskPriority::BEST_EFFORT,
34        base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
35   user_visible_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
36       {base::TaskPriority::USER_VISIBLE,
37        base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
38   user_blocking_task_runner_ = base::ThreadPool::CreateSingleThreadTaskRunner(
39       {base::TaskPriority::USER_BLOCKING,
40        base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
41 
42   scheme::RegisterWebUIControllerFactory();
43   context_menu::RegisterMenuCreatedCallback();
44 }
45