| 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 "services/view_manager/view_manager_service_impl.h" | 5 #include "services/view_manager/view_manager_service_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "mojo/converters/geometry/geometry_type_converters.h" | 10 #include "mojo/converters/geometry/geometry_type_converters.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 view_map_.count(connection->root_->view_id) > 0) { | 93 view_map_.count(connection->root_->view_id) > 0) { |
| 94 client()->OnEmbeddedAppDisconnected( | 94 client()->OnEmbeddedAppDisconnected( |
| 95 ViewIdToTransportId(*connection->root_)); | 95 ViewIdToTransportId(*connection->root_)); |
| 96 } | 96 } |
| 97 if (root_.get() && root_->connection_id == connection->id()) | 97 if (root_.get() && root_->connection_id == connection->id()) |
| 98 root_.reset(); | 98 root_.reset(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 mojo::ErrorCode ViewManagerServiceImpl::CreateView(const ViewId& view_id) { | 101 mojo::ErrorCode ViewManagerServiceImpl::CreateView(const ViewId& view_id) { |
| 102 if (view_id.connection_id != id_) | 102 if (view_id.connection_id != id_) |
| 103 return mojo::ERROR_CODE_ILLEGAL_ARGUMENT; | 103 return mojo::ErrorCode::ILLEGAL_ARGUMENT; |
| 104 if (view_map_.find(view_id.view_id) != view_map_.end()) | 104 if (view_map_.find(view_id.view_id) != view_map_.end()) |
| 105 return mojo::ERROR_CODE_VALUE_IN_USE; | 105 return mojo::ErrorCode::VALUE_IN_USE; |
| 106 view_map_[view_id.view_id] = connection_manager_->CreateServerView(view_id); | 106 view_map_[view_id.view_id] = connection_manager_->CreateServerView(view_id); |
| 107 known_views_.insert(ViewIdToTransportId(view_id)); | 107 known_views_.insert(ViewIdToTransportId(view_id)); |
| 108 return mojo::ERROR_CODE_NONE; | 108 return mojo::ErrorCode::NONE; |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool ViewManagerServiceImpl::AddView(const ViewId& parent_id, | 111 bool ViewManagerServiceImpl::AddView(const ViewId& parent_id, |
| 112 const ViewId& child_id) { | 112 const ViewId& child_id) { |
| 113 ServerView* parent = GetView(parent_id); | 113 ServerView* parent = GetView(parent_id); |
| 114 ServerView* child = GetView(child_id); | 114 ServerView* child = GetView(child_id); |
| 115 if (parent && child && child->parent() != parent && | 115 if (parent && child && child->parent() != parent && |
| 116 !child->Contains(parent) && access_policy_->CanAddView(parent, child)) { | 116 !child->Contains(parent) && access_policy_->CanAddView(parent, child)) { |
| 117 ConnectionManager::ScopedChange change(this, connection_manager_, false); | 117 ConnectionManager::ScopedChange change(this, connection_manager_, false); |
| 118 parent->Add(child); | 118 parent->Add(child); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 320 |
| 321 if (!access_policy_->CanReorderView(view, relative_view, direction)) | 321 if (!access_policy_->CanReorderView(view, relative_view, direction)) |
| 322 return false; | 322 return false; |
| 323 | 323 |
| 324 std::vector<const ServerView*> children = view->parent()->GetChildren(); | 324 std::vector<const ServerView*> children = view->parent()->GetChildren(); |
| 325 const size_t child_i = | 325 const size_t child_i = |
| 326 std::find(children.begin(), children.end(), view) - children.begin(); | 326 std::find(children.begin(), children.end(), view) - children.begin(); |
| 327 const size_t target_i = | 327 const size_t target_i = |
| 328 std::find(children.begin(), children.end(), relative_view) - | 328 std::find(children.begin(), children.end(), relative_view) - |
| 329 children.begin(); | 329 children.begin(); |
| 330 if ((direction == mojo::ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || | 330 if ((direction == mojo::OrderDirection::ABOVE && child_i == target_i + 1) || |
| 331 (direction == mojo::ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { | 331 (direction == mojo::OrderDirection::BELOW && child_i + 1 == target_i)) { |
| 332 return false; | 332 return false; |
| 333 } | 333 } |
| 334 | 334 |
| 335 return true; | 335 return true; |
| 336 } | 336 } |
| 337 | 337 |
| 338 bool ViewManagerServiceImpl::DeleteViewImpl(ViewManagerServiceImpl* source, | 338 bool ViewManagerServiceImpl::DeleteViewImpl(ViewManagerServiceImpl* source, |
| 339 ServerView* view) { | 339 ServerView* view) { |
| 340 DCHECK(view); | 340 DCHECK(view); |
| 341 DCHECK_EQ(view->id().connection_id, id_); | 341 DCHECK_EQ(view->id().connection_id, id_); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 647 } |
| 648 | 648 |
| 649 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy( | 649 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy( |
| 650 const ServerView* view) const { | 650 const ServerView* view) const { |
| 651 ViewManagerServiceImpl* connection = | 651 ViewManagerServiceImpl* connection = |
| 652 connection_manager_->GetConnectionWithRoot(view->id()); | 652 connection_manager_->GetConnectionWithRoot(view->id()); |
| 653 return connection && connection != this; | 653 return connection && connection != this; |
| 654 } | 654 } |
| 655 | 655 |
| 656 } // namespace view_manager | 656 } // namespace view_manager |
| OLD | NEW |