OLD | NEW |
(Empty) | |
| 1 // Copyright 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 CHROME_BROWSER_CHROMEOS_DISPLAY_OUTPUT_PROTECTION_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DISPLAY_OUTPUT_PROTECTION_DELEGATE_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "ui/aura/window.h" |
| 10 #include "ui/aura/window_observer.h" |
| 11 #include "ui/display/chromeos/display_configurator.h" |
| 12 |
| 13 namespace chromeos { |
| 14 |
| 15 // A class to query output protection status and/or enable output protection. |
| 16 // All methods except constructor should be invoked in UI thread. |
| 17 class OutputProtectionDelegate : public aura::WindowObserver { |
| 18 public: |
| 19 typedef base::Callback<void(bool /* success */, |
| 20 uint32_t /* link_mask */, |
| 21 uint32_t /* protection_mask*/)> |
| 22 QueryStatusCallback; |
| 23 typedef base::Callback<void(bool /* success */)> EnableProtectionCallback; |
| 24 |
| 25 OutputProtectionDelegate(int render_process_id, int render_frame_id); |
| 26 ~OutputProtectionDelegate() override; |
| 27 |
| 28 // aura::WindowObserver overrides. |
| 29 void OnWindowHierarchyChanged( |
| 30 const aura::WindowObserver::HierarchyChangeParams& params) override; |
| 31 void OnWindowDestroying(aura::Window* window) override; |
| 32 |
| 33 void QueryStatus(const QueryStatusCallback& callback); |
| 34 void EnableProtection(uint32_t desired_method_mask, |
| 35 const EnableProtectionCallback& callback); |
| 36 |
| 37 private: |
| 38 ui::DisplayConfigurator::ContentProtectionClientId GetClientId(); |
| 39 |
| 40 void QueryStatusComplete( |
| 41 const QueryStatusCallback& callback, |
| 42 const ui::DisplayConfigurator::QueryProtectionResponse& response); |
| 43 void EnableProtectionComplete(const EnableProtectionCallback& callback, |
| 44 bool success); |
| 45 |
| 46 // Used to lookup the WebContents associated with the render frame. |
| 47 int render_process_id_; |
| 48 int render_frame_id_; |
| 49 |
| 50 // Native window being observed. |
| 51 aura::Window* window_; |
| 52 |
| 53 ui::DisplayConfigurator::ContentProtectionClientId client_id_; |
| 54 |
| 55 // The display id which the renderer currently uses. |
| 56 int64 display_id_; |
| 57 |
| 58 // The last desired method mask. Will enable this mask on new display if |
| 59 // renderer changes display. |
| 60 uint32_t desired_method_mask_; |
| 61 |
| 62 base::WeakPtrFactory<OutputProtectionDelegate> weak_ptr_factory_; |
| 63 }; |
| 64 |
| 65 } // namespace chromeos |
| 66 |
| 67 #endif // CHROME_BROWSER_CHROMEOS_DISPLAY_OUTPUT_PROTECTION_DELEGATE_H_ |
OLD | NEW |