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.
5 #ifndef APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_
6 #define APPS_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 "content/public/browser/browser_main_parts.h"
12 #include "ui/aura/root_window_observer.h"
19 class ShellBrowserContext;
20 class ShellDevToolsDelegate;
21 struct MainFunctionParams;
24 namespace extensions {
25 class ShellExtensionsBrowserClient;
26 class ShellExtensionSystem;
43 class ShellBrowserContext;
44 class ShellExtensionsClient;
46 // Handles initialization of AppShell.
47 class ShellBrowserMainParts : public content::BrowserMainParts,
48 public aura::RootWindowObserver {
50 explicit ShellBrowserMainParts(
51 const content::MainFunctionParams& parameters);
52 virtual ~ShellBrowserMainParts();
54 ShellBrowserContext* browser_context() {
55 return browser_context_.get();
58 extensions::ShellExtensionSystem* extension_system() {
59 return extension_system_;
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;
71 // aura::RootWindowObserver overrides:
72 virtual void OnWindowTreeHostCloseRequested(const aura::RootWindow* root)
76 // Creates the window that hosts the apps.
77 void CreateRootWindow();
79 // Closes and destroys the root window hosting the app.
80 void DestroyRootWindow();
82 // Window placement is controlled by a ViewsDelegate.
83 void CreateViewsDelegate();
84 void DestroyViewsDelegate();
86 // Creates and initializes the ExtensionSystem.
87 void CreateExtensionSystem();
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_;
95 // Enable a minimal set of views::corewm to be initialized.
96 scoped_ptr<wm::WMTestHelper> wm_test_helper_;
98 scoped_ptr<aura::TestScreen> test_screen_;
100 scoped_ptr<views::Widget> webview_window_;
102 scoped_ptr<content::ShellDevToolsDelegate> devtools_delegate_;
104 // Owned by the BrowserContextKeyedService system.
105 extensions::ShellExtensionSystem* extension_system_;
107 DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts);
112 #endif // APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_