Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / aura / client / default_capture_client.cc
blob2740c9f8e19224a26cf36aa9330d214ae5b37a0c
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/aura/client/default_capture_client.h"
7 #include "ui/aura/window.h"
8 #include "ui/aura/window_event_dispatcher.h"
9 #include "ui/aura/window_tree_host.h"
11 namespace aura {
12 namespace client {
14 DefaultCaptureClient::DefaultCaptureClient(Window* root_window)
15 : root_window_(root_window),
16 capture_window_(NULL) {
17 SetCaptureClient(root_window_, this);
20 DefaultCaptureClient::~DefaultCaptureClient() {
21 SetCaptureClient(root_window_, NULL);
24 void DefaultCaptureClient::SetCapture(Window* window) {
25 if (capture_window_ == window)
26 return;
27 if (window)
28 ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(window);
30 Window* old_capture_window = capture_window_;
31 capture_window_ = window;
33 CaptureDelegate* capture_delegate = root_window_->GetHost()->dispatcher();
34 if (capture_window_)
35 capture_delegate->SetNativeCapture();
36 else
37 capture_delegate->ReleaseNativeCapture();
39 capture_delegate->UpdateCapture(old_capture_window, capture_window_);
42 void DefaultCaptureClient::ReleaseCapture(Window* window) {
43 if (capture_window_ != window)
44 return;
45 SetCapture(NULL);
48 Window* DefaultCaptureClient::GetCaptureWindow() {
49 return capture_window_;
52 Window* DefaultCaptureClient::GetGlobalCaptureWindow() {
53 return capture_window_;
56 } // namespace client
57 } // namespace aura