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

Side by Side Diff: components/mus/view_tree_impl.cc

Issue 1352043005: mus: Implement Window Server Capture Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test Created 5 years, 3 months 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
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 "components/mus/view_tree_impl.h" 5 #include "components/mus/view_tree_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 "components/mus/connection_manager.h" 9 #include "components/mus/connection_manager.h"
10 #include "components/mus/default_access_policy.h" 10 #include "components/mus/default_access_policy.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 void ViewTreeImpl::ProcessFocusChanged(const ServerView* old_focused_view, 312 void ViewTreeImpl::ProcessFocusChanged(const ServerView* old_focused_view,
313 const ServerView* new_focused_view) { 313 const ServerView* new_focused_view) {
314 const ServerView* view = 314 const ServerView* view =
315 new_focused_view ? access_policy_->GetViewForFocusChange(new_focused_view) 315 new_focused_view ? access_policy_->GetViewForFocusChange(new_focused_view)
316 : nullptr; 316 : nullptr;
317 client()->OnViewFocused(view ? ViewIdToTransportId(view->id()) 317 client()->OnViewFocused(view ? ViewIdToTransportId(view->id())
318 : ViewIdToTransportId(ViewId())); 318 : ViewIdToTransportId(ViewId()));
319 } 319 }
320 320
321 void ViewTreeImpl::ProcessLostCapture(const ServerView* old_captured_view) {
322 client()->OnLostCapture(ViewIdToTransportId(old_captured_view->id()));
323 }
324
321 bool ViewTreeImpl::IsViewKnown(const ServerView* view) const { 325 bool ViewTreeImpl::IsViewKnown(const ServerView* view) const {
322 return known_views_.count(ViewIdToTransportId(view->id())) > 0; 326 return known_views_.count(ViewIdToTransportId(view->id())) > 0;
323 } 327 }
324 328
325 bool ViewTreeImpl::CanReorderView(const ServerView* view, 329 bool ViewTreeImpl::CanReorderView(const ServerView* view,
326 const ServerView* relative_view, 330 const ServerView* relative_view,
327 OrderDirection direction) const { 331 OrderDirection direction) const {
328 if (!view || !relative_view) 332 if (!view || !relative_view)
329 return false; 333 return false;
330 334
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 564 }
561 565
562 void ViewTreeImpl::GetViewTree( 566 void ViewTreeImpl::GetViewTree(
563 Id view_id, 567 Id view_id,
564 const Callback<void(Array<ViewDataPtr>)>& callback) { 568 const Callback<void(Array<ViewDataPtr>)>& callback) {
565 std::vector<const ServerView*> views( 569 std::vector<const ServerView*> views(
566 GetViewTree(ViewIdFromTransportId(view_id))); 570 GetViewTree(ViewIdFromTransportId(view_id)));
567 callback.Run(ViewsToViewDatas(views)); 571 callback.Run(ViewsToViewDatas(views));
568 } 572 }
569 573
574 void ViewTreeImpl::SetCapture(Id view_id,
575 const Callback<void(bool)>& callback) {
576 ServerView* view = GetView(ViewIdFromTransportId(view_id));
577 bool success = view && access_policy_->CanSetCapture(view);
578 if (success) {
579 ViewTreeHostImpl* host = GetHost();
580 if (host)
581 host->SetCapture(view);
582 }
583 callback.Run(success);
584 }
585
570 void ViewTreeImpl::SetViewBounds(Id view_id, 586 void ViewTreeImpl::SetViewBounds(Id view_id,
571 mojo::RectPtr bounds, 587 mojo::RectPtr bounds,
572 const Callback<void(bool)>& callback) { 588 const Callback<void(bool)>& callback) {
573 ServerView* view = GetView(ViewIdFromTransportId(view_id)); 589 ServerView* view = GetView(ViewIdFromTransportId(view_id));
574 const bool success = view && access_policy_->CanSetViewBounds(view); 590 const bool success = view && access_policy_->CanSetViewBounds(view);
575 if (success) { 591 if (success) {
576 ConnectionManager::ScopedChange change(this, connection_manager_, false); 592 ConnectionManager::ScopedChange change(this, connection_manager_, false);
577 view->SetBounds(bounds.To<gfx::Rect>()); 593 view->SetBounds(bounds.To<gfx::Rect>());
578 } 594 }
579 callback.Run(success); 595 callback.Run(success);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 ViewTreeImpl* connection = 689 ViewTreeImpl* connection =
674 connection_manager_->GetConnectionWithRoot(view->id()); 690 connection_manager_->GetConnectionWithRoot(view->id());
675 return connection && connection != this; 691 return connection && connection != this;
676 } 692 }
677 693
678 bool ViewTreeImpl::IsDescendantOfEmbedRoot(const ServerView* view) { 694 bool ViewTreeImpl::IsDescendantOfEmbedRoot(const ServerView* view) {
679 return is_embed_root_ && root_ && GetView(*root_)->Contains(view); 695 return is_embed_root_ && root_ && GetView(*root_)->Contains(view);
680 } 696 }
681 697
682 } // namespace mus 698 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698