OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/views/mus/native_widget_mus.h" | 5 #include "ui/views/mus/native_widget_mus.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "components/mus/public/cpp/property_type_converters.h" | 9 #include "components/mus/public/cpp/property_type_converters.h" |
10 #include "components/mus/public/cpp/window.h" | 10 #include "components/mus/public/cpp/window.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 behavior |= mus::mojom::kResizeBehaviorCanMinimize; | 169 behavior |= mus::mojom::kResizeBehaviorCanMinimize; |
170 return behavior; | 170 return behavior; |
171 } | 171 } |
172 | 172 |
173 } // namespace | 173 } // namespace |
174 | 174 |
175 //////////////////////////////////////////////////////////////////////////////// | 175 //////////////////////////////////////////////////////////////////////////////// |
176 // NativeWidgetMus, public: | 176 // NativeWidgetMus, public: |
177 | 177 |
178 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, | 178 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, |
179 mojo::Shell* shell, | 179 mojo::Connector* connector, |
180 mus::Window* window, | 180 mus::Window* window, |
181 mus::mojom::SurfaceType surface_type) | 181 mus::mojom::SurfaceType surface_type) |
182 : window_(window), | 182 : window_(window), |
183 native_widget_delegate_(delegate), | 183 native_widget_delegate_(delegate), |
184 surface_type_(surface_type), | 184 surface_type_(surface_type), |
185 show_state_before_fullscreen_(ui::PLATFORM_WINDOW_STATE_UNKNOWN), | 185 show_state_before_fullscreen_(ui::PLATFORM_WINDOW_STATE_UNKNOWN), |
186 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 186 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
187 content_(new aura::Window(this)), | 187 content_(new aura::Window(this)), |
188 close_widget_factory_(this) { | 188 close_widget_factory_(this) { |
189 // TODO(fsamuel): Figure out lifetime of |window_|. | 189 // TODO(fsamuel): Figure out lifetime of |window_|. |
190 aura::SetMusWindow(content_, window_); | 190 aura::SetMusWindow(content_, window_); |
191 | 191 |
192 window->SetLocalProperty(kNativeWidgetMusKey, this); | 192 window->SetLocalProperty(kNativeWidgetMusKey, this); |
193 // WindowTreeHost creates the compositor using the ContextFactory from | 193 // WindowTreeHost creates the compositor using the ContextFactory from |
194 // aura::Env. Install |context_factory_| there so that |context_factory_| is | 194 // aura::Env. Install |context_factory_| there so that |context_factory_| is |
195 // picked up. | 195 // picked up. |
196 ui::ContextFactory* default_context_factory = | 196 ui::ContextFactory* default_context_factory = |
197 aura::Env::GetInstance()->context_factory(); | 197 aura::Env::GetInstance()->context_factory(); |
198 // For Chrome, we need the GpuProcessTransportFactory so that renderer and | 198 // For Chrome, we need the GpuProcessTransportFactory so that renderer and |
199 // browser pixels are composited into a single backing | 199 // browser pixels are composited into a single backing |
200 // SoftwareOutputDeviceMus. | 200 // SoftwareOutputDeviceMus. |
201 if (!default_context_factory) { | 201 if (!default_context_factory) { |
202 context_factory_.reset( | 202 context_factory_.reset( |
203 new SurfaceContextFactory(shell, window_, surface_type_)); | 203 new SurfaceContextFactory(connector, window_, surface_type_)); |
204 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 204 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
205 } | 205 } |
206 window_tree_host_.reset(new WindowTreeHostMus(shell, this, window_)); | 206 window_tree_host_.reset(new WindowTreeHostMus(connector, this, window_)); |
207 aura::Env::GetInstance()->set_context_factory(default_context_factory); | 207 aura::Env::GetInstance()->set_context_factory(default_context_factory); |
208 } | 208 } |
209 | 209 |
210 NativeWidgetMus::~NativeWidgetMus() { | 210 NativeWidgetMus::~NativeWidgetMus() { |
211 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 211 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
212 delete native_widget_delegate_; | 212 delete native_widget_delegate_; |
213 else | 213 else |
214 CloseNow(); | 214 CloseNow(); |
215 } | 215 } |
216 | 216 |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 | 852 |
853 void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) { | 853 void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) { |
854 native_widget_delegate_->OnGestureEvent(event); | 854 native_widget_delegate_->OnGestureEvent(event); |
855 } | 855 } |
856 | 856 |
857 void NativeWidgetMus::OnHostCloseRequested(const aura::WindowTreeHost* host) { | 857 void NativeWidgetMus::OnHostCloseRequested(const aura::WindowTreeHost* host) { |
858 GetWidget()->Close(); | 858 GetWidget()->Close(); |
859 } | 859 } |
860 | 860 |
861 } // namespace views | 861 } // namespace views |
OLD | NEW |