OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/i18n/icu_util.h" | 10 #include "base/i18n/icu_util.h" |
| 11 #include "base/memory/ptr_util.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
13 #include "base/power_monitor/power_monitor.h" | 14 #include "base/power_monitor/power_monitor.h" |
14 #include "base/power_monitor/power_monitor_device_source.h" | 15 #include "base/power_monitor/power_monitor_device_source.h" |
15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "ui/base/ime/input_method_initializer.h" | 18 #include "ui/base/ime/input_method_initializer.h" |
18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/base/ui_base_paths.h" | 20 #include "ui/base/ui_base_paths.h" |
20 #include "ui/compositor/test/in_process_context_factory.h" | 21 #include "ui/compositor/test/in_process_context_factory.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #if defined(USE_X11) | 55 #if defined(USE_X11) |
55 // This demo uses InProcessContextFactory which uses X on a separate Gpu | 56 // This demo uses InProcessContextFactory which uses X on a separate Gpu |
56 // thread. | 57 // thread. |
57 gfx::InitializeThreadedX11(); | 58 gfx::InitializeThreadedX11(); |
58 #endif | 59 #endif |
59 | 60 |
60 gfx::GLSurface::InitializeOneOff(); | 61 gfx::GLSurface::InitializeOneOff(); |
61 | 62 |
62 // The ContextFactory must exist before any Compositors are created. | 63 // The ContextFactory must exist before any Compositors are created. |
63 bool context_factory_for_test = false; | 64 bool context_factory_for_test = false; |
64 scoped_ptr<ui::InProcessContextFactory> context_factory( | 65 std::unique_ptr<ui::InProcessContextFactory> context_factory( |
65 new ui::InProcessContextFactory(context_factory_for_test, nullptr)); | 66 new ui::InProcessContextFactory(context_factory_for_test, nullptr)); |
66 context_factory->set_use_test_surface(false); | 67 context_factory->set_use_test_surface(false); |
67 | 68 |
68 base::MessageLoopForUI message_loop; | 69 base::MessageLoopForUI message_loop; |
69 | 70 |
70 base::i18n::InitializeICU(); | 71 base::i18n::InitializeICU(); |
71 | 72 |
72 ui::RegisterPathProvider(); | 73 ui::RegisterPathProvider(); |
73 | 74 |
74 base::FilePath ui_test_pak_path; | 75 base::FilePath ui_test_pak_path; |
75 CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); | 76 CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); |
76 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); | 77 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); |
77 | 78 |
78 base::PowerMonitor power_monitor(make_scoped_ptr( | 79 base::PowerMonitor power_monitor( |
79 new base::PowerMonitorDeviceSource)); | 80 base::WrapUnique(new base::PowerMonitorDeviceSource)); |
80 | 81 |
81 #if defined(OS_WIN) | 82 #if defined(OS_WIN) |
82 gfx::win::MaybeInitializeDirectWrite(); | 83 gfx::win::MaybeInitializeDirectWrite(); |
83 #endif | 84 #endif |
84 | 85 |
85 #if defined(USE_AURA) | 86 #if defined(USE_AURA) |
86 std::unique_ptr<aura::Env> env = aura::Env::CreateInstance(); | 87 std::unique_ptr<aura::Env> env = aura::Env::CreateInstance(); |
87 aura::Env::GetInstance()->set_context_factory(context_factory.get()); | 88 aura::Env::GetInstance()->set_context_factory(context_factory.get()); |
88 #endif | 89 #endif |
89 ui::InitializeInputMethodForTesting(); | 90 ui::InitializeInputMethodForTesting(); |
90 | 91 |
91 { | 92 { |
92 views::DesktopTestViewsDelegate views_delegate; | 93 views::DesktopTestViewsDelegate views_delegate; |
93 #if defined(USE_AURA) | 94 #if defined(USE_AURA) |
94 wm::WMState wm_state; | 95 wm::WMState wm_state; |
95 #endif | 96 #endif |
96 #if !defined(OS_CHROMEOS) && defined(USE_AURA) | 97 #if !defined(OS_CHROMEOS) && defined(USE_AURA) |
97 scoped_ptr<gfx::Screen> desktop_screen(views::CreateDesktopScreen()); | 98 std::unique_ptr<gfx::Screen> desktop_screen(views::CreateDesktopScreen()); |
98 gfx::Screen::SetScreenInstance(desktop_screen.get()); | 99 gfx::Screen::SetScreenInstance(desktop_screen.get()); |
99 #endif | 100 #endif |
100 | 101 |
101 views::examples::ShowExamplesWindow( | 102 views::examples::ShowExamplesWindow( |
102 views::examples::QUIT_ON_CLOSE, nullptr, | 103 views::examples::QUIT_ON_CLOSE, nullptr, |
103 scoped_ptr<ScopedVector<views::examples::ExampleBase>>()); | 104 std::unique_ptr<ScopedVector<views::examples::ExampleBase>>()); |
104 | 105 |
105 base::RunLoop().Run(); | 106 base::RunLoop().Run(); |
106 | 107 |
107 ui::ResourceBundle::CleanupSharedInstance(); | 108 ui::ResourceBundle::CleanupSharedInstance(); |
108 } | 109 } |
109 | 110 |
110 ui::ShutdownInputMethod(); | 111 ui::ShutdownInputMethod(); |
111 | 112 |
112 #if defined(USE_AURA) | 113 #if defined(USE_AURA) |
113 env.reset(); | 114 env.reset(); |
114 #endif | 115 #endif |
115 | 116 |
116 return 0; | 117 return 0; |
117 } | 118 } |
OLD | NEW |