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

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: removed endl 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"
22 #include "ui/aura/env.h"
21 #include "ui/aura/window.h" 23 #include "ui/aura/window.h"
22 #include "ui/base/ime/input_method_initializer.h" 24 #include "ui/base/ime/input_method_initializer.h"
23 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/ui_base_switches.h" 26 #include "ui/base/ui_base_switches.h"
25 #include "ui/display/display.h" 27 #include "ui/display/display.h"
26 #include "ui/display/screen.h" 28 #include "ui/display/screen.h"
27 #include "ui/native_theme/native_theme_aura.h" 29 #include "ui/native_theme/native_theme_aura.h"
28 #include "ui/native_theme/native_theme_dark_aura.h" 30 #include "ui/native_theme/native_theme_dark_aura.h"
29 #include "ui/views/linux_ui/linux_ui.h" 31 #include "ui/views/linux_ui/linux_ui.h"
30 #include "ui/views/widget/desktop_aura/desktop_screen.h" 32 #include "ui/views/widget/desktop_aura/desktop_screen.h"
33 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
31 #include "ui/views/widget/native_widget_aura.h" 34 #include "ui/views/widget/native_widget_aura.h"
32 35
33 namespace { 36 namespace {
34 37
35 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) { 38 ui::NativeTheme* GetNativeThemeForWindow(aura::Window* window) {
36 if (!window) 39 if (!window)
37 return nullptr; 40 return nullptr;
38 41
39 Profile* profile = nullptr; 42 Profile* profile = nullptr;
40 // Window types not listed here (such as tooltips) will never use Chrome 43 // Window types not listed here (such as tooltips) will never use Chrome
(...skipping 20 matching lines...) Expand all
61 64
62 return ui::NativeThemeAura::instance(); 65 return ui::NativeThemeAura::instance();
63 } 66 }
64 67
65 } // namespace 68 } // namespace
66 69
67 ChromeBrowserMainExtraPartsViewsLinux::ChromeBrowserMainExtraPartsViewsLinux() { 70 ChromeBrowserMainExtraPartsViewsLinux::ChromeBrowserMainExtraPartsViewsLinux() {
68 } 71 }
69 72
70 ChromeBrowserMainExtraPartsViewsLinux:: 73 ChromeBrowserMainExtraPartsViewsLinux::
71 ~ChromeBrowserMainExtraPartsViewsLinux() {} 74 ~ChromeBrowserMainExtraPartsViewsLinux() {
75 // X11DesktopHandler is destructed at this point, so we don't need to remove
76 // ourselves as an X11DesktopHandlerObserver
77 DCHECK(!aura::Env::GetInstanceDontCreate());
78 }
72 79
73 void ChromeBrowserMainExtraPartsViewsLinux::PreEarlyInitialization() { 80 void ChromeBrowserMainExtraPartsViewsLinux::PreEarlyInitialization() {
74 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port. 81 // TODO(erg): Refactor this into a dlopen call when we add a GTK3 port.
75 views::LinuxUI* gtk2_ui = BuildGtk2UI(); 82 views::LinuxUI* gtk2_ui = BuildGtk2UI();
76 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow)); 83 gtk2_ui->SetNativeThemeOverride(base::Bind(&GetNativeThemeForWindow));
77 views::LinuxUI::SetInstance(gtk2_ui); 84 views::LinuxUI::SetInstance(gtk2_ui);
78 } 85 }
79 86
80 void ChromeBrowserMainExtraPartsViewsLinux::ToolkitInitialized() { 87 void ChromeBrowserMainExtraPartsViewsLinux::ToolkitInitialized() {
81 ChromeBrowserMainExtraPartsViews::ToolkitInitialized(); 88 ChromeBrowserMainExtraPartsViews::ToolkitInitialized();
82 views::LinuxUI::instance()->Initialize(); 89 views::LinuxUI::instance()->Initialize();
83 } 90 }
84 91
85 void ChromeBrowserMainExtraPartsViewsLinux::PreCreateThreads() { 92 void ChromeBrowserMainExtraPartsViewsLinux::PreCreateThreads() {
86 ChromeBrowserMainExtraPartsViews::PreCreateThreads(); 93 ChromeBrowserMainExtraPartsViews::PreCreateThreads();
87 // TODO(varkha): The next call should not be necessary once Material Design is 94 // TODO(varkha): The next call should not be necessary once Material Design is
88 // on unconditionally. 95 // on unconditionally.
89 views::LinuxUI::instance()->MaterialDesignControllerReady(); 96 views::LinuxUI::instance()->MaterialDesignControllerReady();
90 views::LinuxUI::instance()->UpdateDeviceScaleFactor( 97 views::LinuxUI::instance()->UpdateDeviceScaleFactor(
91 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 98 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
99
100 views::X11DesktopHandler::get()->AddObserver(this);
92 } 101 }
93 102
94 void ChromeBrowserMainExtraPartsViewsLinux::PreProfileInit() { 103 void ChromeBrowserMainExtraPartsViewsLinux::PreProfileInit() {
95 ChromeBrowserMainExtraPartsViews::PreProfileInit(); 104 ChromeBrowserMainExtraPartsViews::PreProfileInit();
96 // On the Linux desktop, we want to prevent the user from logging in as root, 105 // 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 106 // 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. 107 // initialized, check to see if we're running as root and bail if we are.
99 if (getuid() != 0) 108 if (getuid() != 0)
100 return; 109 return;
101 110
102 const base::CommandLine& command_line = 111 const base::CommandLine& command_line =
103 *base::CommandLine::ForCurrentProcess(); 112 *base::CommandLine::ForCurrentProcess();
104 if (command_line.HasSwitch(switches::kUserDataDir)) 113 if (command_line.HasSwitch(switches::kUserDataDir))
105 return; 114 return;
106 115
107 base::string16 title = l10n_util::GetStringFUTF16( 116 base::string16 title = l10n_util::GetStringFUTF16(
108 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 117 IDS_REFUSE_TO_RUN_AS_ROOT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
109 base::string16 message = l10n_util::GetStringFUTF16( 118 base::string16 message = l10n_util::GetStringFUTF16(
110 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 119 IDS_REFUSE_TO_RUN_AS_ROOT_2, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
111 120
112 chrome::ShowWarningMessageBox(NULL, title, message); 121 chrome::ShowWarningMessageBox(NULL, title, message);
113 122
114 // Avoids gpu_process_transport_factory.cc(153)] Check failed: 123 // Avoids gpu_process_transport_factory.cc(153)] Check failed:
115 // per_compositor_data_.empty() when quit is chosen. 124 // per_compositor_data_.empty() when quit is chosen.
116 base::RunLoop().RunUntilIdle(); 125 base::RunLoop().RunUntilIdle();
117 126
118 exit(EXIT_FAILURE); 127 exit(EXIT_FAILURE);
119 } 128 }
129
130 void ChromeBrowserMainExtraPartsViewsLinux::OnWorkspaceChanged(
131 const std::string& new_workspace) {
132 BrowserList::MoveBrowsersInWorkspaceToFront(new_workspace);
133 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/chrome_browser_main_extra_parts_views_linux.h ('k') | chrome/browser/ui/views/frame/browser_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698