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 "components/view_manager/public/cpp/view.h" | 5 #include "components/view_manager/public/cpp/view.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "components/view_manager/public/cpp/lib/view_private.h" | 10 #include "components/view_manager/public/cpp/lib/view_private.h" |
11 #include "components/view_manager/public/cpp/lib/view_tree_client_impl.h" | 11 #include "components/view_manager/public/cpp/lib/view_tree_client_impl.h" |
12 #include "components/view_manager/public/cpp/view_observer.h" | 12 #include "components/view_manager/public/cpp/view_observer.h" |
| 13 #include "components/view_manager/public/cpp/view_surface.h" |
13 #include "components/view_manager/public/cpp/view_tracker.h" | 14 #include "components/view_manager/public/cpp/view_tracker.h" |
14 #include "mojo/application/public/cpp/service_provider_impl.h" | 15 #include "mojo/application/public/cpp/service_provider_impl.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 void NotifyViewTreeChangeAtReceiver( | 21 void NotifyViewTreeChangeAtReceiver( |
21 View* receiver, | 22 View* receiver, |
22 const ViewObserver::TreeChangeParams& params, | 23 const ViewObserver::TreeChangeParams& params, |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 217 |
217 void View::SetVisible(bool value) { | 218 void View::SetVisible(bool value) { |
218 if (visible_ == value) | 219 if (visible_ == value) |
219 return; | 220 return; |
220 | 221 |
221 if (connection_) | 222 if (connection_) |
222 static_cast<ViewTreeClientImpl*>(connection_)->SetVisible(id_, value); | 223 static_cast<ViewTreeClientImpl*>(connection_)->SetVisible(id_, value); |
223 LocalSetVisible(value); | 224 LocalSetVisible(value); |
224 } | 225 } |
225 | 226 |
| 227 scoped_ptr<mojo::ViewSurface> View::RequestSurface() { |
| 228 mojo::SurfacePtr surface; |
| 229 mojo::SurfaceClientPtr client; |
| 230 mojo::InterfaceRequest<SurfaceClient> client_request = GetProxy(&client); |
| 231 static_cast<ViewTreeClientImpl*>(connection_)->RequestSurface( |
| 232 id_, GetProxy(&surface), client.Pass()); |
| 233 return make_scoped_ptr(new mojo::ViewSurface(surface.PassInterface(), |
| 234 client_request.Pass())); |
| 235 } |
| 236 |
226 void View::SetSharedProperty(const std::string& name, | 237 void View::SetSharedProperty(const std::string& name, |
227 const std::vector<uint8_t>* value) { | 238 const std::vector<uint8_t>* value) { |
228 std::vector<uint8_t> old_value; | 239 std::vector<uint8_t> old_value; |
229 std::vector<uint8_t>* old_value_ptr = nullptr; | 240 std::vector<uint8_t>* old_value_ptr = nullptr; |
230 auto it = properties_.find(name); | 241 auto it = properties_.find(name); |
231 if (it != properties_.end()) { | 242 if (it != properties_.end()) { |
232 old_value = it->second; | 243 old_value = it->second; |
233 old_value_ptr = &old_value; | 244 old_value_ptr = &old_value; |
234 | 245 |
235 if (value && old_value == *value) | 246 if (value && old_value == *value) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 // TODO(beng): this could be improved depending on how we decide to own views. | 358 // TODO(beng): this could be improved depending on how we decide to own views. |
348 Children::const_iterator it = children_.begin(); | 359 Children::const_iterator it = children_.begin(); |
349 for (; it != children_.end(); ++it) { | 360 for (; it != children_.end(); ++it) { |
350 View* view = (*it)->GetChildById(id); | 361 View* view = (*it)->GetChildById(id); |
351 if (view) | 362 if (view) |
352 return view; | 363 return view; |
353 } | 364 } |
354 return NULL; | 365 return NULL; |
355 } | 366 } |
356 | 367 |
357 void View::SetSurfaceId(SurfaceIdPtr id) { | |
358 if (connection_) { | |
359 static_cast<ViewTreeClientImpl*>(connection_)->SetSurfaceId(id_, id.Pass()); | |
360 } | |
361 } | |
362 | |
363 void View::SetTextInputState(TextInputStatePtr state) { | 368 void View::SetTextInputState(TextInputStatePtr state) { |
364 if (connection_) { | 369 if (connection_) { |
365 static_cast<ViewTreeClientImpl*>(connection_) | 370 static_cast<ViewTreeClientImpl*>(connection_) |
366 ->SetViewTextInputState(id_, state.Pass()); | 371 ->SetViewTextInputState(id_, state.Pass()); |
367 } | 372 } |
368 } | 373 } |
369 | 374 |
370 void View::SetImeVisibility(bool visible, TextInputStatePtr state) { | 375 void View::SetImeVisibility(bool visible, TextInputStatePtr state) { |
371 // SetImeVisibility() shouldn't be used if the view is not editable. | 376 // SetImeVisibility() shouldn't be used if the view is not editable. |
372 DCHECK(state.is_null() || state->type != TEXT_INPUT_TYPE_NONE); | 377 DCHECK(state.is_null() || state->type != TEXT_INPUT_TYPE_NONE); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 !static_cast<ViewTreeClientImpl*>(connection_)->is_embed_root()) { | 608 !static_cast<ViewTreeClientImpl*>(connection_)->is_embed_root()) { |
604 return false; | 609 return false; |
605 } | 610 } |
606 | 611 |
607 while (!children_.empty()) | 612 while (!children_.empty()) |
608 RemoveChild(children_[0]); | 613 RemoveChild(children_[0]); |
609 return true; | 614 return true; |
610 } | 615 } |
611 | 616 |
612 } // namespace mojo | 617 } // namespace mojo |
OLD | NEW |