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 30 matching lines...) Expand all Loading... |
41 WindowManagerConnection* connection = lazy_tls_ptr.Pointer()->Get(); | 41 WindowManagerConnection* connection = lazy_tls_ptr.Pointer()->Get(); |
42 DCHECK(connection); | 42 DCHECK(connection); |
43 return connection; | 43 return connection; |
44 } | 44 } |
45 | 45 |
46 mus::Window* WindowManagerConnection::NewWindow( | 46 mus::Window* WindowManagerConnection::NewWindow( |
47 const std::map<std::string, std::vector<uint8_t>>& properties) { | 47 const std::map<std::string, std::vector<uint8_t>>& properties) { |
48 return window_tree_connection_->NewTopLevelWindow(&properties); | 48 return window_tree_connection_->NewTopLevelWindow(&properties); |
49 } | 49 } |
50 | 50 |
| 51 NativeWidget* WindowManagerConnection::CreateNativeWidgetMus( |
| 52 const Widget::InitParams& init_params, |
| 53 internal::NativeWidgetDelegate* delegate) { |
| 54 std::map<std::string, std::vector<uint8_t>> properties; |
| 55 NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties); |
| 56 return new NativeWidgetMus(delegate, app_->shell(), NewWindow(properties), |
| 57 mus::mojom::SurfaceType::DEFAULT); |
| 58 } |
| 59 |
51 WindowManagerConnection::WindowManagerConnection(mojo::ApplicationImpl* app) | 60 WindowManagerConnection::WindowManagerConnection(mojo::ApplicationImpl* app) |
52 : app_(app), window_tree_connection_(nullptr) { | 61 : app_(app), window_tree_connection_(nullptr) { |
53 window_tree_connection_.reset(mus::WindowTreeConnection::Create(this, app_)); | 62 window_tree_connection_.reset(mus::WindowTreeConnection::Create(this, app_)); |
54 | 63 |
55 screen_.reset(new ScreenMus(this)); | 64 screen_.reset(new ScreenMus(this)); |
56 screen_->Init(app); | 65 screen_->Init(app); |
57 | 66 |
58 ViewsDelegate::GetInstance()->set_native_widget_factory( | 67 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( |
59 base::Bind(&WindowManagerConnection::CreateNativeWidget, | 68 &WindowManagerConnection::CreateNativeWidgetMus, base::Unretained(this))); |
60 base::Unretained(this))); | |
61 } | 69 } |
62 | 70 |
63 WindowManagerConnection::~WindowManagerConnection() { | 71 WindowManagerConnection::~WindowManagerConnection() { |
64 // ~WindowTreeConnection calls back to us (we're the WindowTreeDelegate), | 72 // ~WindowTreeConnection calls back to us (we're the WindowTreeDelegate), |
65 // destroy it while we are still valid. | 73 // destroy it while we are still valid. |
66 window_tree_connection_.reset(); | 74 window_tree_connection_.reset(); |
67 } | 75 } |
68 | 76 |
69 void WindowManagerConnection::OnEmbed(mus::Window* root) {} | 77 void WindowManagerConnection::OnEmbed(mus::Window* root) {} |
70 | 78 |
71 void WindowManagerConnection::OnConnectionLost( | 79 void WindowManagerConnection::OnConnectionLost( |
72 mus::WindowTreeConnection* connection) {} | 80 mus::WindowTreeConnection* connection) {} |
73 | 81 |
74 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 82 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
75 if (window_tree_connection_) | 83 if (window_tree_connection_) |
76 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); | 84 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); |
77 } | 85 } |
78 | 86 |
79 NativeWidget* WindowManagerConnection::CreateNativeWidget( | |
80 const Widget::InitParams& init_params, | |
81 internal::NativeWidgetDelegate* delegate) { | |
82 std::map<std::string, std::vector<uint8_t>> properties; | |
83 NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties); | |
84 return new NativeWidgetMus(delegate, app_->shell(), NewWindow(properties), | |
85 mus::mojom::SurfaceType::DEFAULT); | |
86 } | |
87 | |
88 } // namespace views | 87 } // namespace views |
OLD | NEW |