OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <map> | 5 #include "content/public/app/content_main.h" |
| 6 #include "sandbox/src/sandbox_types.h" |
| 7 #include "ash/shell/content_client/shell_main_delegate.h" |
6 | 8 |
7 #include "ash/launcher/launcher.h" | 9 #if defined(OS_WIN) |
8 #include "ash/launcher/launcher_delegate.h" | 10 #include "content/public/app/startup_helper_win.h" |
9 #include "ash/launcher/launcher_model.h" | 11 #endif |
10 #include "ash/launcher/launcher_types.h" | |
11 #include "ash/shell.h" | |
12 #include "ash/shell_delegate.h" | |
13 #include "ash/shell_factory.h" | |
14 #include "ash/shell_window_ids.h" | |
15 #include "ash/shell/launcher_delegate_impl.h" | |
16 #include "ash/shell/shell_delegate_impl.h" | |
17 #include "ash/shell/shell_main_parts.h" | |
18 #include "ash/shell/window_watcher.h" | |
19 #include "base/at_exit.h" | |
20 #include "base/command_line.h" | |
21 #include "base/memory/scoped_ptr.h" | |
22 #include "base/message_loop.h" | |
23 #include "ui/aura/env.h" | |
24 #include "ui/aura/client/window_types.h" | |
25 #include "ui/aura/root_window.h" | |
26 #include "ui/aura/window_observer.h" | |
27 #include "ui/base/resource/resource_bundle.h" | |
28 #include "ui/base/ui_base_paths.h" | |
29 #include "ui/gfx/canvas.h" | |
30 #include "ui/gfx/compositor/test/compositor_test_support.h" | |
31 #include "ui/views/test/test_views_delegate.h" | |
32 #include "ui/views/widget/widget.h" | |
33 #include "ui/views/widget/widget_delegate.h" | |
34 | 12 |
35 namespace { | 13 #if defined(OS_WIN) |
36 | 14 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { |
37 class ShellViewsDelegate : public views::TestViewsDelegate { | 15 sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
38 public: | 16 content::InitializeSandboxInfo(&sandbox_info); |
39 ShellViewsDelegate() {} | 17 ash::shell::ShellMainDelegate delegate; |
40 virtual ~ShellViewsDelegate() {} | 18 return content::ContentMain(instance, &sandbox_info, &delegate); |
41 | |
42 // Overridden from views::TestViewsDelegate: | |
43 virtual views::NonClientFrameView* CreateDefaultNonClientFrameView( | |
44 views::Widget* widget) OVERRIDE { | |
45 return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(widget); | |
46 } | |
47 bool UseTransparentWindows() const OVERRIDE { | |
48 // Ash uses transparent window frames. | |
49 return true; | |
50 } | |
51 | |
52 private: | |
53 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegate); | |
54 }; | |
55 | |
56 } // namespace | |
57 | |
58 namespace ash { | |
59 namespace shell { | |
60 | |
61 void InitWindowTypeLauncher(); | |
62 | |
63 } // namespace shell | |
64 } // namespace ash | |
65 | |
66 int main(int argc, char** argv) { | |
67 CommandLine::Init(argc, argv); | |
68 | |
69 // The exit manager is in charge of calling the dtors of singleton objects. | |
70 base::AtExitManager exit_manager; | |
71 | |
72 ash::shell::PreMainMessageLoopStart(); | |
73 | |
74 // Create the message-loop here before creating the root window. | |
75 MessageLoop message_loop(MessageLoop::TYPE_UI); | |
76 ui::CompositorTestSupport::Initialize(); | |
77 | |
78 // A ViewsDelegate is required. | |
79 if (!views::ViewsDelegate::views_delegate) | |
80 views::ViewsDelegate::views_delegate = new ShellViewsDelegate; | |
81 | |
82 ash::shell::ShellDelegateImpl* delegate = new ash::shell::ShellDelegateImpl; | |
83 ash::Shell::CreateInstance(delegate); | |
84 | |
85 scoped_ptr<ash::shell::WindowWatcher> window_watcher( | |
86 new ash::shell::WindowWatcher); | |
87 delegate->SetWatcher(window_watcher.get()); | |
88 | |
89 ash::shell::InitWindowTypeLauncher(); | |
90 | |
91 ash::Shell::GetRootWindow()->ShowRootWindow(); | |
92 MessageLoopForUI::current()->Run(); | |
93 | |
94 window_watcher.reset(); | |
95 | |
96 ash::Shell::DeleteInstance(); | |
97 | |
98 aura::Env::DeleteInstance(); | |
99 | |
100 ui::CompositorTestSupport::Terminate(); | |
101 | |
102 return 0; | |
103 } | 19 } |
| 20 #else |
| 21 int main(int argc, const char** argv) { |
| 22 ash::shell::ShellMainDelegate delegate; |
| 23 return content::ContentMain(argc, argv, &delegate); |
| 24 } |
| 25 #endif |
OLD | NEW |