Roll src/third_party/WebKit 6f84130:7353389 (svn 184386:184391)
[chromium-blink-merge.git] / ui / views / examples / examples_main.cc
bloba751a0d29e78fa0c87f3551ca16ff4dc4a1b0279
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
3 // found in the LICENSE file.
5 #include "base/at_exit.h"
6 #include "base/command_line.h"
7 #include "base/files/file_path.h"
8 #include "base/i18n/icu_util.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h"
11 #include "base/run_loop.h"
12 #include "ui/base/ime/input_method_initializer.h"
13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/base/ui_base_paths.h"
15 #include "ui/compositor/test/in_process_context_factory.h"
16 #include "ui/gfx/screen.h"
17 #include "ui/gl/gl_surface.h"
18 #include "ui/views/examples/example_base.h"
19 #include "ui/views/examples/examples_window.h"
20 #include "ui/views/test/desktop_test_views_delegate.h"
22 #if defined(USE_AURA)
23 #include "ui/aura/env.h"
24 #include "ui/wm/core/wm_state.h"
25 #endif
27 #if !defined(OS_CHROMEOS) && defined(USE_AURA)
28 #include "ui/views/widget/desktop_aura/desktop_screen.h"
29 #endif
31 #if defined(OS_WIN)
32 #include "ui/base/win/scoped_ole_initializer.h"
33 #endif
35 #if defined(USE_X11)
36 #include "ui/gfx/x/x11_connection.h"
37 #endif
39 int main(int argc, char** argv) {
40 #if defined(OS_WIN)
41 ui::ScopedOleInitializer ole_initializer_;
42 #endif
44 CommandLine::Init(argc, argv);
46 base::AtExitManager at_exit;
48 #if defined(USE_X11)
49 // This demo uses InProcessContextFactory which uses X on a separate Gpu
50 // thread.
51 gfx::InitializeThreadedX11();
52 #endif
54 gfx::GLSurface::InitializeOneOff();
56 // The ContextFactory must exist before any Compositors are created.
57 scoped_ptr<ui::InProcessContextFactory> context_factory(
58 new ui::InProcessContextFactory());
60 base::MessageLoopForUI message_loop;
62 base::i18n::InitializeICU();
64 ui::RegisterPathProvider();
66 base::FilePath ui_test_pak_path;
67 DCHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
68 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
70 #if defined(USE_AURA)
71 aura::Env::CreateInstance(true);
72 aura::Env::GetInstance()->set_context_factory(context_factory.get());
73 #endif
74 ui::InitializeInputMethodForTesting();
77 views::DesktopTestViewsDelegate views_delegate;
78 #if defined(USE_AURA)
79 wm::WMState wm_state;
80 #endif
81 #if !defined(OS_CHROMEOS) && defined(USE_AURA)
82 scoped_ptr<gfx::Screen> desktop_screen(views::CreateDesktopScreen());
83 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
84 desktop_screen.get());
85 #endif
87 views::examples::ShowExamplesWindow(
88 views::examples::QUIT_ON_CLOSE,
89 NULL,
90 scoped_ptr<ScopedVector<views::examples::ExampleBase> >());
92 base::RunLoop().Run();
94 ui::ResourceBundle::CleanupSharedInstance();
97 ui::ShutdownInputMethod();
99 #if defined(USE_AURA)
100 aura::Env::DeleteInstance();
101 #endif
103 return 0;