diff options
Diffstat (limited to 'ui/views/examples/examples_main.cc')
-rw-r--r-- | ui/views/examples/examples_main.cc | 110 |
1 files changed, 97 insertions, 13 deletions
diff --git a/ui/views/examples/examples_main.cc b/ui/views/examples/examples_main.cc index bd2fbf3..699f26f 100644 --- a/ui/views/examples/examples_main.cc +++ b/ui/views/examples/examples_main.cc @@ -2,23 +2,107 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/public/app/content_main.h" -#include "sandbox/src/sandbox_types.h" -#include "ui/views/examples/content_client/examples_main_delegate.h" +#include "base/at_exit.h" +#include "base/command_line.h" +#include "base/i18n/icu_util.h" +#include "base/logging.h" +#include "base/message_loop.h" +#include "base/process_util.h" +#include "base/stl_util.h" +#include "base/utf_string_conversions.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_paths.h" +#include "ui/views/examples/examples_window.h" +#include "ui/views/focus/accelerator_handler.h" +#include "ui/views/test/test_views_delegate.h" +#include "ui/views/widget/widget.h" #if defined(OS_WIN) -#include "content/public/app/startup_helper_win.h" +#include "ui/base/win/scoped_ole_initializer.h" #endif +#if defined(USE_AURA) +#include "ui/aura/client/stacking_client.h" +#include "ui/aura/env.h" +#include "ui/aura/root_window.h" +#include "ui/aura/window.h" +#include "ui/gfx/compositor/compositor.h" +#include "ui/gfx/compositor/test/compositor_test_support.h" +#include "ui/views/widget/native_widget_aura.h" +#endif + +#if defined(USE_AURA) +class RootWindowStackingClient : public aura::client::StackingClient { + public: + explicit RootWindowStackingClient() { + aura::client::SetStackingClient(this); + } + + virtual ~RootWindowStackingClient() { + aura::client::SetStackingClient(NULL); + } + + // Overridden from aura::client::StackingClient: + virtual aura::Window* GetDefaultParent(aura::Window* window) OVERRIDE { + return window->GetRootWindow(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(RootWindowStackingClient); +}; +#endif + +int main(int argc, char** argv) { #if defined(OS_WIN) -int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { - sandbox::SandboxInterfaceInfo sandbox_info = {0}; - content::InitializeSandboxInfo(&sandbox_info); - views::examples::ExamplesMainDelegate delegate; - return content::ContentMain(instance, &sandbox_info, &delegate); -} + ui::ScopedOleInitializer ole_initializer; +#endif + CommandLine::Init(argc, argv); + + logging::InitLogging(NULL, + logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, + logging::LOCK_LOG_FILE, + logging::DELETE_OLD_LOG_FILE, + logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); + + base::EnableTerminationOnHeapCorruption(); + + // The exit manager is in charge of calling the dtors of singleton objects. + base::AtExitManager exit_manager; + + ui::RegisterPathProvider(); + bool icu_result = icu_util::Initialize(); + CHECK(icu_result); + ui::ResourceBundle::InitSharedInstanceWithLocale("en-US"); + + MessageLoop main_message_loop(MessageLoop::TYPE_UI); +#if defined(USE_AURA) + + // TURN ON THE HAX. + views::NativeWidgetAura::set_aura_desktop_hax(); + + ui::CompositorTestSupport::Initialize(); + + { + RootWindowStackingClient root_window_stacking_client; +#endif + + views::TestViewsDelegate delegate; + + views::examples::ShowExamplesWindow(views::examples::QUIT_ON_CLOSE); + + // xxx: Hax here because this kills event handling. +#if !defined(USE_AURA) + views::AcceleratorHandler accelerator_handler; + MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); #else -int main(int argc, const char** argv) { - views::examples::ExamplesMainDelegate delegate; - return content::ContentMain(argc, argv, &delegate); + MessageLoopForUI::current()->Run(); +#endif + +#if defined(USE_AURA) + } + aura::Env::DeleteInstance(); + ui::CompositorTestSupport::Terminate(); #endif + + return 0; +} |