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/libgtk2ui/gtk2_ui.h" | 13 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
14 #include "chrome/browser/ui/simple_message_box.h" | 14 #include "chrome/browser/ui/simple_message_box.h" |
15 #include "chrome/browser/ui/views/frame/browser_view.h" | 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "chrome/grit/chromium_strings.h" | 18 #include "chrome/grit/chromium_strings.h" |
19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
20 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
22 #include "ui/base/ime/input_method_initializer.h" | 22 #include "ui/base/ime/input_method_initializer.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/ui_base_switches.h" | 24 #include "ui/base/ui_base_switches.h" |
25 #include "ui/gfx/screen.h" | 25 #include "ui/display/screen.h" |
26 #include "ui/native_theme/native_theme_aura.h" | 26 #include "ui/native_theme/native_theme_aura.h" |
27 #include "ui/native_theme/native_theme_dark_aura.h" | 27 #include "ui/native_theme/native_theme_dark_aura.h" |
28 #include "ui/views/linux_ui/linux_ui.h" | 28 #include "ui/views/linux_ui/linux_ui.h" |
29 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 29 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
30 #include "ui/views/widget/native_widget_aura.h" | 30 #include "ui/views/widget/native_widget_aura.h" |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) { | 34 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) { |
35 if (!window) | 35 if (!window) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 ChromeBrowserMainExtraPartsViews::ToolkitInitialized(); | 80 ChromeBrowserMainExtraPartsViews::ToolkitInitialized(); |
81 views::LinuxUI::instance()->Initialize(); | 81 views::LinuxUI::instance()->Initialize(); |
82 } | 82 } |
83 | 83 |
84 void ChromeBrowserMainExtraPartsViewsLinux::PreCreateThreads() { | 84 void ChromeBrowserMainExtraPartsViewsLinux::PreCreateThreads() { |
85 ChromeBrowserMainExtraPartsViews::PreCreateThreads(); | 85 ChromeBrowserMainExtraPartsViews::PreCreateThreads(); |
86 // TODO(varkha): The next call should not be necessary once Material Design is | 86 // TODO(varkha): The next call should not be necessary once Material Design is |
87 // on unconditionally. | 87 // on unconditionally. |
88 views::LinuxUI::instance()->MaterialDesignControllerReady(); | 88 views::LinuxUI::instance()->MaterialDesignControllerReady(); |
89 views::LinuxUI::instance()->UpdateDeviceScaleFactor( | 89 views::LinuxUI::instance()->UpdateDeviceScaleFactor( |
90 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 90 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
91 } | 91 } |
92 | 92 |
93 void ChromeBrowserMainExtraPartsViewsLinux::PreProfileInit() { | 93 void ChromeBrowserMainExtraPartsViewsLinux::PreProfileInit() { |
94 // On the Linux desktop, we want to prevent the user from logging in as root, | 94 // On the Linux desktop, we want to prevent the user from logging in as root, |
95 // so that we don't destroy the profile. Now that we have some minimal ui | 95 // so that we don't destroy the profile. Now that we have some minimal ui |
96 // initialized, check to see if we're running as root and bail if we are. | 96 // initialized, check to see if we're running as root and bail if we are. |
97 if (getuid() != 0) | 97 if (getuid() != 0) |
98 return; | 98 return; |
99 | 99 |
100 const base::CommandLine& command_line = | 100 const base::CommandLine& command_line = |
101 *base::CommandLine::ForCurrentProcess(); | 101 *base::CommandLine::ForCurrentProcess(); |
102 if (command_line.HasSwitch(switches::kUserDataDir)) | 102 if (command_line.HasSwitch(switches::kUserDataDir)) |
103 return; | 103 return; |
104 | 104 |
105 base::string16 title = l10n_util::GetStringFUTF16( | 105 base::string16 title = l10n_util::GetStringFUTF16( |
106 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 106 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
107 base::string16 message = l10n_util::GetStringFUTF16( | 107 base::string16 message = l10n_util::GetStringFUTF16( |
108 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 108 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
109 | 109 |
110 chrome::ShowWarningMessageBox(NULL, title, message); | 110 chrome::ShowWarningMessageBox(NULL, title, message); |
111 | 111 |
112 // Avoids gpu_process_transport_factory.cc(153)] Check failed: | 112 // Avoids gpu_process_transport_factory.cc(153)] Check failed: |
113 // per_compositor_data_.empty() when quit is chosen. | 113 // per_compositor_data_.empty() when quit is chosen. |
114 base::RunLoop().RunUntilIdle(); | 114 base::RunLoop().RunUntilIdle(); |
115 | 115 |
116 exit(EXIT_FAILURE); | 116 exit(EXIT_FAILURE); |
117 } | 117 } |
OLD | NEW |