| 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 "base/prefs/pref_service.h" |
| 23 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" | 24 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
| 25 #include "chrome/common/pref_names.h" |
| 26 #include "ui/aura/window.h" |
| 27 #include "ui/native_theme/native_theme_aura.h" |
| 23 #include "ui/views/linux_ui/linux_ui.h" | 28 #include "ui/views/linux_ui/linux_ui.h" |
| 24 #else | |
| 25 #endif | 29 #endif |
| 26 | 30 |
| 27 #if defined(USE_ASH) | 31 #if defined(USE_ASH) |
| 28 #include "chrome/browser/ui/ash/ash_init.h" | 32 #include "chrome/browser/ui/ash/ash_init.h" |
| 29 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
| 30 #include "base/command_line.h" | 34 #include "base/command_line.h" |
| 31 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
| 32 #endif // defined(OS_WIN) | 36 #endif // defined(OS_WIN) |
| 33 #endif // defined(USE_ASH) | 37 #endif // defined(USE_ASH) |
| 34 | 38 |
| 35 #if !defined(OS_CHROMEOS) | 39 #if !defined(OS_CHROMEOS) |
| 36 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 40 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
| 37 #endif | 41 #endif |
| 38 | 42 |
| 39 namespace { | 43 namespace { |
| 40 | 44 |
| 45 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 46 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) { |
| 47 Profile* profile = NULL; |
| 48 if (window->type() == ui::wm::WINDOW_TYPE_NORMAL || |
| 49 window->type() == ui::wm::WINDOW_TYPE_POPUP) { |
| 50 profile = reinterpret_cast<Profile*>( |
| 51 window->GetNativeWindowProperty(Profile::kProfileKey)); |
| 52 } |
| 53 |
| 54 if (profile && !profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme)) |
| 55 return ui::NativeThemeAura::instance(); |
| 56 |
| 57 return NULL; |
| 58 } |
| 59 #endif |
| 60 |
| 41 #if !defined(OS_CHROMEOS) && defined(USE_ASH) | 61 #if !defined(OS_CHROMEOS) && defined(USE_ASH) |
| 42 // Returns the desktop this process was initially launched in. | 62 // Returns the desktop this process was initially launched in. |
| 43 chrome::HostDesktopType GetInitialDesktop() { | 63 chrome::HostDesktopType GetInitialDesktop() { |
| 44 #if defined(OS_WIN) && defined(USE_ASH) | 64 #if defined(OS_WIN) && defined(USE_ASH) |
| 45 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 65 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 46 if (command_line->HasSwitch(switches::kViewerConnect) || | 66 if (command_line->HasSwitch(switches::kViewerConnect) || |
| 47 command_line->HasSwitch(switches::kViewerLaunchViaAppId)) { | 67 command_line->HasSwitch(switches::kViewerLaunchViaAppId)) { |
| 48 return chrome::HOST_DESKTOP_TYPE_ASH; | 68 return chrome::HOST_DESKTOP_TYPE_ASH; |
| 49 } | 69 } |
| 50 #endif | 70 #endif |
| 51 return chrome::HOST_DESKTOP_TYPE_NATIVE; | 71 return chrome::HOST_DESKTOP_TYPE_NATIVE; |
| 52 } | 72 } |
| 53 #endif // !defined(OS_CHROMEOS) && defined(USE_ASH) | 73 #endif // !defined(OS_CHROMEOS) && defined(USE_ASH) |
| 54 | 74 |
| 55 } // namespace | 75 } // namespace |
| 56 | 76 |
| 57 ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura() { | 77 ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura() { |
| 58 } | 78 } |
| 59 | 79 |
| 60 ChromeBrowserMainExtraPartsAura::~ChromeBrowserMainExtraPartsAura() { | 80 ChromeBrowserMainExtraPartsAura::~ChromeBrowserMainExtraPartsAura() { |
| 61 } | 81 } |
| 62 | 82 |
| 63 void ChromeBrowserMainExtraPartsAura::PreEarlyInitialization() { | 83 void ChromeBrowserMainExtraPartsAura::PreEarlyInitialization() { |
| 64 #if !defined(USE_ASH) && defined(OS_LINUX) && defined(USE_X11) | 84 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 65 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. | 85 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. |
| 66 views::LinuxUI::SetInstance(BuildGtk2UI()); | 86 views::LinuxUI* gtk2_ui = BuildGtk2UI(); |
| 87 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow)); |
| 88 views::LinuxUI::SetInstance(gtk2_ui); |
| 67 #endif | 89 #endif |
| 68 } | 90 } |
| 69 | 91 |
| 70 void ChromeBrowserMainExtraPartsAura::ToolkitInitialized() { | 92 void ChromeBrowserMainExtraPartsAura::ToolkitInitialized() { |
| 71 #if !defined(OS_CHROMEOS) | 93 #if !defined(OS_CHROMEOS) |
| 72 #if defined(USE_ASH) | 94 #if defined(USE_ASH) |
| 73 aura::Env::CreateInstance(); | 95 aura::Env::CreateInstance(); |
| 74 active_desktop_monitor_.reset(new ActiveDesktopMonitor(GetInitialDesktop())); | 96 active_desktop_monitor_.reset(new ActiveDesktopMonitor(GetInitialDesktop())); |
| 75 #endif | 97 #endif |
| 76 #endif | 98 #endif |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 chrome::MESSAGE_BOX_TYPE_WARNING); | 149 chrome::MESSAGE_BOX_TYPE_WARNING); |
| 128 | 150 |
| 129 // Avoids gpu_process_transport_factory.cc(153)] Check failed: | 151 // Avoids gpu_process_transport_factory.cc(153)] Check failed: |
| 130 // per_compositor_data_.empty() when quit is chosen. | 152 // per_compositor_data_.empty() when quit is chosen. |
| 131 base::RunLoop().RunUntilIdle(); | 153 base::RunLoop().RunUntilIdle(); |
| 132 | 154 |
| 133 exit(EXIT_FAILURE); | 155 exit(EXIT_FAILURE); |
| 134 } | 156 } |
| 135 } | 157 } |
| 136 #endif | 158 #endif |
| OLD | NEW |