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(USE_X11) && !defined(OS_CHROMEOS) | 21 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
22 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" | 24 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
26 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
| 27 #include "ui/base/ime/input_method_initializer.h" |
27 #include "ui/native_theme/native_theme_aura.h" | 28 #include "ui/native_theme/native_theme_aura.h" |
28 #include "ui/views/linux_ui/linux_ui.h" | 29 #include "ui/views/linux_ui/linux_ui.h" |
29 #endif | 30 #endif |
30 | 31 |
31 #if defined(USE_ASH) | 32 #if defined(USE_ASH) |
32 #include "chrome/browser/ui/ash/ash_init.h" | 33 #include "chrome/browser/ui/ash/ash_init.h" |
33 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
34 #include "base/command_line.h" | 35 #include "base/command_line.h" |
35 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
36 #endif // defined(OS_WIN) | 37 #endif // defined(OS_WIN) |
(...skipping 26 matching lines...) Expand all Loading... |
63 | 64 |
64 #if !defined(OS_CHROMEOS) && defined(USE_ASH) | 65 #if !defined(OS_CHROMEOS) && defined(USE_ASH) |
65 // Returns the desktop this process was initially launched in. | 66 // Returns the desktop this process was initially launched in. |
66 chrome::HostDesktopType GetInitialDesktop() { | 67 chrome::HostDesktopType GetInitialDesktop() { |
67 #if defined(OS_WIN) && defined(USE_ASH) | 68 #if defined(OS_WIN) && defined(USE_ASH) |
68 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 69 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
69 if (command_line->HasSwitch(switches::kViewerConnect) || | 70 if (command_line->HasSwitch(switches::kViewerConnect) || |
70 command_line->HasSwitch(switches::kViewerLaunchViaAppId)) { | 71 command_line->HasSwitch(switches::kViewerLaunchViaAppId)) { |
71 return chrome::HOST_DESKTOP_TYPE_ASH; | 72 return chrome::HOST_DESKTOP_TYPE_ASH; |
72 } | 73 } |
| 74 #elif defined(OS_LINUX) |
| 75 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 76 if (command_line->HasSwitch(switches::kOpenAsh)) |
| 77 return chrome::HOST_DESKTOP_TYPE_ASH; |
73 #endif | 78 #endif |
| 79 |
74 return chrome::HOST_DESKTOP_TYPE_NATIVE; | 80 return chrome::HOST_DESKTOP_TYPE_NATIVE; |
75 } | 81 } |
76 #endif // !defined(OS_CHROMEOS) && defined(USE_ASH) | 82 #endif // !defined(OS_CHROMEOS) && defined(USE_ASH) |
77 | 83 |
78 } // namespace | 84 } // namespace |
79 | 85 |
80 ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura() { | 86 ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura() { |
81 } | 87 } |
82 | 88 |
83 ChromeBrowserMainExtraPartsAura::~ChromeBrowserMainExtraPartsAura() { | 89 ChromeBrowserMainExtraPartsAura::~ChromeBrowserMainExtraPartsAura() { |
84 } | 90 } |
85 | 91 |
86 void ChromeBrowserMainExtraPartsAura::PreEarlyInitialization() { | 92 void ChromeBrowserMainExtraPartsAura::PreEarlyInitialization() { |
87 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 93 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
88 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. | 94 if (GetInitialDesktop() != chrome::HOST_DESKTOP_TYPE_ASH) { |
89 views::LinuxUI* gtk2_ui = BuildGtk2UI(); | 95 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. |
90 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow)); | 96 views::LinuxUI* gtk2_ui = BuildGtk2UI(); |
91 views::LinuxUI::SetInstance(gtk2_ui); | 97 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow)); |
| 98 views::LinuxUI::SetInstance(gtk2_ui); |
| 99 } else { |
| 100 // TODO(erg): Eventually, we'll need to somehow support IMEs in ash on |
| 101 // Linux. |
| 102 ui::InitializeInputMethodForTesting(); |
| 103 } |
92 #endif | 104 #endif |
93 } | 105 } |
94 | 106 |
95 void ChromeBrowserMainExtraPartsAura::ToolkitInitialized() { | 107 void ChromeBrowserMainExtraPartsAura::ToolkitInitialized() { |
96 #if !defined(OS_CHROMEOS) | 108 #if !defined(OS_CHROMEOS) |
97 #if defined(USE_ASH) | 109 #if defined(USE_ASH) |
98 CHECK(aura::Env::GetInstance()); | 110 CHECK(aura::Env::GetInstance()); |
99 active_desktop_monitor_.reset(new ActiveDesktopMonitor(GetInitialDesktop())); | 111 active_desktop_monitor_.reset(new ActiveDesktopMonitor(GetInitialDesktop())); |
100 #endif | 112 #endif |
101 #endif | 113 #endif |
102 | 114 |
103 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 115 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
104 views::LinuxUI::instance()->Initialize(); | 116 if (GetInitialDesktop() != chrome::HOST_DESKTOP_TYPE_ASH) |
| 117 views::LinuxUI::instance()->Initialize(); |
105 #endif | 118 #endif |
106 } | 119 } |
107 | 120 |
108 void ChromeBrowserMainExtraPartsAura::PreCreateThreads() { | 121 void ChromeBrowserMainExtraPartsAura::PreCreateThreads() { |
109 #if !defined(OS_CHROMEOS) | 122 #if !defined(OS_CHROMEOS) |
110 #if defined(USE_ASH) | 123 #if defined(USE_ASH) |
111 if (!chrome::ShouldOpenAshOnStartup()) | 124 if (!chrome::ShouldOpenAshOnStartup()) |
112 #endif | 125 #endif |
113 { | 126 { |
114 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, | 127 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 chrome::MESSAGE_BOX_TYPE_WARNING); | 165 chrome::MESSAGE_BOX_TYPE_WARNING); |
153 | 166 |
154 // Avoids gpu_process_transport_factory.cc(153)] Check failed: | 167 // Avoids gpu_process_transport_factory.cc(153)] Check failed: |
155 // per_compositor_data_.empty() when quit is chosen. | 168 // per_compositor_data_.empty() when quit is chosen. |
156 base::RunLoop().RunUntilIdle(); | 169 base::RunLoop().RunUntilIdle(); |
157 | 170 |
158 exit(EXIT_FAILURE); | 171 exit(EXIT_FAILURE); |
159 } | 172 } |
160 } | 173 } |
161 #endif | 174 #endif |
OLD | NEW |