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

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

Issue 2108933003: Reorder browser list on workspace switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted ui/display Created 4 years, 5 months 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 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/libgtk2ui/gtk2_ui.h" 14 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h"
14 #include "chrome/browser/ui/simple_message_box.h" 15 #include "chrome/browser/ui/simple_message_box.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "chrome/grit/chromium_strings.h" 19 #include "chrome/grit/chromium_strings.h"
19 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
20 #include "components/prefs/pref_service.h" 21 #include "components/prefs/pref_service.h"
21 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
22 #include "ui/base/ime/input_method_initializer.h" 23 #include "ui/base/ime/input_method_initializer.h"
23 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/ui_base_switches.h" 25 #include "ui/base/ui_base_switches.h"
25 #include "ui/display/display.h" 26 #include "ui/display/display.h"
26 #include "ui/display/screen.h" 27 #include "ui/display/screen.h"
27 #include "ui/native_theme/native_theme_aura.h" 28 #include "ui/native_theme/native_theme_aura.h"
28 #include "ui/native_theme/native_theme_dark_aura.h" 29 #include "ui/native_theme/native_theme_dark_aura.h"
29 #include "ui/views/linux_ui/linux_ui.h" 30 #include "ui/views/linux_ui/linux_ui.h"
30 #include "ui/views/widget/desktop_aura/desktop_screen.h" 31 #include "ui/views/widget/desktop_aura/desktop_screen.h"
32 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
31 #include "ui/views/widget/native_widget_aura.h" 33 #include "ui/views/widget/native_widget_aura.h"
32 34
33 namespace { 35 namespace {
34 36
35 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) { 37 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) {
36 if (!window) 38 if (!window)
37 return nullptr; 39 return nullptr;
38 40
39 Profile* profile = nullptr; 41 Profile* profile = nullptr;
40 // Window types not listed here (such as tooltips) will never use Chrome 42 // Window types not listed here (such as tooltips) will never use Chrome
(...skipping 20 matching lines...) Expand all
61 63
62 return ui::NativeThemeAura::instance(); 64 return ui::NativeThemeAura::instance();
63 } 65 }
64 66
65 } // namespace 67 } // namespace
66 68
67 ChromeBrowserMainExtraPartsViewsLinux::ChromeBrowserMainExtraPartsViewsLinux() { 69 ChromeBrowserMainExtraPartsViewsLinux::ChromeBrowserMainExtraPartsViewsLinux() {
68 } 70 }
69 71
70 ChromeBrowserMainExtraPartsViewsLinux:: 72 ChromeBrowserMainExtraPartsViewsLinux::
71 ~ChromeBrowserMainExtraPartsViewsLinux() {} 73 ~ChromeBrowserMainExtraPartsViewsLinux() {}
Tom (Use chromium acct) 2016/07/06 22:29:16 Do we need views::X11DesktopHandler::get()->AddObs
sky 2016/07/07 03:23:27 I think you mean RemoveObserver. Not sure. You'll
Tom (Use chromium acct) 2016/07/07 19:12:10 Done.
72 74
73 void ChromeBrowserMainExtraPartsViewsLinux::PreEarlyInitialization() { 75 void ChromeBrowserMainExtraPartsViewsLinux::PreEarlyInitialization() {
74 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. 76 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port.
75 views::LinuxUI* gtk2_ui = BuildGtk2UI(); 77 views::LinuxUI* gtk2_ui = BuildGtk2UI();
76 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow)); 78 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow));
77 views::LinuxUI::SetInstance(gtk2_ui); 79 views::LinuxUI::SetInstance(gtk2_ui);
78 } 80 }
79 81
80 void ChromeBrowserMainExtraPartsViewsLinux::ToolkitInitialized() { 82 void ChromeBrowserMainExtraPartsViewsLinux::ToolkitInitialized() {
81 ChromeBrowserMainExtraPartsViews::ToolkitInitialized(); 83 ChromeBrowserMainExtraPartsViews::ToolkitInitialized();
82 views::LinuxUI::instance()->Initialize(); 84 views::LinuxUI::instance()->Initialize();
83 } 85 }
84 86
85 void ChromeBrowserMainExtraPartsViewsLinux::PreCreateThreads() { 87 void ChromeBrowserMainExtraPartsViewsLinux::PreCreateThreads() {
86 ChromeBrowserMainExtraPartsViews::PreCreateThreads(); 88 ChromeBrowserMainExtraPartsViews::PreCreateThreads();
87 // TODO(varkha): The next call should not be necessary once Material Design is 89 // TODO(varkha): The next call should not be necessary once Material Design is
88 // on unconditionally. 90 // on unconditionally.
89 views::LinuxUI::instance()->MaterialDesignControllerReady(); 91 views::LinuxUI::instance()->MaterialDesignControllerReady();
90 views::LinuxUI::instance()->UpdateDeviceScaleFactor( 92 views::LinuxUI::instance()->UpdateDeviceScaleFactor(
91 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 93 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
94
95 views::X11DesktopHandler::get()->AddObserver(this);
92 } 96 }
93 97
94 void ChromeBrowserMainExtraPartsViewsLinux::PreProfileInit() { 98 void ChromeBrowserMainExtraPartsViewsLinux::PreProfileInit() {
95 ChromeBrowserMainExtraPartsViews::PreProfileInit(); 99 ChromeBrowserMainExtraPartsViews::PreProfileInit();
96 // On the Linux desktop, we want to prevent the user from logging in as root, 100 // On the Linux desktop, we want to prevent the user from logging in as root,
97 // so that we don't destroy the profile. Now that we have some minimal ui 101 // so that we don't destroy the profile. Now that we have some minimal ui
98 // initialized, check to see if we're running as root and bail if we are. 102 // initialized, check to see if we're running as root and bail if we are.
99 if (getuid() != 0) 103 if (getuid() != 0)
100 return; 104 return;
101 105
102 const base::CommandLine& command_line = 106 const base::CommandLine& command_line =
103 *base::CommandLine::ForCurrentProcess(); 107 *base::CommandLine::ForCurrentProcess();
104 if (command_line.HasSwitch(switches::kUserDataDir)) 108 if (command_line.HasSwitch(switches::kUserDataDir))
105 return; 109 return;
106 110
107 base::string16 title = l10n_util::GetStringFUTF16( 111 base::string16 title = l10n_util::GetStringFUTF16(
108 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 112 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
109 base::string16 message = l10n_util::GetStringFUTF16( 113 base::string16 message = l10n_util::GetStringFUTF16(
110 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 114 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
111 115
112 chrome::ShowWarningMessageBox(NULL, title, message); 116 chrome::ShowWarningMessageBox(NULL, title, message);
113 117
114 // Avoids gpu_process_transport_factory.cc(153)] Check failed: 118 // Avoids gpu_process_transport_factory.cc(153)] Check failed:
115 // per_compositor_data_.empty() when quit is chosen. 119 // per_compositor_data_.empty() when quit is chosen.
116 base::RunLoop().RunUntilIdle(); 120 base::RunLoop().RunUntilIdle();
117 121
118 exit(EXIT_FAILURE); 122 exit(EXIT_FAILURE);
119 } 123 }
124
125 void ChromeBrowserMainExtraPartsViewsLinux::OnWorkspaceChanged(
126 const std::string& new_workspace) {
127 BrowserList::ReorderAfterWorkspaceChange(new_workspace);
128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698