OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/renderer/mus/renderer_window_tree_client.h" |
| 6 |
| 7 #include <map> |
| 8 |
| 9 #include "base/lazy_instance.h" |
| 10 #include "services/ui/public/cpp/window_compositor_frame_sink.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 namespace { |
| 15 typedef std::map<int, RendererWindowTreeClient*> ConnectionMap; |
| 16 base::LazyInstance<ConnectionMap>::Leaky g_connections = |
| 17 LAZY_INSTANCE_INITIALIZER; |
| 18 } // namespace |
| 19 |
| 20 // static |
| 21 RendererWindowTreeClient* RendererWindowTreeClient::Get(int routing_id) { |
| 22 auto it = g_connections.Get().find(routing_id); |
| 23 if (it != g_connections.Get().end()) |
| 24 return it->second; |
| 25 return nullptr; |
| 26 } |
| 27 |
| 28 // static |
| 29 void RendererWindowTreeClient::Create(int routing_id) { |
| 30 DCHECK(g_connections.Get().find(routing_id) == g_connections.Get().end()); |
| 31 RendererWindowTreeClient* connection = |
| 32 new RendererWindowTreeClient(routing_id); |
| 33 g_connections.Get().insert(std::make_pair(routing_id, connection)); |
| 34 } |
| 35 |
| 36 RendererWindowTreeClient::RendererWindowTreeClient(int routing_id) |
| 37 : routing_id_(routing_id), binding_(this) {} |
| 38 |
| 39 RendererWindowTreeClient::~RendererWindowTreeClient() { |
| 40 g_connections.Get().erase(routing_id_); |
| 41 } |
| 42 |
| 43 void RendererWindowTreeClient::Bind( |
| 44 ui::mojom::WindowTreeClientRequest request) { |
| 45 binding_.Bind(std::move(request)); |
| 46 } |
| 47 |
| 48 std::unique_ptr<cc::CompositorFrameSink> |
| 49 RendererWindowTreeClient::CreateCompositorFrameSink( |
| 50 const cc::FrameSinkId& frame_sink_id, |
| 51 scoped_refptr<cc::ContextProvider> context_provider, |
| 52 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { |
| 53 std::unique_ptr<ui::WindowCompositorFrameSinkBinding> frame_sink_binding; |
| 54 auto frame_sink = ui::WindowCompositorFrameSink::Create( |
| 55 frame_sink_id, std::move(context_provider), gpu_memory_buffer_manager, |
| 56 &frame_sink_binding); |
| 57 if (tree_) { |
| 58 tree_->AttachCompositorFrameSink( |
| 59 root_window_id_, frame_sink_binding->TakeFrameSinkRequest(), |
| 60 mojo::MakeProxy(frame_sink_binding->TakeFrameSinkClient())); |
| 61 } else { |
| 62 pending_frame_sink_ = std::move(frame_sink_binding); |
| 63 } |
| 64 return std::move(frame_sink); |
| 65 } |
| 66 |
| 67 void RendererWindowTreeClient::DestroySelf() { |
| 68 delete this; |
| 69 } |
| 70 |
| 71 void RendererWindowTreeClient::OnEmbed(ui::ClientSpecificId client_id, |
| 72 ui::mojom::WindowDataPtr root, |
| 73 ui::mojom::WindowTreePtr tree, |
| 74 int64_t display_id, |
| 75 ui::Id focused_window_id, |
| 76 bool drawn) { |
| 77 root_window_id_ = root->window_id; |
| 78 tree_ = std::move(tree); |
| 79 if (pending_frame_sink_) { |
| 80 tree_->AttachCompositorFrameSink( |
| 81 root_window_id_, pending_frame_sink_->TakeFrameSinkRequest(), |
| 82 mojo::MakeProxy(pending_frame_sink_->TakeFrameSinkClient())); |
| 83 pending_frame_sink_ = nullptr; |
| 84 } |
| 85 } |
| 86 |
| 87 void RendererWindowTreeClient::OnEmbeddedAppDisconnected(ui::Id window_id) { |
| 88 // TODO(sad): Embedded mus-client (oopif) is gone. Figure out what to do. |
| 89 } |
| 90 |
| 91 void RendererWindowTreeClient::OnUnembed(ui::Id window_id) { |
| 92 CHECK_EQ(window_id, root_window_id_); |
| 93 DestroySelf(); |
| 94 } |
| 95 |
| 96 void RendererWindowTreeClient::OnCaptureChanged(ui::Id new_capture_window_id, |
| 97 ui::Id old_capture_window_id) {} |
| 98 |
| 99 void RendererWindowTreeClient::OnTopLevelCreated(uint32_t change_id, |
| 100 ui::mojom::WindowDataPtr data, |
| 101 int64_t display_id, |
| 102 bool drawn) { |
| 103 NOTREACHED(); |
| 104 } |
| 105 |
| 106 void RendererWindowTreeClient::OnWindowBoundsChanged( |
| 107 ui::Id window_id, |
| 108 const gfx::Rect& old_bounds, |
| 109 const gfx::Rect& new_bounds) {} |
| 110 |
| 111 void RendererWindowTreeClient::OnClientAreaChanged( |
| 112 uint32_t window_id, |
| 113 const gfx::Insets& new_client_area, |
| 114 const std::vector<gfx::Rect>& new_additional_client_areas) {} |
| 115 |
| 116 void RendererWindowTreeClient::OnTransientWindowAdded( |
| 117 uint32_t window_id, |
| 118 uint32_t transient_window_id) {} |
| 119 |
| 120 void RendererWindowTreeClient::OnTransientWindowRemoved( |
| 121 uint32_t window_id, |
| 122 uint32_t transient_window_id) {} |
| 123 |
| 124 void RendererWindowTreeClient::OnWindowHierarchyChanged( |
| 125 ui::Id window_id, |
| 126 ui::Id old_parent_id, |
| 127 ui::Id new_parent_id, |
| 128 std::vector<ui::mojom::WindowDataPtr> windows) {} |
| 129 |
| 130 void RendererWindowTreeClient::OnWindowReordered( |
| 131 ui::Id window_id, |
| 132 ui::Id relative_window_id, |
| 133 ui::mojom::OrderDirection direction) {} |
| 134 |
| 135 void RendererWindowTreeClient::OnWindowDeleted(ui::Id window_id) { |
| 136 // TODO(sad): With OOPIF, |window_id| may not be |root_window_id_|. We need to |
| 137 // make sure that works correctly. |
| 138 CHECK_EQ(window_id, root_window_id_); |
| 139 DestroySelf(); |
| 140 } |
| 141 |
| 142 void RendererWindowTreeClient::OnWindowVisibilityChanged(ui::Id window_id, |
| 143 bool visible) {} |
| 144 |
| 145 void RendererWindowTreeClient::OnWindowOpacityChanged(ui::Id window_id, |
| 146 float old_opacity, |
| 147 float new_opacity) {} |
| 148 |
| 149 void RendererWindowTreeClient::OnWindowParentDrawnStateChanged(ui::Id window_id, |
| 150 bool drawn) {} |
| 151 |
| 152 void RendererWindowTreeClient::OnWindowSharedPropertyChanged( |
| 153 ui::Id window_id, |
| 154 const std::string& name, |
| 155 const base::Optional<std::vector<uint8_t>>& new_data) {} |
| 156 |
| 157 void RendererWindowTreeClient::OnWindowInputEvent( |
| 158 uint32_t event_id, |
| 159 ui::Id window_id, |
| 160 std::unique_ptr<ui::Event> event, |
| 161 bool matches_pointer_watcher) { |
| 162 NOTREACHED(); |
| 163 } |
| 164 |
| 165 void RendererWindowTreeClient::OnPointerEventObserved( |
| 166 std::unique_ptr<ui::Event> event, |
| 167 uint32_t window_id) { |
| 168 NOTREACHED(); |
| 169 } |
| 170 |
| 171 void RendererWindowTreeClient::OnWindowFocused(ui::Id focused_window_id) {} |
| 172 |
| 173 void RendererWindowTreeClient::OnWindowPredefinedCursorChanged( |
| 174 ui::Id window_id, |
| 175 ui::mojom::Cursor cursor) {} |
| 176 |
| 177 void RendererWindowTreeClient::OnWindowSurfaceChanged( |
| 178 ui::Id window_id, |
| 179 const cc::SurfaceInfo& surface_info) { |
| 180 NOTIMPLEMENTED(); |
| 181 } |
| 182 |
| 183 void RendererWindowTreeClient::OnDragDropStart( |
| 184 const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data) {} |
| 185 |
| 186 void RendererWindowTreeClient::OnDragEnter( |
| 187 ui::Id window_id, |
| 188 uint32_t event_flags, |
| 189 const gfx::Point& position, |
| 190 uint32_t effect_bitmask, |
| 191 const OnDragEnterCallback& callback) {} |
| 192 |
| 193 void RendererWindowTreeClient::OnDragOver(ui::Id window_id, |
| 194 uint32_t event_flags, |
| 195 const gfx::Point& position, |
| 196 uint32_t effect_bitmask, |
| 197 const OnDragOverCallback& callback) {} |
| 198 |
| 199 void RendererWindowTreeClient::OnDragLeave(ui::Id window_id) {} |
| 200 |
| 201 void RendererWindowTreeClient::OnCompleteDrop( |
| 202 ui::Id window_id, |
| 203 uint32_t event_flags, |
| 204 const gfx::Point& position, |
| 205 uint32_t effect_bitmask, |
| 206 const OnCompleteDropCallback& callback) {} |
| 207 |
| 208 void RendererWindowTreeClient::OnPerformDragDropCompleted( |
| 209 uint32_t window, |
| 210 bool success, |
| 211 uint32_t action_taken) {} |
| 212 |
| 213 void RendererWindowTreeClient::OnDragDropDone() {} |
| 214 |
| 215 void RendererWindowTreeClient::OnChangeCompleted(uint32_t change_id, |
| 216 bool success) {} |
| 217 |
| 218 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {} |
| 219 |
| 220 void RendererWindowTreeClient::GetWindowManager( |
| 221 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { |
| 222 NOTREACHED(); |
| 223 } |
| 224 |
| 225 } // namespace content |
OLD | NEW |