Chromium Code Reviews| 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 "chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h" | 5 #include "chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/chrome_browser_main.h" | 9 #include "chrome/browser/chrome_browser_main.h" |
| 10 #include "chrome/browser/ui/aura/active_desktop_monitor.h" | 10 #include "chrome/browser/ui/aura/active_desktop_monitor.h" |
| 11 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
| 12 #include "chrome/browser/ui/simple_message_box.h" | 12 #include "chrome/browser/ui/simple_message_box.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "grit/chromium_strings.h" | 14 #include "grit/chromium_strings.h" |
| 15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 16 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
| 19 #include "ui/views/widget/native_widget_aura.h" | 19 #include "ui/views/widget/native_widget_aura.h" |
| 20 | 20 |
| 21 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 21 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 22 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" | 22 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
| 23 #include "ui/base/ime/input_method_initializer.h" | |
| 23 #include "ui/views/linux_ui/linux_ui.h" | 24 #include "ui/views/linux_ui/linux_ui.h" |
| 24 #else | |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 #if defined(USE_ASH) | 27 #if defined(USE_ASH) |
| 28 #include "chrome/browser/ui/ash/ash_init.h" | 28 #include "chrome/browser/ui/ash/ash_init.h" |
| 29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 30 #include "base/command_line.h" | 30 #include "base/command_line.h" |
| 31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 32 #endif // defined(OS_WIN) | 32 #endif // defined(OS_WIN) |
| 33 #endif // defined(USE_ASH) | 33 #endif // defined(USE_ASH) |
| 34 | 34 |
| 35 #if !defined(OS_CHROMEOS) | 35 #if !defined(OS_CHROMEOS) |
| 36 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 36 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 #if !defined(OS_CHROMEOS) && defined(USE_ASH) | 41 #if !defined(OS_CHROMEOS) && defined(USE_ASH) |
| 42 // Returns the desktop this process was initially launched in. | 42 // Returns the desktop this process was initially launched in. |
| 43 chrome::HostDesktopType GetInitialDesktop() { | 43 chrome::HostDesktopType GetInitialDesktop() { |
| 44 #if defined(OS_WIN) && defined(USE_ASH) | 44 #if defined(OS_WIN) && defined(USE_ASH) |
| 45 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 45 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 46 if (command_line->HasSwitch(switches::kViewerConnect) || | 46 if (command_line->HasSwitch(switches::kViewerConnect) || |
| 47 command_line->HasSwitch(switches::kViewerLaunchViaAppId)) { | 47 command_line->HasSwitch(switches::kViewerLaunchViaAppId)) { |
| 48 return chrome::HOST_DESKTOP_TYPE_ASH; | 48 return chrome::HOST_DESKTOP_TYPE_ASH; |
| 49 } | 49 } |
| 50 #elif defined(OS_LINUX) | |
| 51 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 52 if (command_line->HasSwitch(switches::kOpenAsh)) { | |
|
sky
2014/04/24 23:14:32
nit: no {}
| |
| 53 return chrome::HOST_DESKTOP_TYPE_ASH; | |
| 54 } | |
| 50 #endif | 55 #endif |
| 56 | |
| 51 return chrome::HOST_DESKTOP_TYPE_NATIVE; | 57 return chrome::HOST_DESKTOP_TYPE_NATIVE; |
| 52 } | 58 } |
| 53 #endif // !defined(OS_CHROMEOS) && defined(USE_ASH) | 59 #endif // !defined(OS_CHROMEOS) && defined(USE_ASH) |
| 54 | 60 |
| 55 } // namespace | 61 } // namespace |
| 56 | 62 |
| 57 ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura() { | 63 ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura() { |
| 58 } | 64 } |
| 59 | 65 |
| 60 ChromeBrowserMainExtraPartsAura::~ChromeBrowserMainExtraPartsAura() { | 66 ChromeBrowserMainExtraPartsAura::~ChromeBrowserMainExtraPartsAura() { |
| 61 } | 67 } |
| 62 | 68 |
| 63 void ChromeBrowserMainExtraPartsAura::PreEarlyInitialization() { | 69 void ChromeBrowserMainExtraPartsAura::PreEarlyInitialization() { |
| 64 #if !defined(USE_ASH) && defined(OS_LINUX) && defined(USE_X11) | 70 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 65 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. | 71 if (GetInitialDesktop() != chrome::HOST_DESKTOP_TYPE_ASH) { |
| 66 views::LinuxUI::SetInstance(BuildGtk2UI()); | 72 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. |
| 73 views::LinuxUI::SetInstance(BuildGtk2UI()); | |
| 74 } else { | |
| 75 ui::InitializeInputMethodForTesting(); | |
| 76 } | |
| 67 #endif | 77 #endif |
| 68 } | 78 } |
| 69 | 79 |
| 70 void ChromeBrowserMainExtraPartsAura::ToolkitInitialized() { | 80 void ChromeBrowserMainExtraPartsAura::ToolkitInitialized() { |
| 71 #if !defined(OS_CHROMEOS) | 81 #if !defined(OS_CHROMEOS) |
| 72 #if defined(USE_ASH) | 82 #if defined(USE_ASH) |
| 73 CHECK(aura::Env::GetInstance()); | 83 CHECK(aura::Env::GetInstance()); |
| 74 active_desktop_monitor_.reset(new ActiveDesktopMonitor(GetInitialDesktop())); | 84 active_desktop_monitor_.reset(new ActiveDesktopMonitor(GetInitialDesktop())); |
| 75 #endif | 85 #endif |
| 76 #endif | 86 #endif |
| 77 | 87 |
| 78 #if !defined(USE_ASH) && defined(OS_LINUX) && defined(USE_X11) | 88 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 79 views::LinuxUI::instance()->Initialize(); | 89 if (GetInitialDesktop() != chrome::HOST_DESKTOP_TYPE_ASH) |
| 90 views::LinuxUI::instance()->Initialize(); | |
| 80 #endif | 91 #endif |
| 81 } | 92 } |
| 82 | 93 |
| 83 void ChromeBrowserMainExtraPartsAura::PreCreateThreads() { | 94 void ChromeBrowserMainExtraPartsAura::PreCreateThreads() { |
| 84 #if !defined(OS_CHROMEOS) | 95 #if !defined(OS_CHROMEOS) |
| 85 #if defined(USE_ASH) | 96 #if defined(USE_ASH) |
| 86 if (!chrome::ShouldOpenAshOnStartup()) | 97 if (!chrome::ShouldOpenAshOnStartup()) |
| 87 #endif | 98 #endif |
| 88 { | 99 { |
| 89 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, | 100 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 chrome::MESSAGE_BOX_TYPE_WARNING); | 138 chrome::MESSAGE_BOX_TYPE_WARNING); |
| 128 | 139 |
| 129 // Avoids gpu_process_transport_factory.cc(153)] Check failed: | 140 // Avoids gpu_process_transport_factory.cc(153)] Check failed: |
| 130 // per_compositor_data_.empty() when quit is chosen. | 141 // per_compositor_data_.empty() when quit is chosen. |
| 131 base::RunLoop().RunUntilIdle(); | 142 base::RunLoop().RunUntilIdle(); |
| 132 | 143 |
| 133 exit(EXIT_FAILURE); | 144 exit(EXIT_FAILURE); |
| 134 } | 145 } |
| 135 } | 146 } |
| 136 #endif | 147 #endif |
| OLD | NEW |