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" |
| 11 #include "components/mus/public/cpp/property_type_converters.h" |
| 12 #include "components/mus/public/cpp/window.h" |
| 13 #include "components/mus/public/cpp/window_property.h" |
11 #include "components/mus/public/cpp/window_tree_connection.h" | 14 #include "components/mus/public/cpp/window_tree_connection.h" |
12 #include "components/mus/public/interfaces/window_tree.mojom.h" | 15 #include "components/mus/public/interfaces/window_tree.mojom.h" |
13 #include "mojo/converters/geometry/geometry_type_converters.h" | 16 #include "mojo/converters/geometry/geometry_type_converters.h" |
14 #include "services/shell/public/cpp/connection.h" | 17 #include "services/shell/public/cpp/connection.h" |
15 #include "services/shell/public/cpp/connector.h" | 18 #include "services/shell/public/cpp/connector.h" |
16 #include "ui/events/devices/device_data_manager.h" | 19 #include "ui/events/devices/device_data_manager.h" |
17 #include "ui/views/mus/native_widget_mus.h" | 20 #include "ui/views/mus/native_widget_mus.h" |
18 #include "ui/views/mus/screen_mus.h" | 21 #include "ui/views/mus/screen_mus.h" |
19 #include "ui/views/views_delegate.h" | 22 #include "ui/views/views_delegate.h" |
20 | 23 |
21 namespace views { | 24 namespace views { |
22 namespace { | 25 namespace { |
23 | 26 |
24 using WindowManagerConnectionPtr = | 27 using WindowManagerConnectionPtr = |
25 base::ThreadLocalPointer<views::WindowManagerConnection>; | 28 base::ThreadLocalPointer<views::WindowManagerConnection>; |
26 | 29 |
27 // Env is thread local so that aura may be used on multiple threads. | 30 // Env is thread local so that aura may be used on multiple threads. |
28 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr = | 31 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr = |
29 LAZY_INSTANCE_INITIALIZER; | 32 LAZY_INSTANCE_INITIALIZER; |
30 | 33 |
31 } // namespace | 34 } // namespace |
32 | 35 |
33 // static | 36 // static |
34 void WindowManagerConnection::Create(shell::Connector* connector) { | 37 void WindowManagerConnection::Create(shell::Connector* connector, |
| 38 const shell::Identity& identity) { |
35 DCHECK(!lazy_tls_ptr.Pointer()->Get()); | 39 DCHECK(!lazy_tls_ptr.Pointer()->Get()); |
36 lazy_tls_ptr.Pointer()->Set(new WindowManagerConnection(connector)); | 40 lazy_tls_ptr.Pointer()->Set(new WindowManagerConnection(connector, identity)); |
37 } | 41 } |
38 | 42 |
39 // static | 43 // static |
40 WindowManagerConnection* WindowManagerConnection::Get() { | 44 WindowManagerConnection* WindowManagerConnection::Get() { |
41 WindowManagerConnection* connection = lazy_tls_ptr.Pointer()->Get(); | 45 WindowManagerConnection* connection = lazy_tls_ptr.Pointer()->Get(); |
42 DCHECK(connection); | 46 DCHECK(connection); |
43 return connection; | 47 return connection; |
44 } | 48 } |
45 | 49 |
46 // static | 50 // static |
(...skipping 11 matching lines...) Expand all Loading... |
58 const std::map<std::string, std::vector<uint8_t>>& properties) { | 62 const std::map<std::string, std::vector<uint8_t>>& properties) { |
59 return window_tree_connection_->NewTopLevelWindow(&properties); | 63 return window_tree_connection_->NewTopLevelWindow(&properties); |
60 } | 64 } |
61 | 65 |
62 NativeWidget* WindowManagerConnection::CreateNativeWidgetMus( | 66 NativeWidget* WindowManagerConnection::CreateNativeWidgetMus( |
63 const std::map<std::string, std::vector<uint8_t>>& props, | 67 const std::map<std::string, std::vector<uint8_t>>& props, |
64 const Widget::InitParams& init_params, | 68 const Widget::InitParams& init_params, |
65 internal::NativeWidgetDelegate* delegate) { | 69 internal::NativeWidgetDelegate* delegate) { |
66 std::map<std::string, std::vector<uint8_t>> properties = props; | 70 std::map<std::string, std::vector<uint8_t>> properties = props; |
67 NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties); | 71 NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties); |
| 72 properties[mus::mojom::WindowManager::kAppID_Property] = |
| 73 mojo::ConvertTo<std::vector<uint8_t>>(identity_.name()); |
68 return new NativeWidgetMus(delegate, connector_, NewWindow(properties), | 74 return new NativeWidgetMus(delegate, connector_, NewWindow(properties), |
69 mus::mojom::SurfaceType::DEFAULT); | 75 mus::mojom::SurfaceType::DEFAULT); |
70 } | 76 } |
71 | 77 |
72 WindowManagerConnection::WindowManagerConnection(shell::Connector* connector) | 78 WindowManagerConnection::WindowManagerConnection( |
73 : connector_(connector), window_tree_connection_(nullptr) { | 79 shell::Connector* connector, |
| 80 const shell::Identity& identity) |
| 81 : connector_(connector), |
| 82 identity_(identity), |
| 83 window_tree_connection_(nullptr) { |
74 window_tree_connection_.reset( | 84 window_tree_connection_.reset( |
75 mus::WindowTreeConnection::Create(this, connector_)); | 85 mus::WindowTreeConnection::Create(this, connector_)); |
76 | 86 |
77 screen_.reset(new ScreenMus(this)); | 87 screen_.reset(new ScreenMus(this)); |
78 screen_->Init(connector); | 88 screen_->Init(connector); |
79 | 89 |
80 // TODO(sad): We should have a DeviceDataManager implementation that talks to | 90 // TODO(sad): We should have a DeviceDataManager implementation that talks to |
81 // a mojo service to learn about the input-devices on the system. | 91 // a mojo service to learn about the input-devices on the system. |
82 // http://crbug.com/601981 | 92 // http://crbug.com/601981 |
83 ui::DeviceDataManager::CreateInstance(); | 93 ui::DeviceDataManager::CreateInstance(); |
(...skipping 16 matching lines...) Expand all Loading... |
100 | 110 |
101 void WindowManagerConnection::OnConnectionLost( | 111 void WindowManagerConnection::OnConnectionLost( |
102 mus::WindowTreeConnection* connection) {} | 112 mus::WindowTreeConnection* connection) {} |
103 | 113 |
104 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 114 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
105 if (window_tree_connection_) | 115 if (window_tree_connection_) |
106 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); | 116 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); |
107 } | 117 } |
108 | 118 |
109 } // namespace views | 119 } // namespace views |
OLD | NEW |