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

Side by Side Diff: components/mus/ws/window_tree_impl.cc

Issue 1352043005: mus: Implement Window Server Capture Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added capture unit tests Created 5 years, 1 month 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/ws/window_tree_impl.h" 5 #include "components/mus/ws/window_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/ws/connection_manager.h" 9 #include "components/mus/ws/connection_manager.h"
10 #include "components/mus/ws/default_access_policy.h" 10 #include "components/mus/ws/default_access_policy.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 WindowTreeHostImpl* host = GetHost(); 396 WindowTreeHostImpl* host = GetHost();
397 if (!host || !host->window_manager()) 397 if (!host || !host->window_manager())
398 return false; 398 return false;
399 // Requests coming from the WM should not be routed through the WM again. 399 // Requests coming from the WM should not be routed through the WM again.
400 bool is_wm = host->GetWindowTree() == this; 400 bool is_wm = host->GetWindowTree() == this;
401 if (is_wm) 401 if (is_wm)
402 return false; 402 return false;
403 return true; 403 return true;
404 } 404 }
405 405
406 void WindowTreeImpl::ProcessLostCapture(
407 const ServerWindow* old_capture_window) {
408 client()->OnLostCapture(WindowIdToTransportId(old_capture_window->id()));
409 }
410
406 bool WindowTreeImpl::IsWindowKnown(const ServerWindow* window) const { 411 bool WindowTreeImpl::IsWindowKnown(const ServerWindow* window) const {
407 return known_windows_.count(WindowIdToTransportId(window->id())) > 0; 412 return known_windows_.count(WindowIdToTransportId(window->id())) > 0;
408 } 413 }
409 414
410 bool WindowTreeImpl::CanReorderWindow(const ServerWindow* window, 415 bool WindowTreeImpl::CanReorderWindow(const ServerWindow* window,
411 const ServerWindow* relative_window, 416 const ServerWindow* relative_window,
412 mojom::OrderDirection direction) const { 417 mojom::OrderDirection direction) const {
413 if (!window || !relative_window) 418 if (!window || !relative_window)
414 return false; 419 return false;
415 420
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 695 }
691 696
692 void WindowTreeImpl::GetWindowTree( 697 void WindowTreeImpl::GetWindowTree(
693 Id window_id, 698 Id window_id,
694 const Callback<void(Array<mojom::WindowDataPtr>)>& callback) { 699 const Callback<void(Array<mojom::WindowDataPtr>)>& callback) {
695 std::vector<const ServerWindow*> windows( 700 std::vector<const ServerWindow*> windows(
696 GetWindowTree(WindowIdFromTransportId(window_id))); 701 GetWindowTree(WindowIdFromTransportId(window_id)));
697 callback.Run(WindowsToWindowDatas(windows)); 702 callback.Run(WindowsToWindowDatas(windows));
698 } 703 }
699 704
705 void WindowTreeImpl::SetCapture(uint32_t change_id, Id window_id) {
706 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id));
707 WindowTreeHostImpl* host = GetHost();
708 bool success = window && access_policy_->CanSetCapture(window) && host &&
709 access_policy_->CanSetCapture(host->GetCaptureWindow());
710 if (success) {
711 Operation op(this, connection_manager_, OperationType::SET_CAPTURE);
712 host->SetCapture(window);
713 }
714 client_->OnChangeCompleted(change_id, success);
715 }
716
717 void WindowTreeImpl::ReleaseCapture(uint32_t change_id, Id window_id) {
718 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id));
719 WindowTreeHostImpl* host = GetHost();
720 bool success =
721 window && host && access_policy_->CanSetCapture(host->GetCaptureWindow());
722 if (success) {
723 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE);
724 host->SetCapture(nullptr);
725 }
726 client_->OnChangeCompleted(change_id, success);
727 }
728
700 void WindowTreeImpl::SetWindowBounds(uint32_t change_id, 729 void WindowTreeImpl::SetWindowBounds(uint32_t change_id,
701 Id window_id, 730 Id window_id,
702 mojo::RectPtr bounds) { 731 mojo::RectPtr bounds) {
703 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id)); 732 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id));
704 if (window && ShouldRouteToWindowManager(window)) { 733 if (window && ShouldRouteToWindowManager(window)) {
705 const uint32_t wm_change_id = 734 const uint32_t wm_change_id =
706 connection_manager_->GenerateWindowManagerChangeId(this, change_id); 735 connection_manager_->GenerateWindowManagerChangeId(this, change_id);
707 GetHost()->GetWindowTree()->client_->WmSetBounds(wm_change_id, window_id, 736 GetHost()->GetWindowTree()->client_->WmSetBounds(wm_change_id, window_id,
708 bounds.Pass()); 737 bounds.Pass());
709 return; 738 return;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 return connection && connection != this; 896 return connection && connection != this;
868 } 897 }
869 898
870 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) { 899 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) {
871 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window); 900 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window);
872 } 901 }
873 902
874 } // namespace ws 903 } // namespace ws
875 904
876 } // namespace mus 905 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698