1// Copyright (c) 2013 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.
4
5#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_CAPTURE_CLIENT_H_
6#define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_CAPTURE_CLIENT_H_
7
8#include <set>
9
10#include "base/basictypes.h"
11#include "base/compiler_specific.h"
12#include "ui/aura/client/capture_client.h"
13#include "ui/views/views_export.h"
14
15namespace views {
16
17// A capture client which will collaborate with all other capture clients of
18// its class. When capture is changed in an instance of this capture client,
19// capture is released in all other windows.
20class VIEWS_EXPORT DesktopCaptureClient : public aura::client::CaptureClient {
21 public:
22  explicit DesktopCaptureClient(aura::RootWindow* root_window);
23  virtual ~DesktopCaptureClient();
24
25  // Overridden from client::CaptureClient:
26  virtual void SetCapture(aura::Window* window) OVERRIDE;
27  virtual void ReleaseCapture(aura::Window* window) OVERRIDE;
28  virtual aura::Window* GetCaptureWindow() OVERRIDE;
29
30 private:
31  // Called when another instance of the capture client takes capture.
32  void OnOtherCaptureClientTookCapture();
33
34  aura::RootWindow* root_window_;
35  aura::Window* capture_window_;
36
37  static std::set<DesktopCaptureClient*> live_capture_clients_;
38
39  DISALLOW_COPY_AND_ASSIGN(DesktopCaptureClient);
40};
41
42}  // namespace views
43
44#endif  // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_CAPTURE_CLIENT_H_
45