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.
5 #ifndef CHROME_BROWSER_CHROMEOS_DISPLAY_OUTPUT_PROTECTION_DELEGATE_H_
6 #define CHROME_BROWSER_CHROMEOS_DISPLAY_OUTPUT_PROTECTION_DELEGATE_H_
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"
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
{
19 typedef base::Callback
<void(bool /* success */,
20 uint32_t /* link_mask */,
21 uint32_t /* protection_mask*/)>
23 typedef base::Callback
<void(bool /* success */)> EnableProtectionCallback
;
25 OutputProtectionDelegate(int render_process_id
, int render_frame_id
);
26 ~OutputProtectionDelegate() override
;
28 // aura::WindowObserver overrides.
29 void OnWindowHierarchyChanged(
30 const aura::WindowObserver::HierarchyChangeParams
& params
) override
;
31 void OnWindowDestroying(aura::Window
* window
) override
;
33 void QueryStatus(const QueryStatusCallback
& callback
);
34 void EnableProtection(uint32_t desired_method_mask
,
35 const EnableProtectionCallback
& callback
);
38 ui::DisplayConfigurator::ContentProtectionClientId
GetClientId();
40 void QueryStatusComplete(
41 const QueryStatusCallback
& callback
,
42 const ui::DisplayConfigurator::QueryProtectionResponse
& response
);
43 void EnableProtectionComplete(const EnableProtectionCallback
& callback
,
46 // Used to lookup the WebContents associated with the render frame.
47 int render_process_id_
;
50 // Native window being observed.
51 aura::Window
* window_
;
53 ui::DisplayConfigurator::ContentProtectionClientId client_id_
;
55 // The display id which the renderer currently uses.
58 // The last desired method mask. Will enable this mask on new display if
59 // renderer changes display.
60 uint32_t desired_method_mask_
;
62 base::WeakPtrFactory
<OutputProtectionDelegate
> weak_ptr_factory_
;
65 } // namespace chromeos
67 #endif // CHROME_BROWSER_CHROMEOS_DISPLAY_OUTPUT_PROTECTION_DELEGATE_H_