OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/views/chrome_browser_main_extra_parts_views_linux.h" | 5 #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views_linux.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/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/themes/theme_service.h" | 11 #include "chrome/browser/themes/theme_service.h" |
12 #include "chrome/browser/themes/theme_service_factory.h" | 12 #include "chrome/browser/themes/theme_service_factory.h" |
13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/libgtkui/gtk_ui.h" | |
15 #include "chrome/browser/ui/simple_message_box.h" | 14 #include "chrome/browser/ui/simple_message_box.h" |
16 #include "chrome/browser/ui/views/frame/browser_view.h" | 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
17 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
19 #include "chrome/grit/chromium_strings.h" | 18 #include "chrome/grit/chromium_strings.h" |
20 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
21 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
22 #include "ui/aura/env.h" | 21 #include "ui/aura/env.h" |
23 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
24 #include "ui/base/ime/input_method_initializer.h" | 23 #include "ui/base/ime/input_method_initializer.h" |
25 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/ui_base_switches.h" | 25 #include "ui/base/ui_base_switches.h" |
27 #include "ui/display/display.h" | 26 #include "ui/display/display.h" |
28 #include "ui/display/screen.h" | 27 #include "ui/display/screen.h" |
29 #include "ui/native_theme/native_theme_aura.h" | 28 #include "ui/native_theme/native_theme_aura.h" |
30 #include "ui/native_theme/native_theme_dark_aura.h" | 29 #include "ui/native_theme/native_theme_dark_aura.h" |
31 #include "ui/views/linux_ui/linux_ui.h" | 30 #include "ui/views/linux_ui/linux_ui.h" |
32 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 31 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
32 #include "ui/views/widget/native_widget_aura.h" | |
33 | |
34 #if !defined(USE_OZONE) | |
35 #include "chrome/browser/ui/libgtkui/gtk_ui.h" | |
36 #endif | |
37 | |
38 #if defined(USE_X11) | |
33 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" | 39 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
34 #include "ui/views/widget/native_widget_aura.h" | 40 #endif |
35 | 41 |
36 namespace { | 42 namespace { |
37 | 43 |
38 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) { | 44 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) { |
Lei Zhang
2016/11/01 21:36:25
Is the Ozone build going to complain that this is
| |
39 if (!window) | 45 if (!window) |
40 return nullptr; | 46 return nullptr; |
41 | 47 |
42 Profile* profile = nullptr; | 48 Profile* profile = nullptr; |
43 // Window types not listed here (such as tooltips) will never use Chrome | 49 // Window types not listed here (such as tooltips) will never use Chrome |
44 // theming. | 50 // theming. |
45 if (window->type() == ui::wm::WINDOW_TYPE_NORMAL || | 51 if (window->type() == ui::wm::WINDOW_TYPE_NORMAL || |
46 window->type() == ui::wm::WINDOW_TYPE_POPUP) { | 52 window->type() == ui::wm::WINDOW_TYPE_POPUP) { |
47 profile = reinterpret_cast<Profile*>( | 53 profile = reinterpret_cast<Profile*>( |
48 window->GetNativeWindowProperty(Profile::kProfileKey)); | 54 window->GetNativeWindowProperty(Profile::kProfileKey)); |
(...skipping 16 matching lines...) Expand all Loading... | |
65 return ui::NativeThemeAura::instance(); | 71 return ui::NativeThemeAura::instance(); |
66 } | 72 } |
67 | 73 |
68 } // namespace | 74 } // namespace |
69 | 75 |
70 ChromeBrowserMainExtraPartsViewsLinux::ChromeBrowserMainExtraPartsViewsLinux() { | 76 ChromeBrowserMainExtraPartsViewsLinux::ChromeBrowserMainExtraPartsViewsLinux() { |
71 } | 77 } |
72 | 78 |
73 ChromeBrowserMainExtraPartsViewsLinux:: | 79 ChromeBrowserMainExtraPartsViewsLinux:: |
74 ~ChromeBrowserMainExtraPartsViewsLinux() { | 80 ~ChromeBrowserMainExtraPartsViewsLinux() { |
81 #if defined(USE_X11) | |
75 // X11DesktopHandler is destructed at this point, so we don't need to remove | 82 // X11DesktopHandler is destructed at this point, so we don't need to remove |
76 // ourselves as an X11DesktopHandlerObserver | 83 // ourselves as an X11DesktopHandlerObserver |
77 DCHECK(!aura::Env::GetInstanceDontCreate()); | 84 DCHECK(!aura::Env::GetInstanceDontCreate()); |
85 #endif | |
78 } | 86 } |
79 | 87 |
80 void ChromeBrowserMainExtraPartsViewsLinux::PreEarlyInitialization() { | 88 void ChromeBrowserMainExtraPartsViewsLinux::PreEarlyInitialization() { |
89 #if !defined(USE_OZONE) | |
81 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. | 90 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. |
82 views::LinuxUI* gtk2_ui = BuildGtk2UI(); | 91 views::LinuxUI* gtk2_ui = BuildGtk2UI(); |
83 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow)); | 92 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow)); |
84 views::LinuxUI::SetInstance(gtk2_ui); | 93 views::LinuxUI::SetInstance(gtk2_ui); |
94 #endif | |
85 } | 95 } |
86 | 96 |
87 void ChromeBrowserMainExtraPartsViewsLinux::ToolkitInitialized() { | 97 void ChromeBrowserMainExtraPartsViewsLinux::ToolkitInitialized() { |
88 ChromeBrowserMainExtraPartsViews::ToolkitInitialized(); | 98 ChromeBrowserMainExtraPartsViews::ToolkitInitialized(); |
99 #if !defined(USE_OZONE) | |
89 views::LinuxUI::instance()->Initialize(); | 100 views::LinuxUI::instance()->Initialize(); |
101 #endif | |
90 } | 102 } |
91 | 103 |
92 void ChromeBrowserMainExtraPartsViewsLinux::PreCreateThreads() { | 104 void ChromeBrowserMainExtraPartsViewsLinux::PreCreateThreads() { |
93 ChromeBrowserMainExtraPartsViews::PreCreateThreads(); | 105 ChromeBrowserMainExtraPartsViews::PreCreateThreads(); |
106 #if !defined(USE_OZONE) | |
94 views::LinuxUI::instance()->UpdateDeviceScaleFactor( | 107 views::LinuxUI::instance()->UpdateDeviceScaleFactor( |
95 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 108 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
109 #endif | |
96 | 110 |
111 #if defined(USE_X11) | |
97 views::X11DesktopHandler::get()->AddObserver(this); | 112 views::X11DesktopHandler::get()->AddObserver(this); |
113 #endif | |
98 } | 114 } |
99 | 115 |
100 void ChromeBrowserMainExtraPartsViewsLinux::PreProfileInit() { | 116 void ChromeBrowserMainExtraPartsViewsLinux::PreProfileInit() { |
101 ChromeBrowserMainExtraPartsViews::PreProfileInit(); | 117 ChromeBrowserMainExtraPartsViews::PreProfileInit(); |
102 // On the Linux desktop, we want to prevent the user from logging in as root, | 118 // On the Linux desktop, we want to prevent the user from logging in as root, |
103 // so that we don't destroy the profile. Now that we have some minimal ui | 119 // so that we don't destroy the profile. Now that we have some minimal ui |
104 // initialized, check to see if we're running as root and bail if we are. | 120 // initialized, check to see if we're running as root and bail if we are. |
105 if (getuid() != 0) | 121 if (getuid() != 0) |
106 return; | 122 return; |
107 | 123 |
(...skipping 13 matching lines...) Expand all Loading... | |
121 // per_compositor_data_.empty() when quit is chosen. | 137 // per_compositor_data_.empty() when quit is chosen. |
122 base::RunLoop().RunUntilIdle(); | 138 base::RunLoop().RunUntilIdle(); |
123 | 139 |
124 exit(EXIT_FAILURE); | 140 exit(EXIT_FAILURE); |
125 } | 141 } |
126 | 142 |
127 void ChromeBrowserMainExtraPartsViewsLinux::OnWorkspaceChanged( | 143 void ChromeBrowserMainExtraPartsViewsLinux::OnWorkspaceChanged( |
128 const std::string& new_workspace) { | 144 const std::string& new_workspace) { |
129 BrowserList::MoveBrowsersInWorkspaceToFront(new_workspace); | 145 BrowserList::MoveBrowsersInWorkspaceToFront(new_workspace); |
130 } | 146 } |
OLD | NEW |