| 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/window_manager_connection.h" | 5 #include "ui/views/mus/window_manager_connection.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 void WindowManagerConnection::Reset() { | 47 void WindowManagerConnection::Reset() { |
| 48 delete Get(); | 48 delete Get(); |
| 49 lazy_tls_ptr.Pointer()->Set(nullptr); | 49 lazy_tls_ptr.Pointer()->Set(nullptr); |
| 50 } | 50 } |
| 51 | 51 |
| 52 mus::Window* WindowManagerConnection::NewWindow( | 52 mus::Window* WindowManagerConnection::NewWindow( |
| 53 const std::map<std::string, std::vector<uint8_t>>& properties) { | 53 const std::map<std::string, std::vector<uint8_t>>& properties) { |
| 54 return window_tree_connection_->NewTopLevelWindow(&properties); | 54 return window_tree_connection_->NewTopLevelWindow(&properties); |
| 55 } | 55 } |
| 56 | 56 |
| 57 NativeWidget* WindowManagerConnection::CreateNativeWidgetMus( | |
| 58 const Widget::InitParams& init_params, | |
| 59 internal::NativeWidgetDelegate* delegate) { | |
| 60 std::map<std::string, std::vector<uint8_t>> properties; | |
| 61 NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties); | |
| 62 return new NativeWidgetMus(delegate, shell_, NewWindow(properties), | |
| 63 mus::mojom::SurfaceType::DEFAULT); | |
| 64 } | |
| 65 | |
| 66 WindowManagerConnection::WindowManagerConnection(mojo::Shell* shell) | 57 WindowManagerConnection::WindowManagerConnection(mojo::Shell* shell) |
| 67 : shell_(shell), window_tree_connection_(nullptr) { | 58 : shell_(shell), window_tree_connection_(nullptr) { |
| 68 window_tree_connection_.reset( | 59 window_tree_connection_.reset( |
| 69 mus::WindowTreeConnection::Create(this, shell_)); | 60 mus::WindowTreeConnection::Create(this, shell_)); |
| 70 | 61 |
| 71 screen_.reset(new ScreenMus(this)); | 62 screen_.reset(new ScreenMus(this)); |
| 72 screen_->Init(shell); | 63 screen_->Init(shell); |
| 73 | 64 |
| 74 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( | 65 ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 75 &WindowManagerConnection::CreateNativeWidgetMus, base::Unretained(this))); | 66 base::Bind(&WindowManagerConnection::CreateNativeWidget, |
| 67 base::Unretained(this))); |
| 76 } | 68 } |
| 77 | 69 |
| 78 WindowManagerConnection::~WindowManagerConnection() { | 70 WindowManagerConnection::~WindowManagerConnection() { |
| 79 // ~WindowTreeConnection calls back to us (we're the WindowTreeDelegate), | 71 // ~WindowTreeConnection calls back to us (we're the WindowTreeDelegate), |
| 80 // destroy it while we are still valid. | 72 // destroy it while we are still valid. |
| 81 window_tree_connection_.reset(); | 73 window_tree_connection_.reset(); |
| 82 } | 74 } |
| 83 | 75 |
| 84 void WindowManagerConnection::OnEmbed(mus::Window* root) {} | 76 void WindowManagerConnection::OnEmbed(mus::Window* root) {} |
| 85 | 77 |
| 86 void WindowManagerConnection::OnConnectionLost( | 78 void WindowManagerConnection::OnConnectionLost( |
| 87 mus::WindowTreeConnection* connection) {} | 79 mus::WindowTreeConnection* connection) {} |
| 88 | 80 |
| 89 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 81 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
| 90 if (window_tree_connection_) | 82 if (window_tree_connection_) |
| 91 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); | 83 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); |
| 92 } | 84 } |
| 93 | 85 |
| 86 NativeWidget* WindowManagerConnection::CreateNativeWidget( |
| 87 const Widget::InitParams& init_params, |
| 88 internal::NativeWidgetDelegate* delegate) { |
| 89 std::map<std::string, std::vector<uint8_t>> properties; |
| 90 NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties); |
| 91 return new NativeWidgetMus(delegate, shell_, NewWindow(properties), |
| 92 mus::mojom::SurfaceType::DEFAULT); |
| 93 } |
| 94 |
| 94 } // namespace views | 95 } // namespace views |
| OLD | NEW |