OLD | NEW |
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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #if !defined(OS_CHROMEOS) | 28 #if !defined(OS_CHROMEOS) |
29 #include "ui/shell_dialogs/select_file_dialog.h" | 29 #include "ui/shell_dialogs/select_file_dialog.h" |
30 #include "ui/shell_dialogs/shell_dialogs_delegate.h" | 30 #include "ui/shell_dialogs/shell_dialogs_delegate.h" |
31 #endif | 31 #endif |
32 | 32 |
33 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
34 #include "base/win/windows_version.h" | 34 #include "base/win/windows_version.h" |
35 #endif | 35 #endif |
36 | 36 |
| 37 #if defined(ENABLE_WAYLAND_SERVER) |
| 38 #include "base/message_loop/message_loop.h" |
| 39 #include "chrome/common/chrome_switches.h" |
| 40 #include "components/exo/display.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 Loading... |
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(ENABLE_WAYLAND_SERVER) |
| 77 class ChromeBrowserMainExtraPartsAsh::WaylandWatcher |
| 78 : public base::MessagePumpLibevent::Watcher { |
| 79 public: |
| 80 explicit WaylandWatcher(exo::wayland::Server* server) : server_(server) { |
| 81 base::MessageLoopForUI::current()->WatchFileDescriptor( |
| 82 server_->GetFileDescriptor(), |
| 83 true, // persistent |
| 84 base::MessagePumpLibevent::WATCH_READ, &controller_, this); |
| 85 } |
| 86 |
| 87 // base::MessagePumpLibevent::Watcher: |
| 88 void OnFileCanReadWithoutBlocking(int fd) override { |
| 89 server_->Dispatch(base::TimeDelta()); |
| 90 server_->Flush(); |
| 91 } |
| 92 void OnFileCanWriteWithoutBlocking(int fd) override { NOTREACHED(); } |
| 93 |
| 94 private: |
| 95 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
| 96 exo::wayland::Server* const server_; |
| 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(WaylandWatcher); |
| 99 }; |
| 100 #endif |
| 101 |
68 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() { | 102 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() { |
69 } | 103 } |
70 | 104 |
71 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() { | 105 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() { |
72 } | 106 } |
73 | 107 |
74 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { | 108 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { |
75 if (chrome::ShouldOpenAshOnStartup()) { | 109 if (chrome::ShouldOpenAshOnStartup()) { |
76 chrome::OpenAsh(gfx::kNullAcceleratedWidget); | 110 chrome::OpenAsh(gfx::kNullAcceleratedWidget); |
77 | 111 |
78 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 112 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
79 ash::Shell::GetInstance()->CreateShelf(); | 113 ash::Shell::GetInstance()->CreateShelf(); |
80 ash::Shell::GetInstance()->ShowShelf(); | 114 ash::Shell::GetInstance()->ShowShelf(); |
81 #endif | 115 #endif |
| 116 |
| 117 #if defined(ENABLE_WAYLAND_SERVER) |
| 118 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 119 switches::kEnableWaylandServer)) { |
| 120 exo_display_ = make_scoped_ptr(new exo::Display); |
| 121 wayland_server_ = exo::wayland::Server::Create(exo_display_.get()); |
| 122 wayland_watcher_ = |
| 123 make_scoped_ptr(new WaylandWatcher(wayland_server_.get())); |
| 124 } |
| 125 #endif |
82 } else { | 126 } else { |
83 #if !defined(OS_CHROMEOS) | 127 #if !defined(OS_CHROMEOS) |
84 gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateWin); | 128 gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateWin); |
85 ui::SelectFileDialog::SetShellDialogsDelegate( | 129 ui::SelectFileDialog::SetShellDialogsDelegate( |
86 g_shell_dialogs_delegate.Pointer()); | 130 g_shell_dialogs_delegate.Pointer()); |
87 #endif | 131 #endif |
88 } | 132 } |
89 #if defined(OS_CHROMEOS) | 133 #if defined(OS_CHROMEOS) |
90 // For OS_CHROMEOS, virtual keyboard needs to be initialized before profile | 134 // For OS_CHROMEOS, virtual keyboard needs to be initialized before profile |
91 // initialized. Otherwise, virtual keyboard extension will not load at login | 135 // initialized. Otherwise, virtual keyboard extension will not load at login |
(...skipping 12 matching lines...) Expand all Loading... |
104 | 148 |
105 // Initialize TabScrubber after the Ash Shell has been initialized. | 149 // Initialize TabScrubber after the Ash Shell has been initialized. |
106 TabScrubber::GetInstance(); | 150 TabScrubber::GetInstance(); |
107 // Activate virtual keyboard after profile is initialized. It depends on the | 151 // Activate virtual keyboard after profile is initialized. It depends on the |
108 // default profile. | 152 // default profile. |
109 ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | 153 ash::Shell::GetPrimaryRootWindowController()->ActivateKeyboard( |
110 keyboard::KeyboardController::GetInstance()); | 154 keyboard::KeyboardController::GetInstance()); |
111 } | 155 } |
112 | 156 |
113 void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { | 157 void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { |
| 158 #if defined(ENABLE_WAYLAND_SERVER) |
| 159 wayland_server_.reset(); |
| 160 exo_display_.reset(); |
| 161 #endif |
114 chrome::CloseAsh(); | 162 chrome::CloseAsh(); |
115 } | 163 } |
OLD | NEW |