Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: services/window_manager/window_manager_app.cc

Issue 815003002: Nukes ViewManager arg from ViewManagerDelegate::OnEmbed (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: format Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/window_manager/window_manager_app.h ('k') | sky/tools/debugger/debugger.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "services/window_manager/window_manager_app.h" 5 #include "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/converters/geometry/geometry_type_converters.h" 9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/converters/input_events/input_events_type_converters.h" 10 #include "mojo/converters/input_events/input_events_type_converters.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 //////////////////////////////////////////////////////////////////////////////// 48 ////////////////////////////////////////////////////////////////////////////////
49 // WindowManagerApp, public: 49 // WindowManagerApp, public:
50 50
51 WindowManagerApp::WindowManagerApp( 51 WindowManagerApp::WindowManagerApp(
52 ViewManagerDelegate* view_manager_delegate, 52 ViewManagerDelegate* view_manager_delegate,
53 WindowManagerDelegate* window_manager_delegate) 53 WindowManagerDelegate* window_manager_delegate)
54 : shell_(nullptr), 54 : shell_(nullptr),
55 native_viewport_event_dispatcher_factory_(this), 55 native_viewport_event_dispatcher_factory_(this),
56 wrapped_view_manager_delegate_(view_manager_delegate), 56 wrapped_view_manager_delegate_(view_manager_delegate),
57 window_manager_delegate_(window_manager_delegate), 57 window_manager_delegate_(window_manager_delegate),
58 view_manager_(nullptr),
59 root_(nullptr) { 58 root_(nullptr) {
60 } 59 }
61 60
62 WindowManagerApp::~WindowManagerApp() { 61 WindowManagerApp::~WindowManagerApp() {
63 STLDeleteElements(&connections_); 62 STLDeleteElements(&connections_);
64 } 63 }
65 64
66 void WindowManagerApp::AddConnection(WindowManagerImpl* connection) { 65 void WindowManagerApp::AddConnection(WindowManagerImpl* connection) {
67 DCHECK(connections_.find(connection) == connections_.end()); 66 DCHECK(connections_.find(connection) == connections_.end());
68 connections_.insert(connection); 67 connections_.insert(connection);
69 } 68 }
70 69
71 void WindowManagerApp::RemoveConnection(WindowManagerImpl* connection) { 70 void WindowManagerApp::RemoveConnection(WindowManagerImpl* connection) {
72 DCHECK(connections_.find(connection) != connections_.end()); 71 DCHECK(connections_.find(connection) != connections_.end());
73 connections_.erase(connection); 72 connections_.erase(connection);
74 } 73 }
75 74
76 void WindowManagerApp::SetCapture(Id view_id) { 75 void WindowManagerApp::SetCapture(Id view_id) {
77 View* view = view_manager_->GetViewById(view_id); 76 View* view = view_manager()->GetViewById(view_id);
78 DCHECK(view); 77 DCHECK(view);
79 capture_controller_->SetCapture(view); 78 capture_controller_->SetCapture(view);
80 } 79 }
81 80
82 void WindowManagerApp::FocusWindow(Id view_id) { 81 void WindowManagerApp::FocusWindow(Id view_id) {
83 View* view = view_manager_->GetViewById(view_id); 82 View* view = view_manager()->GetViewById(view_id);
84 DCHECK(view); 83 DCHECK(view);
85 focus_controller_->FocusView(view); 84 focus_controller_->FocusView(view);
86 } 85 }
87 86
88 void WindowManagerApp::ActivateWindow(Id view_id) { 87 void WindowManagerApp::ActivateWindow(Id view_id) {
89 View* view = view_manager_->GetViewById(view_id); 88 View* view = view_manager()->GetViewById(view_id);
90 DCHECK(view); 89 DCHECK(view);
91 focus_controller_->ActivateView(view); 90 focus_controller_->ActivateView(view);
92 } 91 }
93 92
94 bool WindowManagerApp::IsReady() const { 93 bool WindowManagerApp::IsReady() const {
95 return view_manager_ && root_; 94 return root_;
96 } 95 }
97 96
98 void WindowManagerApp::InitFocus(scoped_ptr<FocusRules> rules) { 97 void WindowManagerApp::InitFocus(scoped_ptr<FocusRules> rules) {
99 DCHECK(root_); 98 DCHECK(root_);
100 99
101 focus_controller_.reset(new FocusController(rules.Pass())); 100 focus_controller_.reset(new FocusController(rules.Pass()));
102 focus_controller_->AddObserver(this); 101 focus_controller_->AddObserver(this);
103 SetFocusController(root_, focus_controller_.get()); 102 SetFocusController(root_, focus_controller_.get());
104 103
105 capture_controller_.reset(new CaptureController); 104 capture_controller_.reset(new CaptureController);
106 capture_controller_->AddObserver(this); 105 capture_controller_->AddObserver(this);
107 SetCaptureController(root_, capture_controller_.get()); 106 SetCaptureController(root_, capture_controller_.get());
108 } 107 }
109 108
110 void WindowManagerApp::Embed( 109 void WindowManagerApp::Embed(
111 const mojo::String& url, 110 const mojo::String& url,
112 mojo::InterfaceRequest<ServiceProvider> service_provider) { 111 mojo::InterfaceRequest<ServiceProvider> service_provider) {
113 if (view_manager_) { 112 if (view_manager()) {
114 window_manager_delegate_->Embed(url, service_provider.Pass()); 113 window_manager_delegate_->Embed(url, service_provider.Pass());
115 return; 114 return;
116 } 115 }
117 scoped_ptr<PendingEmbed> pending_embed(new PendingEmbed); 116 scoped_ptr<PendingEmbed> pending_embed(new PendingEmbed);
118 pending_embed->url = url; 117 pending_embed->url = url;
119 pending_embed->service_provider = service_provider.Pass(); 118 pending_embed->service_provider = service_provider.Pass();
120 pending_embeds_.push_back(pending_embed.release()); 119 pending_embeds_.push_back(pending_embed.release());
121 } 120 }
122 121
123 //////////////////////////////////////////////////////////////////////////////// 122 ////////////////////////////////////////////////////////////////////////////////
124 // WindowManagerApp, ApplicationDelegate implementation: 123 // WindowManagerApp, ApplicationDelegate implementation:
125 124
126 void WindowManagerApp::Initialize(mojo::ApplicationImpl* impl) { 125 void WindowManagerApp::Initialize(mojo::ApplicationImpl* impl) {
127 shell_ = impl->shell(); 126 shell_ = impl->shell();
128 LaunchViewManager(impl); 127 LaunchViewManager(impl);
129 } 128 }
130 129
131 bool WindowManagerApp::ConfigureIncomingConnection( 130 bool WindowManagerApp::ConfigureIncomingConnection(
132 ApplicationConnection* connection) { 131 ApplicationConnection* connection) {
133 connection->AddService(static_cast<InterfaceFactory<WindowManager>*>(this)); 132 connection->AddService(static_cast<InterfaceFactory<WindowManager>*>(this));
134 return true; 133 return true;
135 } 134 }
136 135
137 //////////////////////////////////////////////////////////////////////////////// 136 ////////////////////////////////////////////////////////////////////////////////
138 // WindowManagerApp, ViewManagerDelegate implementation: 137 // WindowManagerApp, ViewManagerDelegate implementation:
139 138
140 void WindowManagerApp::OnEmbed(mojo::ViewManager* view_manager, 139 void WindowManagerApp::OnEmbed(View* root,
141 View* root,
142 mojo::ServiceProviderImpl* exported_services, 140 mojo::ServiceProviderImpl* exported_services,
143 scoped_ptr<ServiceProvider> imported_services) { 141 scoped_ptr<ServiceProvider> imported_services) {
144 DCHECK(!view_manager_ && !root_); 142 DCHECK(!root_);
145 view_manager_ = view_manager;
146 root_ = root; 143 root_ = root;
147 144
148 view_event_dispatcher_.reset(new ViewEventDispatcher); 145 view_event_dispatcher_.reset(new ViewEventDispatcher);
149 146
150 RegisterSubtree(root_); 147 RegisterSubtree(root_);
151 148
152 if (wrapped_view_manager_delegate_) { 149 if (wrapped_view_manager_delegate_) {
153 wrapped_view_manager_delegate_->OnEmbed( 150 wrapped_view_manager_delegate_->OnEmbed(root, exported_services,
154 view_manager, root, exported_services, imported_services.Pass()); 151 imported_services.Pass());
155 } 152 }
156 153
157 for (PendingEmbed* pending_embed : pending_embeds_) 154 for (PendingEmbed* pending_embed : pending_embeds_)
158 Embed(pending_embed->url, pending_embed->service_provider.Pass()); 155 Embed(pending_embed->url, pending_embed->service_provider.Pass());
159 pending_embeds_.clear(); 156 pending_embeds_.clear();
160 } 157 }
161 158
162 void WindowManagerApp::OnViewManagerDisconnected( 159 void WindowManagerApp::OnViewManagerDisconnected(
163 mojo::ViewManager* view_manager) { 160 mojo::ViewManager* view_manager) {
164 DCHECK_EQ(view_manager_, view_manager); 161 DCHECK(this->view_manager());
162 DCHECK_EQ(this->view_manager(), view_manager);
165 if (wrapped_view_manager_delegate_) 163 if (wrapped_view_manager_delegate_)
166 wrapped_view_manager_delegate_->OnViewManagerDisconnected(view_manager); 164 wrapped_view_manager_delegate_->OnViewManagerDisconnected(view_manager);
167 view_manager_ = nullptr; 165 root_ = nullptr;
168 base::MessageLoop::current()->Quit(); 166 base::MessageLoop::current()->Quit();
169 } 167 }
170 168
171 //////////////////////////////////////////////////////////////////////////////// 169 ////////////////////////////////////////////////////////////////////////////////
172 // WindowManagerApp, ViewObserver implementation: 170 // WindowManagerApp, ViewObserver implementation:
173 171
174 void WindowManagerApp::OnTreeChanged( 172 void WindowManagerApp::OnTreeChanged(
175 const ViewObserver::TreeChangeParams& params) { 173 const ViewObserver::TreeChangeParams& params) {
176 if (params.receiver != root_) 174 if (params.receiver != root_)
177 return; 175 return;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 uint16_t connection_id, 352 uint16_t connection_id,
355 mojo::ScopedMessagePipeHandle window_manager_pipe) { 353 mojo::ScopedMessagePipeHandle window_manager_pipe) {
356 // TODO(sky): pass in |connection_id| for validation. 354 // TODO(sky): pass in |connection_id| for validation.
357 WindowManagerImpl* wm = new WindowManagerImpl(this, true); 355 WindowManagerImpl* wm = new WindowManagerImpl(this, true);
358 wm->Bind(window_manager_pipe.Pass()); 356 wm->Bind(window_manager_pipe.Pass());
359 // WindowManagerImpl is deleted when the connection has an error, or from our 357 // WindowManagerImpl is deleted when the connection has an error, or from our
360 // destructor. 358 // destructor.
361 } 359 }
362 360
363 } // namespace window_manager 361 } // namespace window_manager
OLDNEW
« no previous file with comments | « services/window_manager/window_manager_app.h ('k') | sky/tools/debugger/debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698