| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef UI_AURA_MUS_CAPTURE_SYNCHRONIZER_H_ | 5 #ifndef UI_AURA_MUS_CAPTURE_SYNCHRONIZER_H_ |
| 6 #define UI_AURA_MUS_CAPTURE_SYNCHRONIZER_H_ | 6 #define UI_AURA_MUS_CAPTURE_SYNCHRONIZER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace aura { | 21 namespace aura { |
| 22 class CaptureSynchronizerDelegate; | 22 class CaptureSynchronizerDelegate; |
| 23 class WindowMus; | 23 class WindowMus; |
| 24 | 24 |
| 25 namespace client { | 25 namespace client { |
| 26 class CaptureClient; | 26 class CaptureClient; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // CaptureSynchronizer is resonsible for keeping capture in sync between aura | 29 // CaptureSynchronizer is resonsible for keeping capture in sync between aura |
| 30 // and the mus server. | 30 // and the mus server. |
| 31 class AURA_EXPORT CaptureSynchronizer : public WindowObserver, | 31 class CaptureSynchronizer : public WindowObserver, |
| 32 public client::CaptureClientObserver { | 32 public client::CaptureClientObserver { |
| 33 public: | 33 public: |
| 34 CaptureSynchronizer(CaptureSynchronizerDelegate* delegate, | 34 CaptureSynchronizer(CaptureSynchronizerDelegate* delegate, |
| 35 ui::mojom::WindowTree* window_tree); | 35 ui::mojom::WindowTree* window_tree, |
| 36 client::CaptureClient* capture_client); |
| 36 ~CaptureSynchronizer() override; | 37 ~CaptureSynchronizer() override; |
| 37 | 38 |
| 38 WindowMus* capture_window() { return capture_window_; } | 39 WindowMus* capture_window() { return capture_window_; } |
| 39 | 40 |
| 40 // Called when the server side wants to change capture to |window|. | 41 // Called when the server side wants to change capture to |window|. |
| 41 void SetCaptureFromServer(WindowMus* window); | 42 void SetCaptureFromServer(WindowMus* window); |
| 42 | 43 |
| 43 // Called when the |capture_client| has been set or will be unset. | |
| 44 void AttachToCaptureClient(client::CaptureClient* capture_client); | |
| 45 void DetachFromCaptureClient(client::CaptureClient* capture_client); | |
| 46 | |
| 47 private: | 44 private: |
| 48 // Internal implementation for capture changes. Adds/removes observer as | 45 // Internal implementation for capture changes. Adds/removes observer as |
| 49 // necessary and sets |capture_window_| to |window|. | 46 // necessary and sets |capture_window_| to |window|. |
| 50 void SetCaptureWindow(WindowMus* window); | 47 void SetCaptureWindow(WindowMus* window); |
| 51 | 48 |
| 52 // WindowObserver: | 49 // WindowObserver: |
| 53 void OnWindowDestroying(Window* window) override; | 50 void OnWindowDestroying(Window* window) override; |
| 54 | 51 |
| 55 // client::CaptureClientObserver: | 52 // client::CaptureClientObserver: |
| 56 void OnCaptureChanged(Window* lost_capture, Window* gained_capture) override; | 53 void OnCaptureChanged(Window* lost_capture, Window* gained_capture) override; |
| 57 | 54 |
| 58 CaptureSynchronizerDelegate* delegate_; | 55 CaptureSynchronizerDelegate* delegate_; |
| 59 ui::mojom::WindowTree* window_tree_; | 56 ui::mojom::WindowTree* window_tree_; |
| 57 client::CaptureClient* capture_client_; |
| 60 | 58 |
| 61 // Window that currently has capture. | 59 // Window that currently has capture. |
| 62 WindowMus* capture_window_ = nullptr; | 60 WindowMus* capture_window_ = nullptr; |
| 63 | 61 |
| 64 // Used when setting capture from the server to avoid setting capture back | 62 // Used when setting capture from the server to avoid setting capture back |
| 65 // on the server. If |setting_capture_| is true SetCaptureFromServer() was | 63 // on the server. If |setting_capture_| is true SetCaptureFromServer() was |
| 66 // called and |window_setting_capture_to_| is the window capture is being | 64 // called and |window_setting_capture_to_| is the window capture is being |
| 67 // set on. | 65 // set on. |
| 68 bool setting_capture_ = false; | 66 bool setting_capture_ = false; |
| 69 WindowMus* window_setting_capture_to_ = nullptr; | 67 WindowMus* window_setting_capture_to_ = nullptr; |
| 70 | 68 |
| 71 DISALLOW_COPY_AND_ASSIGN(CaptureSynchronizer); | 69 DISALLOW_COPY_AND_ASSIGN(CaptureSynchronizer); |
| 72 }; | 70 }; |
| 73 | 71 |
| 74 } // namespace aura | 72 } // namespace aura |
| 75 | 73 |
| 76 #endif // UI_AURA_MUS_CAPTURE_SYNCHRONIZER_H_ | 74 #endif // UI_AURA_MUS_CAPTURE_SYNCHRONIZER_H_ |
| OLD | NEW |