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

Side by Side Diff: chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc

Issue 1412093006: components: Add Exosphere component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on improved shared memory support Created 5 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/ash/chrome_browser_main_extra_parts_ash.h" 5 #include "chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/session/session_state_delegate.h" 8 #include "ash/session/session_state_delegate.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "chrome/browser/chrome_browser_main.h" 12 #include "chrome/browser/chrome_browser_main.h"
13 #include "chrome/browser/ui/ash/ash_init.h" 13 #include "chrome/browser/ui/ash/ash_init.h"
14 #include "chrome/browser/ui/ash/ash_util.h" 14 #include "chrome/browser/ui/ash/ash_util.h"
15 #include "chrome/browser/ui/views/ash/tab_scrubber.h" 15 #include "chrome/browser/ui/views/ash/tab_scrubber.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "components/exo/display.h"
17 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
18 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
19 #include "ui/gfx/screen_type_delegate.h" 20 #include "ui/gfx/screen_type_delegate.h"
20 #include "ui/keyboard/content/keyboard.h" 21 #include "ui/keyboard/content/keyboard.h"
21 #include "ui/keyboard/keyboard_controller.h" 22 #include "ui/keyboard/keyboard_controller.h"
22 23
23 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/ui/views/select_file_dialog_extension.h" 25 #include "chrome/browser/ui/views/select_file_dialog_extension.h"
25 #include "chrome/browser/ui/views/select_file_dialog_extension_factory.h" 26 #include "chrome/browser/ui/views/select_file_dialog_extension_factory.h"
26 #endif 27 #endif
27 28
28 #if !defined(OS_CHROMEOS) 29 #if !defined(OS_CHROMEOS)
29 #include "ui/shell_dialogs/select_file_dialog.h" 30 #include "ui/shell_dialogs/select_file_dialog.h"
30 #include "ui/shell_dialogs/shell_dialogs_delegate.h" 31 #include "ui/shell_dialogs/shell_dialogs_delegate.h"
31 #endif 32 #endif
32 33
33 #if defined(OS_WIN) 34 #if defined(OS_WIN)
34 #include "base/win/windows_version.h" 35 #include "base/win/windows_version.h"
35 #endif 36 #endif
36 37
38 #if defined(OS_LINUX)
39 #include "base/message_loop/message_loop.h"
40 #include "chrome/common/chrome_switches.h"
41 #include "components/exo/wayland/server.h"
42 #include "content/public/browser/browser_thread.h"
43 #endif
44
37 #if !defined(OS_CHROMEOS) 45 #if !defined(OS_CHROMEOS)
38 class ScreenTypeDelegateWin : public gfx::ScreenTypeDelegate { 46 class ScreenTypeDelegateWin : public gfx::ScreenTypeDelegate {
39 public: 47 public:
40 ScreenTypeDelegateWin() {} 48 ScreenTypeDelegateWin() {}
41 gfx::ScreenType GetScreenTypeForNativeView(gfx::NativeView view) override { 49 gfx::ScreenType GetScreenTypeForNativeView(gfx::NativeView view) override {
42 return chrome::IsNativeViewInAsh(view) ? 50 return chrome::IsNativeViewInAsh(view) ?
43 gfx::SCREEN_TYPE_ALTERNATE : 51 gfx::SCREEN_TYPE_ALTERNATE :
44 gfx::SCREEN_TYPE_NATIVE; 52 gfx::SCREEN_TYPE_NATIVE;
45 } 53 }
46 private: 54 private:
(...skipping 11 matching lines...) Expand all
58 return chrome::IsNativeViewInAsh(window); 66 return chrome::IsNativeViewInAsh(window);
59 } 67 }
60 private: 68 private:
61 DISALLOW_COPY_AND_ASSIGN(ShellDialogsDelegateWin); 69 DISALLOW_COPY_AND_ASSIGN(ShellDialogsDelegateWin);
62 }; 70 };
63 71
64 base::LazyInstance<ShellDialogsDelegateWin> g_shell_dialogs_delegate; 72 base::LazyInstance<ShellDialogsDelegateWin> g_shell_dialogs_delegate;
65 73
66 #endif 74 #endif
67 75
76 #if defined(OS_LINUX)
77 class ChromeBrowserMainExtraPartsAsh::WaylandWatcher
78 : public base::MessagePumpLibevent::Watcher {
79 public:
80 explicit WaylandWatcher(exo::wayland::Server* server) : server_(server) {
81 #if defined(USE_OZONE) || (defined(USE_X11) && !defined(USE_GLIB))
82 base::MessageLoopForUI::current()->WatchFileDescriptor(
83 server_->GetFileDescriptor(),
84 true, // persistent
85 base::MessagePumpLibevent::WATCH_READ, &controller_, this);
86 #else
87 NOTIMPLEMENTED();
88 #endif
89 }
90
91 // base::MessagePumpLibevent::Watcher:
92 void OnFileCanReadWithoutBlocking(int fd) override {
93 server_->Dispatch(base::TimeDelta());
94 server_->Flush();
95 }
96 void OnFileCanWriteWithoutBlocking(int fd) override { NOTREACHED(); }
97
98 private:
99 base::MessagePumpLibevent::FileDescriptorWatcher controller_;
100 exo::wayland::Server* const server_;
101
102 DISALLOW_COPY_AND_ASSIGN(WaylandWatcher);
103 };
104 #endif
105
68 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() { 106 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() {
69 } 107 }
70 108
71 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() { 109 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {
72 } 110 }
73 111
74 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { 112 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() {
75 if (chrome::ShouldOpenAshOnStartup()) { 113 if (chrome::ShouldOpenAshOnStartup()) {
76 chrome::OpenAsh(gfx::kNullAcceleratedWidget); 114 chrome::OpenAsh(gfx::kNullAcceleratedWidget);
77 115
78 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 116 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
79 ash::Shell::GetInstance()->CreateShelf(); 117 ash::Shell::GetInstance()->CreateShelf();
80 ash::Shell::GetInstance()->ShowShelf(); 118 ash::Shell::GetInstance()->ShowShelf();
81 #endif 119 #endif
120
121 exo_display_ = make_scoped_ptr(new exo::Display);
122 #if defined(OS_LINUX)
123 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
124 switches::kEnableWaylandServer)) {
125 wayland_server_ = exo::wayland::Server::Create(exo_display_.get());
126 wayland_watcher_ =
127 make_scoped_ptr(new WaylandWatcher(wayland_server_.get()));
128 }
129 #endif
82 } else { 130 } else {
83 #if !defined(OS_CHROMEOS) 131 #if !defined(OS_CHROMEOS)
84 gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateWin); 132 gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateWin);
85 ui::SelectFileDialog::SetShellDialogsDelegate( 133 ui::SelectFileDialog::SetShellDialogsDelegate(
86 g_shell_dialogs_delegate.Pointer()); 134 g_shell_dialogs_delegate.Pointer());
87 #endif 135 #endif
88 } 136 }
89 #if defined(OS_CHROMEOS) 137 #if defined(OS_CHROMEOS)
90 // For OS_CHROMEOS, virtual keyboard needs to be initialized before profile 138 // For OS_CHROMEOS, virtual keyboard needs to be initialized before profile
91 // initialized. Otherwise, virtual keyboard extension will not load at login 139 // initialized. Otherwise, virtual keyboard extension will not load at login
(...skipping 12 matching lines...) Expand all
104 152
105 // Initialize TabScrubber after the Ash Shell has been initialized. 153 // Initialize TabScrubber after the Ash Shell has been initialized.
106 TabScrubber::GetInstance(); 154 TabScrubber::GetInstance();
107 // Activate virtual keyboard after profile is initialized. It depends on the 155 // Activate virtual keyboard after profile is initialized. It depends on the
108 // default profile. 156 // default profile.
109 ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard( 157 ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard(
110 keyboard::KeyboardController::GetInstance()); 158 keyboard::KeyboardController::GetInstance());
111 } 159 }
112 160
113 void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { 161 void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
162 #if defined(OS_LINUX)
163 wayland_server_.reset();
164 #endif
165 exo_display_.reset();
114 chrome::CloseAsh(); 166 chrome::CloseAsh();
115 } 167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698