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 25 matching lines...) Expand all Loading... |
36 lazy_tls_ptr.Pointer()->Set(new WindowManagerConnection(shell)); | 36 lazy_tls_ptr.Pointer()->Set(new WindowManagerConnection(shell)); |
37 } | 37 } |
38 | 38 |
39 // static | 39 // static |
40 WindowManagerConnection* WindowManagerConnection::Get() { | 40 WindowManagerConnection* WindowManagerConnection::Get() { |
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 // static |
| 47 void WindowManagerConnection::Reset() { |
| 48 delete Get(); |
| 49 lazy_tls_ptr.Pointer()->Set(nullptr); |
| 50 } |
| 51 |
46 mus::Window* WindowManagerConnection::NewWindow( | 52 mus::Window* WindowManagerConnection::NewWindow( |
47 const std::map<std::string, std::vector<uint8_t>>& properties) { | 53 const std::map<std::string, std::vector<uint8_t>>& properties) { |
48 return window_tree_connection_->NewTopLevelWindow(&properties); | 54 return window_tree_connection_->NewTopLevelWindow(&properties); |
49 } | 55 } |
50 | 56 |
51 WindowManagerConnection::WindowManagerConnection(mojo::Shell* shell) | 57 WindowManagerConnection::WindowManagerConnection(mojo::Shell* shell) |
52 : shell_(shell), window_tree_connection_(nullptr) { | 58 : shell_(shell), window_tree_connection_(nullptr) { |
53 window_tree_connection_.reset( | 59 window_tree_connection_.reset( |
54 mus::WindowTreeConnection::Create(this, shell_)); | 60 mus::WindowTreeConnection::Create(this, shell_)); |
55 | 61 |
(...skipping 24 matching lines...) Expand all Loading... |
80 NativeWidget* WindowManagerConnection::CreateNativeWidget( | 86 NativeWidget* WindowManagerConnection::CreateNativeWidget( |
81 const Widget::InitParams& init_params, | 87 const Widget::InitParams& init_params, |
82 internal::NativeWidgetDelegate* delegate) { | 88 internal::NativeWidgetDelegate* delegate) { |
83 std::map<std::string, std::vector<uint8_t>> properties; | 89 std::map<std::string, std::vector<uint8_t>> properties; |
84 NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties); | 90 NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties); |
85 return new NativeWidgetMus(delegate, shell_, NewWindow(properties), | 91 return new NativeWidgetMus(delegate, shell_, NewWindow(properties), |
86 mus::mojom::SurfaceType::DEFAULT); | 92 mus::mojom::SurfaceType::DEFAULT); |
87 } | 93 } |
88 | 94 |
89 } // namespace views | 95 } // namespace views |
OLD | NEW |