• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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 #ifndef CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
6 #define CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
7 #pragma once
8 
9 #include "libcef/browser/request_context_impl.h"
10 
11 #include "base/command_line.h"
12 #include "base/strings/string_piece.h"
13 #include "build/build_config.h"
14 #include "components/prefs/pref_service.h"
15 #include "content/public/browser/browser_main_parts.h"
16 #include "content/public/common/main_function_params.h"
17 
18 #if defined(USE_AURA)
19 namespace display {
20 class Screen;
21 }
22 namespace wm {
23 class WMState;
24 }
25 #endif
26 
27 #if defined(TOOLKIT_VIEWS)
28 namespace views {
29 class ViewsDelegate;
30 #if BUILDFLAG(IS_MAC)
31 class LayoutProvider;
32 #endif
33 }  // namespace views
34 #endif  // defined(TOOLKIT_VIEWS)
35 
36 class CefDevToolsDelegate;
37 
38 class AlloyBrowserMainParts : public content::BrowserMainParts {
39  public:
40   explicit AlloyBrowserMainParts(content::MainFunctionParams parameters);
41 
42   AlloyBrowserMainParts(const AlloyBrowserMainParts&) = delete;
43   AlloyBrowserMainParts& operator=(const AlloyBrowserMainParts&) = delete;
44 
45   ~AlloyBrowserMainParts() override;
46 
47   int PreEarlyInitialization() override;
48   void ToolkitInitialized() override;
49   void PreCreateMainMessageLoop() override;
50   void PostCreateMainMessageLoop() override;
51   int PreCreateThreads() override;
52   int PreMainMessageLoopRun() override;
53   void PostMainMessageLoopRun() override;
54   void PostDestroyThreads() override;
55 
request_context()56   CefRefPtr<CefRequestContextImpl> request_context() const {
57     return global_request_context_;
58   }
devtools_delegate()59   CefDevToolsDelegate* devtools_delegate() const { return devtools_delegate_; }
60 
background_task_runner()61   scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const {
62     return background_task_runner_;
63   }
user_visible_task_runner()64   scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const {
65     return user_visible_task_runner_;
66   }
user_blocking_task_runner()67   scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner()
68       const {
69     return user_blocking_task_runner_;
70   }
71 
72  private:
73 #if BUILDFLAG(IS_WIN)
74   void PlatformInitialize();
75 #endif  // BUILDFLAG(IS_WIN)
76 
77   content::MainFunctionParams parameters_;
78 
79   CefRefPtr<CefRequestContextImpl> global_request_context_;
80   CefDevToolsDelegate* devtools_delegate_ = nullptr;  // Deletes itself.
81 
82   // Blocking task runners exposed via CefTaskRunner. For consistency with
83   // previous named thread behavior always execute all pending tasks before
84   // shutdown (e.g. to make sure critical data is saved to disk).
85   // |background_task_runner_| is also passed to SQLitePersistentCookieStore.
86   scoped_refptr<base::SingleThreadTaskRunner> background_task_runner_;
87   scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner_;
88   scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner_;
89 
90 #if defined(USE_AURA)
91   std::unique_ptr<display::Screen> screen_;
92   std::unique_ptr<wm::WMState> wm_state_;
93 #endif
94 
95 #if defined(TOOLKIT_VIEWS)
96   std::unique_ptr<views::ViewsDelegate> views_delegate_;
97 #if BUILDFLAG(IS_MAC)
98   std::unique_ptr<views::LayoutProvider> layout_provider_;
99 #endif
100 #endif  // defined(TOOLKIT_VIEWS)
101 };
102 
103 #endif  // CEF_LIBCEF_BROWSER_ALLOY_ALLOY_BROWSER_MAIN_H_
104