Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/ui/views/chrome_browser_main_extra_parts_views_linux.cc

Issue 2462423002: Condition the use of ChromeBrowserMainExtraPartsViewsLinux to !use_ozone (Closed)
Patch Set: addressed thomasanderson@ remarks Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if !defined(USE_OZONE)
14 #include "chrome/browser/ui/libgtkui/gtk_ui.h" 15 #include "chrome/browser/ui/libgtkui/gtk_ui.h"
16 #endif
15 #include "chrome/browser/ui/simple_message_box.h" 17 #include "chrome/browser/ui/simple_message_box.h"
16 #include "chrome/browser/ui/views/frame/browser_view.h" 18 #include "chrome/browser/ui/views/frame/browser_view.h"
17 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
19 #include "chrome/grit/chromium_strings.h" 21 #include "chrome/grit/chromium_strings.h"
20 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
21 #include "components/prefs/pref_service.h" 23 #include "components/prefs/pref_service.h"
22 #include "ui/aura/env.h" 24 #include "ui/aura/env.h"
23 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
24 #include "ui/base/ime/input_method_initializer.h" 26 #include "ui/base/ime/input_method_initializer.h"
25 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/ui_base_switches.h" 28 #include "ui/base/ui_base_switches.h"
27 #include "ui/display/display.h" 29 #include "ui/display/display.h"
28 #include "ui/display/screen.h" 30 #include "ui/display/screen.h"
29 #include "ui/native_theme/native_theme_aura.h" 31 #include "ui/native_theme/native_theme_aura.h"
30 #include "ui/native_theme/native_theme_dark_aura.h" 32 #include "ui/native_theme/native_theme_dark_aura.h"
31 #include "ui/views/linux_ui/linux_ui.h" 33 #include "ui/views/linux_ui/linux_ui.h"
32 #include "ui/views/widget/desktop_aura/desktop_screen.h" 34 #include "ui/views/widget/desktop_aura/desktop_screen.h"
35 #if defined(USE_X11)
Tom (Use chromium acct) 2016/11/01 18:10:07 nit: Please move the gtk_ui.h include and the x11_
tonikitoo 2016/11/01 18:29:54 Done.
33 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" 36 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
37 #endif
34 #include "ui/views/widget/native_widget_aura.h" 38 #include "ui/views/widget/native_widget_aura.h"
35 39
36 namespace { 40 namespace {
37 41
38 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) { 42 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) {
39 if (!window) 43 if (!window)
40 return nullptr; 44 return nullptr;
41 45
42 Profile* profile = nullptr; 46 Profile* profile = nullptr;
43 // Window types not listed here (such as tooltips) will never use Chrome 47 // Window types not listed here (such as tooltips) will never use Chrome
(...skipping 21 matching lines...) Expand all
65 return ui::NativeThemeAura::instance(); 69 return ui::NativeThemeAura::instance();
66 } 70 }
67 71
68 } // namespace 72 } // namespace
69 73
70 ChromeBrowserMainExtraPartsViewsLinux::ChromeBrowserMainExtraPartsViewsLinux() { 74 ChromeBrowserMainExtraPartsViewsLinux::ChromeBrowserMainExtraPartsViewsLinux() {
71 } 75 }
72 76
73 ChromeBrowserMainExtraPartsViewsLinux:: 77 ChromeBrowserMainExtraPartsViewsLinux::
74 ~ChromeBrowserMainExtraPartsViewsLinux() { 78 ~ChromeBrowserMainExtraPartsViewsLinux() {
75 // X11DesktopHandler is destructed at this point, so we don't need to remove 79 // X11DesktopHandler is destructed at this point, so we don't need to remove
Tom (Use chromium acct) 2016/11/01 18:10:07 nit: Surround this comment and DCHECK with #if def
tonikitoo 2016/11/01 18:29:54 Done.
76 // ourselves as an X11DesktopHandlerObserver 80 // ourselves as an X11DesktopHandlerObserver
77 DCHECK(!aura::Env::GetInstanceDontCreate()); 81 DCHECK(!aura::Env::GetInstanceDontCreate());
78 } 82 }
79 83
80 void ChromeBrowserMainExtraPartsViewsLinux::PreEarlyInitialization() { 84 void ChromeBrowserMainExtraPartsViewsLinux::PreEarlyInitialization() {
85 #if !defined(USE_OZONE)
81 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. 86 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port.
82 views::LinuxUI* gtk2_ui = BuildGtk2UI(); 87 views::LinuxUI* gtk2_ui = BuildGtk2UI();
83 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow)); 88 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow));
84 views::LinuxUI::SetInstance(gtk2_ui); 89 views::LinuxUI::SetInstance(gtk2_ui);
90 #endif
85 } 91 }
86 92
87 void ChromeBrowserMainExtraPartsViewsLinux::ToolkitInitialized() { 93 void ChromeBrowserMainExtraPartsViewsLinux::ToolkitInitialized() {
88 ChromeBrowserMainExtraPartsViews::ToolkitInitialized(); 94 ChromeBrowserMainExtraPartsViews::ToolkitInitialized();
95 #if !defined(USE_OZONE)
89 views::LinuxUI::instance()->Initialize(); 96 views::LinuxUI::instance()->Initialize();
97 #endif
90 } 98 }
91 99
92 void ChromeBrowserMainExtraPartsViewsLinux::PreCreateThreads() { 100 void ChromeBrowserMainExtraPartsViewsLinux::PreCreateThreads() {
101 // Intentionally do not call the parent class' PreCreateThreads
Tom (Use chromium acct) 2016/11/01 18:10:06 Add the check for !defined(USE_OZONE) in ChromeBro
tonikitoo 2016/11/01 18:29:54 Done.
102 // here, given that it instantiates DesktopScreen, which is not
103 // used in Ozone.
104 #if !defined(USE_OZONE)
93 ChromeBrowserMainExtraPartsViews::PreCreateThreads(); 105 ChromeBrowserMainExtraPartsViews::PreCreateThreads();
94 views::LinuxUI::instance()->UpdateDeviceScaleFactor( 106 views::LinuxUI::instance()->UpdateDeviceScaleFactor(
95 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 107 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
108 #endif
96 109
110 #if defined(USE_X11)
97 views::X11DesktopHandler::get()->AddObserver(this); 111 views::X11DesktopHandler::get()->AddObserver(this);
112 #endif
98 } 113 }
99 114
100 void ChromeBrowserMainExtraPartsViewsLinux::PreProfileInit() { 115 void ChromeBrowserMainExtraPartsViewsLinux::PreProfileInit() {
101 ChromeBrowserMainExtraPartsViews::PreProfileInit(); 116 ChromeBrowserMainExtraPartsViews::PreProfileInit();
102 // On the Linux desktop, we want to prevent the user from logging in as root, 117 // 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 118 // 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. 119 // initialized, check to see if we're running as root and bail if we are.
105 if (getuid() != 0) 120 if (getuid() != 0)
106 return; 121 return;
107 122
108 const base::CommandLine& command_line = 123 const base::CommandLine& command_line =
109 *base::CommandLine::ForCurrentProcess(); 124 *base::CommandLine::ForCurrentProcess();
110 if (command_line.HasSwitch(switches::kUserDataDir)) 125 if (command_line.HasSwitch(switches::kUserDataDir))
111 return; 126 return;
112 127
113 base::string16 title = l10n_util::GetStringFUTF16( 128 base::string16 title = l10n_util::GetStringFUTF16(
114 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 129 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
115 base::string16 message = l10n_util::GetStringFUTF16( 130 base::string16 message = l10n_util::GetStringFUTF16(
116 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 131 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
117 132
118 chrome::ShowWarningMessageBox(NULL, title, message); 133 chrome::ShowWarningMessageBox(NULL, title, message);
119 134
120 // Avoids gpu_process_transport_factory.cc(153)] Check failed: 135 // Avoids gpu_process_transport_factory.cc(153)] Check failed:
121 // per_compositor_data_.empty() when quit is chosen. 136 // per_compositor_data_.empty() when quit is chosen.
122 base::RunLoop().RunUntilIdle(); 137 base::RunLoop().RunUntilIdle();
123 138
124 exit(EXIT_FAILURE); 139 exit(EXIT_FAILURE);
125 } 140 }
126 141
127 void ChromeBrowserMainExtraPartsViewsLinux::OnWorkspaceChanged( 142 void ChromeBrowserMainExtraPartsViewsLinux::OnWorkspaceChanged(
Tom (Use chromium acct) 2016/11/01 18:10:06 I'm surprised this doesn't need to be surrounded w
tonikitoo 2016/11/01 18:29:54 I believe the reason it "works" is because X11Desk
Tom (Use chromium acct) 2016/11/01 18:38:27 I'll let thestig@ decide this one
Lei Zhang 2016/11/01 21:19:24 Will OnWorkspaceChanged() ever be useful in an Ozo
128 const std::string& new_workspace) { 143 const std::string& new_workspace) {
129 BrowserList::MoveBrowsersInWorkspaceToFront(new_workspace); 144 BrowserList::MoveBrowsersInWorkspaceToFront(new_workspace);
130 } 145 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698