Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / aura / chrome_browser_main_extra_parts_aura.cc
blobad1ec3ff24c0f5570fcf7583d23b2605314e570b
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h"
7 #include "chrome/browser/chrome_browser_main.h"
8 #include "chrome/browser/ui/aura/active_desktop_monitor.h"
9 #include "chrome/browser/ui/host_desktop.h"
10 #include "ui/aura/env.h"
11 #include "ui/gfx/screen.h"
12 #include "ui/views/widget/desktop_aura/desktop_screen.h"
13 #include "ui/views/widget/native_widget_aura.h"
15 #if defined(OS_LINUX)
16 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h"
17 #include "ui/linux_ui/linux_ui.h"
18 #else
19 #endif
21 #if defined(USE_ASH)
22 #include "chrome/browser/ui/ash/ash_init.h"
23 #if defined(OS_WIN)
24 #include "base/command_line.h"
25 #include "chrome/common/chrome_switches.h"
26 #endif // defined(OS_WIN)
27 #endif // defined(USE_ASH)
29 namespace {
31 // Returns the desktop this process was initially launched in.
32 chrome::HostDesktopType GetInitialDesktop() {
33 #if defined(OS_WIN) && defined(USE_ASH)
34 const CommandLine* command_line = CommandLine::ForCurrentProcess();
35 if (command_line->HasSwitch(switches::kViewerConnect) ||
36 command_line->HasSwitch(switches::kViewerLaunchViaAppId)) {
37 return chrome::HOST_DESKTOP_TYPE_ASH;
39 #endif
40 return chrome::HOST_DESKTOP_TYPE_NATIVE;
43 } // namespace
45 ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura() {
48 ChromeBrowserMainExtraPartsAura::~ChromeBrowserMainExtraPartsAura() {
51 void ChromeBrowserMainExtraPartsAura::ToolkitInitialized() {
52 #if !defined(OS_CHROMEOS)
53 #if defined(USE_ASH)
54 active_desktop_monitor_.reset(new ActiveDesktopMonitor(GetInitialDesktop()));
55 if (!chrome::ShouldOpenAshOnStartup())
56 #endif
58 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
59 views::CreateDesktopScreen());
61 #endif
63 #if !defined(USE_ASH) && defined(OS_LINUX) && defined(USE_X11)
64 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port.
65 ui::LinuxUI::SetInstance(BuildGtk2UI());
66 #endif
69 void ChromeBrowserMainExtraPartsAura::PostMainMessageLoopRun() {
70 active_desktop_monitor_.reset();
72 // aura::Env instance is deleted in BrowserProcessImpl::StartTearDown
73 // after the metrics service is deleted.