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_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_
6 #define CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_
11 #include "base/callback_forward.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/content_settings/permission_queue_controller.h"
15 class PermissionRequestID
;
23 // Manages protected media identifier permissions flow, and delegates UI
24 // handling via PermissionQueueController.
25 class ProtectedMediaIdentifierPermissionContext
26 : public base::RefCountedThreadSafe
<
27 ProtectedMediaIdentifierPermissionContext
> {
29 explicit ProtectedMediaIdentifierPermissionContext(Profile
* profile
);
31 void RequestProtectedMediaIdentifierPermission(
32 content::WebContents
* web_contents
,
34 base::Callback
<void(bool)> result_callback
,
35 base::Closure
* cancel_callback
);
37 // Called on the UI thread when the profile is about to be destroyed.
38 void ShutdownOnUIThread();
41 friend class base::RefCountedThreadSafe
<
42 ProtectedMediaIdentifierPermissionContext
>;
43 ~ProtectedMediaIdentifierPermissionContext();
45 Profile
* profile() const { return profile_
; }
47 // Return an instance of the infobar queue controller, creating it
49 PermissionQueueController
* QueueController();
51 void CancelProtectedMediaIdentifierPermissionRequests(
52 int render_process_id
,
56 // Notifies whether or not the corresponding bridge is allowed to use
57 // protected media identifier via
58 // SetProtectedMediaIdentifierPermissionResponse(). Called on the UI thread.
59 void NotifyPermissionSet(const PermissionRequestID
& id
,
61 const base::Callback
<void(bool)>& callback
,
64 // Decide whether the protected media identifier permission should be granted.
65 // Calls PermissionDecided if permission can be decided non-interactively,
66 // or NotifyPermissionSet if permission decided by presenting an
67 // infobar to the user. Called on the UI thread.
68 void DecidePermission(const PermissionRequestID
& id
,
71 content::RenderViewHost
* rvh
,
72 const base::Callback
<void(bool)>& callback
);
74 // Called when permission is granted without interactively asking
75 // the user. Can be overridden to introduce additional UI flow.
76 // Should ultimately ensure that NotifyPermissionSet is called.
77 // Called on the UI thread.
78 void PermissionDecided(const PermissionRequestID
& id
,
81 const base::Callback
<void(bool)>& callback
,
84 // Create an PermissionQueueController. overridden in derived classes to
85 // provide additional UI flow. Called on the UI thread.
86 PermissionQueueController
* CreateQueueController();
88 // Removes pending InfoBar requests that match |bridge_id| from the tab
89 // given by |render_process_id| and |render_view_id|.
90 void CancelPendingInfobarRequests(int render_process_id
,
94 // These must only be accessed from the UI thread.
95 Profile
* const profile_
;
97 scoped_ptr
<PermissionQueueController
> permission_queue_controller_
;
99 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext
);
102 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_