Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors |
[email protected] | 147f809 | 2012-03-21 11:47:45 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | de7d61ff | 2013-08-20 11:30:41 | [diff] [blame] | 5 | #ifndef CONTENT_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_ |
6 | #define CONTENT_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_ | ||||
[email protected] | 147f809 | 2012-03-21 11:47:45 | [diff] [blame] | 7 | |
dcheng | 6003e0b | 2016-04-09 18:42:34 | [diff] [blame] | 8 | #include <memory> |
9 | |||||
chaopeng | 90e2c604 | 2017-11-22 22:47:43 | [diff] [blame] | 10 | #include "base/metrics/field_trial.h" |
avi | 66a0772 | 2015-12-25 23:38:12 | [diff] [blame] | 11 | #include "build/build_config.h" |
[email protected] | 147f809 | 2012-03-21 11:47:45 | [diff] [blame] | 12 | #include "content/public/browser/browser_main_parts.h" |
mkwst | 36b11b6f | 2014-10-15 16:18:56 | [diff] [blame] | 13 | #include "content/shell/browser/shell_browser_context.h" |
Xianzhu Wang | 6be66b01 | 2020-05-06 17:17:25 | [diff] [blame] | 14 | |
Julie Jeongeun Kim | bb75cae | 2023-05-20 13:37:51 | [diff] [blame] | 15 | #if BUILDFLAG(IS_IOS) |
Alvin Ji | 0ff2727 | 2024-03-13 21:57:27 | [diff] [blame] | 16 | #include "services/device/public/cpp/geolocation/geolocation_system_permission_manager.h" |
Julie Jeongeun Kim | bb75cae | 2023-05-20 13:37:51 | [diff] [blame] | 17 | #endif |
18 | |||||
Ulan Degenbaev | 70cc5275 | 2020-09-30 15:25:05 | [diff] [blame] | 19 | namespace performance_manager { |
20 | class PerformanceManagerLifetime; | ||||
21 | } // namespace performance_manager | ||||
22 | |||||
Will Harris | 09785ba | 2022-04-14 00:07:37 | [diff] [blame] | 23 | #if BUILDFLAG(IS_ANDROID) |
24 | namespace crash_reporter { | ||||
25 | class ChildExitObserver; | ||||
26 | } | ||||
27 | #endif | ||||
28 | |||||
[email protected] | 147f809 | 2012-03-21 11:47:45 | [diff] [blame] | 29 | namespace content { |
danakj | de3e2a0 | 2020-05-12 16:51:20 | [diff] [blame] | 30 | class ShellPlatformDelegate; |
[email protected] | 147f809 | 2012-03-21 11:47:45 | [diff] [blame] | 31 | |
Sergey Ulanov | d283ff9 | 2023-03-03 20:59:47 | [diff] [blame] | 32 | #if BUILDFLAG(IS_FUCHSIA) |
33 | class FuchsiaViewPresenter; | ||||
34 | #endif | ||||
35 | |||||
[email protected] | 147f809 | 2012-03-21 11:47:45 | [diff] [blame] | 36 | class ShellBrowserMainParts : public BrowserMainParts { |
37 | public: | ||||
Gabriel Charette | 4c1897a | 2022-05-02 18:22:25 | [diff] [blame] | 38 | ShellBrowserMainParts(); |
Peter Boström | 828b902 | 2021-09-21 02:28:43 | [diff] [blame] | 39 | |
40 | ShellBrowserMainParts(const ShellBrowserMainParts&) = delete; | ||||
41 | ShellBrowserMainParts& operator=(const ShellBrowserMainParts&) = delete; | ||||
42 | |||||
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 43 | ~ShellBrowserMainParts() override; |
[email protected] | 147f809 | 2012-03-21 11:47:45 | [diff] [blame] | 44 | |
[email protected] | 78089f0 | 2012-07-19 06:11:28 | [diff] [blame] | 45 | // BrowserMainParts overrides. |
Scott Violet | 9068b4df | 2018-01-12 16:44:21 | [diff] [blame] | 46 | int PreEarlyInitialization() override; |
jbudorick | e834612b | 2016-04-02 22:36:41 | [diff] [blame] | 47 | int PreCreateThreads() override; |
Xiaohan Wang | bd08442 | 2022-01-15 18:47:51 | [diff] [blame] | 48 | #if BUILDFLAG(IS_MAC) |
Gabriel Charette | 09c6a96e | 2021-05-17 14:52:59 | [diff] [blame] | 49 | void PreCreateMainMessageLoop() override; |
Maksim Sisov | 2ac2c31 | 2021-11-03 08:00:12 | [diff] [blame] | 50 | #endif |
51 | void PostCreateThreads() override; | ||||
Gabriel Charette | 09c6a96e | 2021-05-17 14:52:59 | [diff] [blame] | 52 | void PostCreateMainMessageLoop() override; |
Xianzhu Wang | 6be66b01 | 2020-05-06 17:17:25 | [diff] [blame] | 53 | void ToolkitInitialized() override; |
Gabriel Charette | c716bcf3 | 2021-03-16 16:25:35 | [diff] [blame] | 54 | int PreMainMessageLoopRun() override; |
55 | void WillRunMainMessageLoop( | ||||
56 | std::unique_ptr<base::RunLoop>& run_loop) override; | ||||
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 57 | void PostMainMessageLoopRun() override; |
ortuno | d7279d06 | 2016-01-16 02:08:31 | [diff] [blame] | 58 | void PostDestroyThreads() override; |
Julie Jeongeun Kim | bb75cae | 2023-05-20 13:37:51 | [diff] [blame] | 59 | #if BUILDFLAG(IS_IOS) |
Alvin Ji | 0ff2727 | 2024-03-13 21:57:27 | [diff] [blame] | 60 | device::GeolocationSystemPermissionManager* |
61 | GetGeolocationSystemPermissionManager(); | ||||
Julie Jeongeun Kim | bb75cae | 2023-05-20 13:37:51 | [diff] [blame] | 62 | #endif |
[email protected] | 147f809 | 2012-03-21 11:47:45 | [diff] [blame] | 63 | |
[email protected] | 3560b57 | 2012-04-04 20:47:32 | [diff] [blame] | 64 | ShellBrowserContext* browser_context() { return browser_context_.get(); } |
[email protected] | 71d504f | 2012-07-25 17:15:28 | [diff] [blame] | 65 | ShellBrowserContext* off_the_record_browser_context() { |
66 | return off_the_record_browser_context_.get(); | ||||
67 | } | ||||
[email protected] | 3560b57 | 2012-04-04 20:47:32 | [diff] [blame] | 68 | |
mkwst | 36b11b6f | 2014-10-15 16:18:56 | [diff] [blame] | 69 | protected: |
70 | virtual void InitializeBrowserContexts(); | ||||
71 | virtual void InitializeMessageLoopContext(); | ||||
danakj | de3e2a0 | 2020-05-12 16:51:20 | [diff] [blame] | 72 | // Gets the ShellPlatformDelegate to be used. May be a subclass of |
73 | // ShellPlatformDelegate to change behaviour based on platform or for tests. | ||||
74 | virtual std::unique_ptr<ShellPlatformDelegate> CreateShellPlatformDelegate(); | ||||
mkwst | 36b11b6f | 2014-10-15 16:18:56 | [diff] [blame] | 75 | |
76 | void set_browser_context(ShellBrowserContext* context) { | ||||
77 | browser_context_.reset(context); | ||||
78 | } | ||||
79 | void set_off_the_record_browser_context(ShellBrowserContext* context) { | ||||
80 | off_the_record_browser_context_.reset(context); | ||||
81 | } | ||||
82 | |||||
[email protected] | 147f809 | 2012-03-21 11:47:45 | [diff] [blame] | 83 | private: |
dcheng | 6003e0b | 2016-04-09 18:42:34 | [diff] [blame] | 84 | std::unique_ptr<ShellBrowserContext> browser_context_; |
85 | std::unique_ptr<ShellBrowserContext> off_the_record_browser_context_; | ||||
[email protected] | 3560b57 | 2012-04-04 20:47:32 | [diff] [blame] | 86 | |
Ulan Degenbaev | 70cc5275 | 2020-09-30 15:25:05 | [diff] [blame] | 87 | std::unique_ptr<performance_manager::PerformanceManagerLifetime> |
88 | performance_manager_lifetime_; | ||||
Will Harris | 09785ba | 2022-04-14 00:07:37 | [diff] [blame] | 89 | #if BUILDFLAG(IS_ANDROID) |
90 | std::unique_ptr<crash_reporter::ChildExitObserver> child_exit_observer_; | ||||
91 | #endif | ||||
Sergey Ulanov | d283ff9 | 2023-03-03 20:59:47 | [diff] [blame] | 92 | #if BUILDFLAG(IS_FUCHSIA) |
93 | std::unique_ptr<FuchsiaViewPresenter> fuchsia_view_presenter_; | ||||
94 | #endif | ||||
[email protected] | 147f809 | 2012-03-21 11:47:45 | [diff] [blame] | 95 | }; |
96 | |||||
97 | } // namespace content | ||||
98 | |||||
[email protected] | de7d61ff | 2013-08-20 11:30:41 | [diff] [blame] | 99 | #endif // CONTENT_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_ |