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/memory/scoped_ptr.h"
12 #include "chrome/browser/content_settings/permission_queue_controller.h"
14 class PermissionRequestID
;
21 // Manages protected media identifier permissions flow, and delegates UI
22 // handling via PermissionQueueController.
23 class ProtectedMediaIdentifierPermissionContext
24 : public base::RefCountedThreadSafe
<
25 ProtectedMediaIdentifierPermissionContext
> {
27 explicit ProtectedMediaIdentifierPermissionContext(Profile
* profile
);
29 void RequestProtectedMediaIdentifierPermission(
30 int render_process_id
,
34 const GURL
& requesting_frame
,
35 const base::Callback
<void(bool)>& callback
);
36 void CancelProtectedMediaIdentifierPermissionRequests(
39 // Called on the UI thread when the profile is about to be destroyed.
40 void ShutdownOnUIThread();
43 friend class base::RefCountedThreadSafe
<
44 ProtectedMediaIdentifierPermissionContext
>;
45 ~ProtectedMediaIdentifierPermissionContext();
47 Profile
* profile() const { return profile_
; }
49 // Return an instance of the infobar queue controller, creating it
51 PermissionQueueController
* QueueController();
53 // Notifies whether or not the corresponding bridge is allowed to use
54 // protected media identifier via
55 // SetProtectedMediaIdentifierPermissionResponse(). Called on the UI thread.
56 void NotifyPermissionSet(const PermissionRequestID
& id
,
57 const GURL
& requesting_frame
,
58 const base::Callback
<void(bool)>& callback
,
61 // Decide whether the protected media identifier permission should be granted.
62 // Calls PermissionDecided if permission can be decided non-interactively,
63 // or NotifyPermissionSet if permission decided by presenting an
64 // infobar to the user. Called on the UI thread.
65 void DecidePermission(const PermissionRequestID
& id
,
66 const GURL
& requesting_frame
,
68 content::RenderViewHost
* rvh
,
69 const base::Callback
<void(bool)>& callback
);
71 // Called when permission is granted without interactively asking
72 // the user. Can be overridden to introduce additional UI flow.
73 // Should ultimately ensure that NotifyPermissionSet is called.
74 // Called on the UI thread.
75 void PermissionDecided(const PermissionRequestID
& id
,
76 const GURL
& requesting_frame
,
78 const base::Callback
<void(bool)>& callback
,
81 // Create an PermissionQueueController. overridden in derived classes to
82 // provide additional UI flow. Called on the UI thread.
83 PermissionQueueController
* CreateQueueController();
85 // Removes pending InfoBar requests that match |group_id|.
86 void CancelPendingInfobarRequests(int group_id
);
88 // These must only be accessed from the UI thread.
89 Profile
* const profile_
;
91 scoped_ptr
<PermissionQueueController
> permission_queue_controller_
;
93 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext
);
96 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_