Upstream version 5.34.104.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 "ui/aura/root_window_observer.h"
13
14 namespace aura {
15 class TestScreen;
16 }
17
18 namespace content {
19 class ShellBrowserContext;
20 class ShellDevToolsDelegate;
21 struct MainFunctionParams;
22 }
23
24 namespace extensions {
25 class ShellExtensionsBrowserClient;
26 class ShellExtensionSystem;
27 }
28
29 namespace views {
30 class Widget;
31 }
32
33 namespace net {
34 class NetLog;
35 }
36
37 namespace wm {
38 class WMTestHelper;
39 }
40
41 namespace apps {
42
43 class ShellBrowserContext;
44 class ShellExtensionsClient;
45
46 // Handles initialization of AppShell.
47 class ShellBrowserMainParts : public content::BrowserMainParts,
48                               public aura::RootWindowObserver {
49  public:
50   explicit ShellBrowserMainParts(
51       const content::MainFunctionParams& parameters);
52   virtual ~ShellBrowserMainParts();
53
54   ShellBrowserContext* browser_context() {
55     return browser_context_.get();
56   }
57
58   extensions::ShellExtensionSystem* extension_system() {
59     return extension_system_;
60   }
61
62   // BrowserMainParts overrides.
63   virtual void PreEarlyInitialization() OVERRIDE;
64   virtual void PreMainMessageLoopStart() OVERRIDE;
65   virtual void PostMainMessageLoopStart() OVERRIDE;
66   virtual int PreCreateThreads() OVERRIDE;
67   virtual void PreMainMessageLoopRun() OVERRIDE;
68   virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
69   virtual void PostMainMessageLoopRun() OVERRIDE;
70
71   // aura::RootWindowObserver overrides:
72   virtual void OnWindowTreeHostCloseRequested(const aura::RootWindow* root)
73       OVERRIDE;
74
75  private:
76   // Creates the window that hosts the apps.
77   void CreateRootWindow();
78
79   // Closes and destroys the root window hosting the app.
80   void DestroyRootWindow();
81
82   // Window placement is controlled by a ViewsDelegate.
83   void CreateViewsDelegate();
84   void DestroyViewsDelegate();
85
86   // Creates and initializes the ExtensionSystem.
87   void CreateExtensionSystem();
88
89   scoped_ptr<ShellBrowserContext> browser_context_;
90   scoped_ptr<ShellExtensionsClient> extensions_client_;
91   scoped_ptr<extensions::ShellExtensionsBrowserClient>
92       extensions_browser_client_;
93   scoped_ptr<net::NetLog> net_log_;
94
95   // Enable a minimal set of views::corewm to be initialized.
96   scoped_ptr<wm::WMTestHelper> wm_test_helper_;
97
98   scoped_ptr<aura::TestScreen> test_screen_;
99
100   scoped_ptr<views::Widget> webview_window_;
101
102   scoped_ptr<content::ShellDevToolsDelegate> devtools_delegate_;
103
104   // Owned by the BrowserContextKeyedService system.
105   extensions::ShellExtensionSystem* extension_system_;
106
107   DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts);
108 };
109
110 }  // namespace apps
111
112 #endif  // APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_