1 // Copyright 2014 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.
5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_
6 #define EXTENSIONS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/task/cancelable_task_tracker.h"
12 #include "content/public/browser/browser_main_parts.h"
13 #include "content/public/common/main_function_params.h"
14 #include "ui/aura/window_tree_host_observer.h"
20 class DevToolsHttpHandler
;
21 struct MainFunctionParams
;
28 namespace extensions
{
30 class AppWindowClient
;
31 class DesktopController
;
32 class ExtensionsBrowserClient
;
33 class ExtensionsClient
;
34 class ShellBrowserContext
;
35 class ShellBrowserMainDelegate
;
36 class ShellDeviceClient
;
37 class ShellExtensionSystem
;
38 class ShellOAuth2TokenService
;
39 class ShellUpdateQueryParamsDelegate
;
41 #if defined(OS_CHROMEOS)
42 class ShellAudioController
;
43 class ShellNetworkController
;
46 // Handles initialization of AppShell.
47 class ShellBrowserMainParts
: public content::BrowserMainParts
{
49 ShellBrowserMainParts(const content::MainFunctionParams
& parameters
,
50 ShellBrowserMainDelegate
* browser_main_delegate
);
51 ~ShellBrowserMainParts() override
;
53 ShellBrowserContext
* browser_context() { return browser_context_
.get(); }
55 ShellExtensionSystem
* extension_system() { return extension_system_
; }
57 // BrowserMainParts overrides.
58 void PreEarlyInitialization() override
;
59 void PreMainMessageLoopStart() override
;
60 void PostMainMessageLoopStart() override
;
61 int PreCreateThreads() override
;
62 void PreMainMessageLoopRun() override
;
63 bool MainMessageLoopRun(int* result_code
) override
;
64 void PostMainMessageLoopRun() override
;
65 void PostDestroyThreads() override
;
68 // app_shell embedders may need custom extensions client interfaces.
69 // This class takes ownership of the returned objects.
70 virtual ExtensionsClient
* CreateExtensionsClient();
71 virtual ExtensionsBrowserClient
* CreateExtensionsBrowserClient(
72 content::BrowserContext
* context
,
73 PrefService
* service
);
76 // Creates and initializes the ExtensionSystem.
77 void CreateExtensionSystem();
79 #if defined(OS_CHROMEOS)
80 scoped_ptr
<ShellNetworkController
> network_controller_
;
81 scoped_ptr
<ShellAudioController
> audio_controller_
;
83 scoped_ptr
<DesktopController
> desktop_controller_
;
84 scoped_ptr
<ShellBrowserContext
> browser_context_
;
85 scoped_ptr
<PrefService
> local_state_
;
86 scoped_ptr
<PrefService
> user_pref_service_
;
87 scoped_ptr
<ShellDeviceClient
> device_client_
;
88 scoped_ptr
<AppWindowClient
> app_window_client_
;
89 scoped_ptr
<ExtensionsClient
> extensions_client_
;
90 scoped_ptr
<ExtensionsBrowserClient
> extensions_browser_client_
;
91 scoped_ptr
<content::DevToolsHttpHandler
> devtools_http_handler_
;
92 scoped_ptr
<ShellUpdateQueryParamsDelegate
> update_query_params_delegate_
;
93 scoped_ptr
<ShellOAuth2TokenService
> oauth2_token_service_
;
95 // Owned by the KeyedService system.
96 ShellExtensionSystem
* extension_system_
;
98 // For running app browsertests.
99 const content::MainFunctionParams parameters_
;
101 // If true, indicates the main message loop should be run
102 // in MainMessageLoopRun. If false, it has already been run.
103 bool run_message_loop_
;
105 scoped_ptr
<ShellBrowserMainDelegate
> browser_main_delegate_
;
107 #if !defined(DISABLE_NACL)
108 base::CancelableTaskTracker task_tracker_
;
111 DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts
);
114 } // namespace extensions
116 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_