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 struct MainFunctionParams
;
23 namespace devtools_http_handler
{
24 class DevToolsHttpHandler
;
31 namespace extensions
{
33 class AppWindowClient
;
34 class DesktopController
;
35 class ExtensionsBrowserClient
;
36 class ExtensionsClient
;
37 class ShellBrowserContext
;
38 class ShellBrowserMainDelegate
;
39 class ShellDeviceClient
;
40 class ShellExtensionSystem
;
41 class ShellOAuth2TokenService
;
42 class ShellUpdateQueryParamsDelegate
;
44 #if defined(OS_CHROMEOS)
45 class ShellAudioController
;
46 class ShellNetworkController
;
49 // Handles initialization of AppShell.
50 class ShellBrowserMainParts
: public content::BrowserMainParts
{
52 ShellBrowserMainParts(const content::MainFunctionParams
& parameters
,
53 ShellBrowserMainDelegate
* browser_main_delegate
);
54 ~ShellBrowserMainParts() override
;
56 ShellBrowserContext
* browser_context() { return browser_context_
.get(); }
58 ShellExtensionSystem
* extension_system() { return extension_system_
; }
60 // BrowserMainParts overrides.
61 void PreEarlyInitialization() override
;
62 void PreMainMessageLoopStart() override
;
63 void PostMainMessageLoopStart() override
;
64 int PreCreateThreads() override
;
65 void PreMainMessageLoopRun() override
;
66 bool MainMessageLoopRun(int* result_code
) override
;
67 void PostMainMessageLoopRun() override
;
68 void PostDestroyThreads() override
;
71 // app_shell embedders may need custom extensions client interfaces.
72 // This class takes ownership of the returned objects.
73 virtual ExtensionsClient
* CreateExtensionsClient();
74 virtual ExtensionsBrowserClient
* CreateExtensionsBrowserClient(
75 content::BrowserContext
* context
,
76 PrefService
* service
);
79 // Creates and initializes the ExtensionSystem.
80 void CreateExtensionSystem();
82 #if defined(OS_CHROMEOS)
83 scoped_ptr
<ShellNetworkController
> network_controller_
;
84 scoped_ptr
<ShellAudioController
> audio_controller_
;
86 scoped_ptr
<DesktopController
> desktop_controller_
;
87 scoped_ptr
<ShellBrowserContext
> browser_context_
;
88 scoped_ptr
<PrefService
> local_state_
;
89 scoped_ptr
<PrefService
> user_pref_service_
;
90 scoped_ptr
<ShellDeviceClient
> device_client_
;
91 scoped_ptr
<AppWindowClient
> app_window_client_
;
92 scoped_ptr
<ExtensionsClient
> extensions_client_
;
93 scoped_ptr
<ExtensionsBrowserClient
> extensions_browser_client_
;
94 scoped_ptr
<devtools_http_handler::DevToolsHttpHandler
> devtools_http_handler_
;
95 scoped_ptr
<ShellUpdateQueryParamsDelegate
> update_query_params_delegate_
;
96 scoped_ptr
<ShellOAuth2TokenService
> oauth2_token_service_
;
98 // Owned by the KeyedService system.
99 ShellExtensionSystem
* extension_system_
;
101 // For running app browsertests.
102 const content::MainFunctionParams parameters_
;
104 // If true, indicates the main message loop should be run
105 // in MainMessageLoopRun. If false, it has already been run.
106 bool run_message_loop_
;
108 scoped_ptr
<ShellBrowserMainDelegate
> browser_main_delegate_
;
110 #if !defined(DISABLE_NACL)
111 base::CancelableTaskTracker task_tracker_
;
114 DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts
);
117 } // namespace extensions
119 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_