OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/window_manager/window_manager_app.h" | 5 #include "mojo/services/window_manager/window_manager_app.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "mojo/aura/aura_init.h" | 9 #include "mojo/aura/aura_init.h" |
10 #include "mojo/converters/geometry/geometry_type_converters.h" | 10 #include "mojo/converters/geometry/geometry_type_converters.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 public: | 83 public: |
84 WindowManagerInternalImpl(WindowManagerApp* app) : app_(app) {} | 84 WindowManagerInternalImpl(WindowManagerApp* app) : app_(app) {} |
85 ~WindowManagerInternalImpl() override {} | 85 ~WindowManagerInternalImpl() override {} |
86 | 86 |
87 // WindowManagerInternal: | 87 // WindowManagerInternal: |
88 void CreateWindowManagerForViewManagerClient( | 88 void CreateWindowManagerForViewManagerClient( |
89 uint16_t connection_id, | 89 uint16_t connection_id, |
90 ScopedMessagePipeHandle window_manager_pipe) override { | 90 ScopedMessagePipeHandle window_manager_pipe) override { |
91 // |wm_internal| is tied to the life of the pipe. | 91 // |wm_internal| is tied to the life of the pipe. |
92 WindowManagerImpl* wm = new WindowManagerImpl(app_, true); | 92 WindowManagerImpl* wm = new WindowManagerImpl(app_, true); |
93 BindToPipe(wm, window_manager_pipe.Pass()); | 93 WeakBindToPipe(wm, window_manager_pipe.Pass()); |
| 94 } |
| 95 |
| 96 // InterfaceImpl: |
| 97 void OnConnectionError() override { |
| 98 // Necessary since we used WeakBindToPipe and are not automatically deleted. |
| 99 delete this; |
94 } | 100 } |
95 | 101 |
96 private: | 102 private: |
97 WindowManagerApp* app_; | 103 WindowManagerApp* app_; |
98 | 104 |
99 DISALLOW_COPY_AND_ASSIGN(WindowManagerInternalImpl); | 105 DISALLOW_COPY_AND_ASSIGN(WindowManagerInternalImpl); |
100 }; | 106 }; |
101 | 107 |
102 // Used for calls to Embed() that occur before we've connected to the | 108 // Used for calls to Embed() that occur before we've connected to the |
103 // ViewManager. | 109 // ViewManager. |
(...skipping 11 matching lines...) Expand all Loading... |
115 : shell_(nullptr), | 121 : shell_(nullptr), |
116 window_manager_factory_(this), | 122 window_manager_factory_(this), |
117 native_viewport_event_dispatcher_factory_(this), | 123 native_viewport_event_dispatcher_factory_(this), |
118 wrapped_view_manager_delegate_(view_manager_delegate), | 124 wrapped_view_manager_delegate_(view_manager_delegate), |
119 window_manager_delegate_(window_manager_delegate), | 125 window_manager_delegate_(window_manager_delegate), |
120 view_manager_(NULL), | 126 view_manager_(NULL), |
121 root_(NULL), | 127 root_(NULL), |
122 dummy_delegate_(new DummyDelegate) { | 128 dummy_delegate_(new DummyDelegate) { |
123 } | 129 } |
124 | 130 |
125 WindowManagerApp::~WindowManagerApp() {} | 131 WindowManagerApp::~WindowManagerApp() { |
| 132 STLDeleteElements(&connections_); |
| 133 } |
126 | 134 |
127 // static | 135 // static |
128 View* WindowManagerApp::GetViewForWindow(aura::Window* window) { | 136 View* WindowManagerApp::GetViewForWindow(aura::Window* window) { |
129 return window->GetProperty(kViewKey); | 137 return window->GetProperty(kViewKey); |
130 } | 138 } |
131 | 139 |
132 aura::Window* WindowManagerApp::GetWindowForViewId(Id view) { | 140 aura::Window* WindowManagerApp::GetWindowForViewId(Id view) { |
133 ViewIdToWindowMap::const_iterator it = view_id_to_window_map_.find(view); | 141 ViewIdToWindowMap::const_iterator it = view_id_to_window_map_.find(view); |
134 return it != view_id_to_window_map_.end() ? it->second : NULL; | 142 return it != view_id_to_window_map_.end() ? it->second : NULL; |
135 } | 143 } |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 view_manager_app->ConnectToService(&window_manager_client_); | 412 view_manager_app->ConnectToService(&window_manager_client_); |
405 } | 413 } |
406 | 414 |
407 void WindowManagerApp::Create(ApplicationConnection* connection, | 415 void WindowManagerApp::Create(ApplicationConnection* connection, |
408 InterfaceRequest<WindowManagerInternal> request) { | 416 InterfaceRequest<WindowManagerInternal> request) { |
409 WindowManagerInternalImpl* impl = new WindowManagerInternalImpl(this); | 417 WindowManagerInternalImpl* impl = new WindowManagerInternalImpl(this); |
410 BindToRequest(impl, &request); | 418 BindToRequest(impl, &request); |
411 } | 419 } |
412 | 420 |
413 } // namespace mojo | 421 } // namespace mojo |
OLD | NEW |