Close crashed incognito-mode app's shell window.
[chromium-blink-merge.git] / apps / shell / shell_browser_main_parts.h
blob62ff7720109eb90747db9cd6fbfc69563525fdb6
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_SHELL_BROWSER_MAIN_PARTS_H_
6 #define APPS_SHELL_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"
14 namespace aura {
15 class TestScreen;
18 namespace content {
19 class ShellBrowserContext;
20 struct MainFunctionParams;
23 namespace extensions {
24 class ShellExtensionsBrowserClient;
25 class ShellExtensionSystem;
28 namespace wm {
29 class WMTestHelper;
32 namespace apps {
34 class ShellBrowserContext;
35 class ShellExtensionsClient;
37 // Handles initialization of AppShell.
38 class ShellBrowserMainParts : public content::BrowserMainParts,
39 public aura::RootWindowObserver {
40 public:
41 explicit ShellBrowserMainParts(
42 const content::MainFunctionParams& parameters);
43 virtual ~ShellBrowserMainParts();
45 ShellBrowserContext* browser_context() {
46 return browser_context_.get();
49 extensions::ShellExtensionSystem* extension_system() {
50 return extension_system_;
53 // BrowserMainParts overrides.
54 virtual void PreEarlyInitialization() OVERRIDE;
55 virtual void PreMainMessageLoopStart() OVERRIDE;
56 virtual void PostMainMessageLoopStart() OVERRIDE;
57 virtual int PreCreateThreads() OVERRIDE;
58 virtual void PreMainMessageLoopRun() OVERRIDE;
59 virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
60 virtual void PostMainMessageLoopRun() OVERRIDE;
62 // aura::RootWindowObserver overrides:
63 virtual void OnWindowTreeHostCloseRequested(const aura::RootWindow* root)
64 OVERRIDE;
66 private:
67 // Creates the window that hosts the apps.
68 void CreateRootWindow();
70 // Closes and destroys the root window hosting the app.
71 void DestroyRootWindow();
73 // Creates and initializes the ExtensionSystem.
74 void CreateExtensionSystem();
76 scoped_ptr<ShellBrowserContext> browser_context_;
77 scoped_ptr<ShellExtensionsClient> extensions_client_;
78 scoped_ptr<extensions::ShellExtensionsBrowserClient>
79 extensions_browser_client_;
81 // Enable a minimal set of views::corewm to be initialized.
82 scoped_ptr<wm::WMTestHelper> wm_test_helper_;
84 scoped_ptr<aura::TestScreen> test_screen_;
86 // Owned by the BrowserContextKeyedService system.
87 extensions::ShellExtensionSystem* extension_system_;
89 DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts);
92 } // namespace apps
94 #endif // APPS_SHELL_SHELL_BROWSER_MAIN_PARTS_H_