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

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

Issue 2462423002: Condition the use of ChromeBrowserMainExtraPartsViewsLinux to !use_ozone (Closed)
Patch Set: same as patchset 6, w/ grouped includes 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
OLDNEW
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/views/chrome_browser_main_extra_parts_views.h" 5 #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h"
6 6
7 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h" 7 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h"
8 #include "chrome/browser/ui/views/chrome_views_delegate.h" 8 #include "chrome/browser/ui/views/chrome_views_delegate.h"
9 #include "components/constrained_window/constrained_window_views.h" 9 #include "components/constrained_window/constrained_window_views.h"
10 10
11 #if defined(USE_AURA) 11 #if defined(USE_AURA)
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/common/service_manager_connection.h" 14 #include "content/public/common/service_manager_connection.h"
15 #include "services/service_manager/public/cpp/connector.h" 15 #include "services/service_manager/public/cpp/connector.h"
16 #include "services/service_manager/runner/common/client_util.h" 16 #include "services/service_manager/runner/common/client_util.h"
17 #include "services/ui/public/cpp/gpu_service.h" 17 #include "services/ui/public/cpp/gpu_service.h"
18 #include "services/ui/public/cpp/input_devices/input_device_client.h" 18 #include "services/ui/public/cpp/input_devices/input_device_client.h"
19 #include "services/ui/public/interfaces/input_devices/input_device_server.mojom. h" 19 #include "services/ui/public/interfaces/input_devices/input_device_server.mojom. h"
20 #include "ui/display/screen.h" 20 #include "ui/display/screen.h"
21 #include "ui/views/mus/window_manager_connection.h" 21 #include "ui/views/mus/window_manager_connection.h"
22 #include "ui/views/widget/desktop_aura/desktop_screen.h" 22 #include "ui/views/widget/desktop_aura/desktop_screen.h"
23 #include "ui/wm/core/wm_state.h" 23 #include "ui/wm/core/wm_state.h"
24 #endif // defined(USE_AURA) 24 #endif // defined(USE_AURA)
25 25
26 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
27 #include "base/command_line.h"
28 #include "chrome/browser/ui/simple_message_box.h"
29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/grit/chromium_strings.h"
31 #include "chrome/grit/generated_resources.h"
32 #include "ui/base/l10n/l10n_util.h"
33 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
34
26 ChromeBrowserMainExtraPartsViews::ChromeBrowserMainExtraPartsViews() { 35 ChromeBrowserMainExtraPartsViews::ChromeBrowserMainExtraPartsViews() {
27 } 36 }
28 37
29 ChromeBrowserMainExtraPartsViews::~ChromeBrowserMainExtraPartsViews() { 38 ChromeBrowserMainExtraPartsViews::~ChromeBrowserMainExtraPartsViews() {
30 constrained_window::SetConstrainedWindowViewsClient(nullptr); 39 constrained_window::SetConstrainedWindowViewsClient(nullptr);
31 } 40 }
32 41
33 void ChromeBrowserMainExtraPartsViews::ToolkitInitialized() { 42 void ChromeBrowserMainExtraPartsViews::ToolkitInitialized() {
34 // The delegate needs to be set before any UI is created so that windows 43 // The delegate needs to be set before any UI is created so that windows
35 // display the correct icon. 44 // display the correct icon.
36 if (!views::ViewsDelegate::GetInstance()) 45 if (!views::ViewsDelegate::GetInstance())
37 views_delegate_.reset(new ChromeViewsDelegate); 46 views_delegate_.reset(new ChromeViewsDelegate);
38 47
39 SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient()); 48 SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient());
40 49
41 #if defined(USE_AURA) 50 #if defined(USE_AURA)
42 wm_state_.reset(new wm::WMState); 51 wm_state_.reset(new wm::WMState);
43 #endif 52 #endif
44 } 53 }
45 54
46 void ChromeBrowserMainExtraPartsViews::PreCreateThreads() { 55 void ChromeBrowserMainExtraPartsViews::PreCreateThreads() {
47 #if defined(USE_AURA) && !defined(OS_CHROMEOS) 56 #if defined(USE_AURA) && !defined(OS_CHROMEOS)
48 // The screen may have already been set in test initialization. 57 // The screen may have already been set in test initialization.
49 if (!display::Screen::GetScreen()) 58 if (!display::Screen::GetScreen())
50 display::Screen::SetScreenInstance(views::CreateDesktopScreen()); 59 display::Screen::SetScreenInstance(views::CreateDesktopScreen());
51 #endif 60 #endif
52 } 61 }
53 62
63 void ChromeBrowserMainExtraPartsViews::PreProfileInit() {
64 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
65 // On the Linux desktop, we want to prevent the user from logging in as root,
66 // so that we don't destroy the profile. Now that we have some minimal ui
67 // initialized, check to see if we're running as root and bail if we are.
68 if (getuid() != 0)
69 return;
70
71 const base::CommandLine& command_line =
72 *base::CommandLine::ForCurrentProcess();
73 if (command_line.HasSwitch(switches::kUserDataDir))
74 return;
75
76 base::string16 title = l10n_util::GetStringFUTF16(
77 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
78 base::string16 message = l10n_util::GetStringFUTF16(
79 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
80
81 chrome::ShowWarningMessageBox(NULL, title, message);
82
83 // Avoids gpu_process_transport_factory.cc(153)] Check failed:
84 // per_compositor_data_.empty() when quit is chosen.
85 base::RunLoop().RunUntilIdle();
86
87 exit(EXIT_FAILURE);
88 #endif
89 }
90
54 void ChromeBrowserMainExtraPartsViews::ServiceManagerConnectionStarted( 91 void ChromeBrowserMainExtraPartsViews::ServiceManagerConnectionStarted(
55 content::ServiceManagerConnection* connection) { 92 content::ServiceManagerConnection* connection) {
56 DCHECK(connection); 93 DCHECK(connection);
57 #if defined(USE_AURA) 94 #if defined(USE_AURA)
58 if (service_manager::ServiceManagerIsRemote()) { 95 if (service_manager::ServiceManagerIsRemote()) {
59 // TODO(rockot): Remove the blocking wait for init. 96 // TODO(rockot): Remove the blocking wait for init.
60 // http://crbug.com/594852. 97 // http://crbug.com/594852.
61 base::RunLoop wait_loop; 98 base::RunLoop wait_loop;
62 connection->SetInitializeHandler(wait_loop.QuitClosure()); 99 connection->SetInitializeHandler(wait_loop.QuitClosure());
63 wait_loop.Run(); 100 wait_loop.Run();
64 101
65 input_device_client_.reset(new ui::InputDeviceClient()); 102 input_device_client_.reset(new ui::InputDeviceClient());
66 ui::mojom::InputDeviceServerPtr server; 103 ui::mojom::InputDeviceServerPtr server;
67 connection->GetConnector()->ConnectToInterface("service:ui", &server); 104 connection->GetConnector()->ConnectToInterface("service:ui", &server);
68 input_device_client_->Connect(std::move(server)); 105 input_device_client_->Connect(std::move(server));
69 106
70 window_manager_connection_ = views::WindowManagerConnection::Create( 107 window_manager_connection_ = views::WindowManagerConnection::Create(
71 connection->GetConnector(), connection->GetIdentity(), 108 connection->GetConnector(), connection->GetIdentity(),
72 content::BrowserThread::GetTaskRunnerForThread( 109 content::BrowserThread::GetTaskRunnerForThread(
73 content::BrowserThread::IO)); 110 content::BrowserThread::IO));
74 } 111 }
75 #endif // defined(USE_AURA) 112 #endif // defined(USE_AURA)
76 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698