Upstream version 9.37.197.0
[platform/framework/web/crosswalk.git] / src / apps / shell / browser / shell_browser_main_parts.h
1 // Copyright 2013 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 APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_
6 #define APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/browser/browser_main_parts.h"
12 #include "content/public/common/main_function_params.h"
13 #include "ui/aura/window_tree_host_observer.h"
14
15 namespace content {
16 class ShellBrowserContext;
17 class ShellDevToolsDelegate;
18 struct MainFunctionParams;
19 }
20
21 namespace extensions {
22 class ShellExtensionsBrowserClient;
23 class ShellExtensionSystem;
24 }
25
26 namespace views {
27 class Widget;
28 }
29
30 namespace net {
31 class NetLog;
32 }
33
34 namespace apps {
35
36 class ShellBrowserContext;
37 class ShellBrowserMainDelegate;
38 class ShellDesktopController;
39 class ShellExtensionsClient;
40
41 #if defined(OS_CHROMEOS)
42 class ShellNetworkController;
43 #endif
44
45 // Handles initialization of AppShell.
46 class ShellBrowserMainParts : public content::BrowserMainParts {
47  public:
48   ShellBrowserMainParts(const content::MainFunctionParams& parameters,
49                         ShellBrowserMainDelegate* browser_main_delegate);
50   virtual ~ShellBrowserMainParts();
51
52   ShellBrowserContext* browser_context() {
53     return browser_context_.get();
54   }
55
56   extensions::ShellExtensionSystem* extension_system() {
57     return extension_system_;
58   }
59
60   // BrowserMainParts overrides.
61   virtual void PreEarlyInitialization() OVERRIDE;
62   virtual void PreMainMessageLoopStart() OVERRIDE;
63   virtual void PostMainMessageLoopStart() OVERRIDE;
64   virtual int PreCreateThreads() OVERRIDE;
65   virtual void PreMainMessageLoopRun() OVERRIDE;
66   virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
67   virtual void PostMainMessageLoopRun() OVERRIDE;
68   virtual void PostDestroyThreads() OVERRIDE;
69
70  private:
71   // Creates and initializes the ExtensionSystem.
72   void CreateExtensionSystem();
73
74 #if defined(OS_CHROMEOS)
75   scoped_ptr<ShellNetworkController> network_controller_;
76 #endif
77   scoped_ptr<ShellDesktopController> desktop_controller_;
78   scoped_ptr<ShellBrowserContext> browser_context_;
79   scoped_ptr<ShellExtensionsClient> extensions_client_;
80   scoped_ptr<extensions::ShellExtensionsBrowserClient>
81       extensions_browser_client_;
82   scoped_ptr<net::NetLog> net_log_;
83
84   scoped_ptr<content::ShellDevToolsDelegate> devtools_delegate_;
85
86   // Owned by the KeyedService system.
87   extensions::ShellExtensionSystem* extension_system_;
88
89   // For running app browsertests.
90   const content::MainFunctionParams parameters_;
91
92   // If true, indicates the main message loop should be run
93   // in MainMessageLoopRun. If false, it has already been run.
94   bool run_message_loop_;
95
96   scoped_ptr<ShellBrowserMainDelegate> browser_main_delegate_;
97
98   DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts);
99 };
100
101 }  // namespace apps
102
103 #endif  // APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_