OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ |
6 #define CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ | 6 #define CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ |
7 | 7 |
8 #include <map> | 8 #include "chrome/browser/content_settings/permission_context_base.h" |
9 #include <string> | |
10 | |
11 #include "base/callback_forward.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "chrome/browser/content_settings/permission_queue_controller.h" | |
14 | 9 |
15 class PermissionRequestID; | 10 class PermissionRequestID; |
16 class Profile; | 11 class Profile; |
17 | 12 |
18 namespace content { | 13 namespace content { |
19 class RenderViewHost; | 14 class RenderViewHost; |
20 class WebContents; | 15 class WebContents; |
21 } | 16 } |
22 | 17 |
23 // Manages protected media identifier permissions flow, and delegates UI | 18 // Manages protected media identifier permissions flow, and delegates UI |
24 // handling via PermissionQueueController. | 19 // handling via PermissionQueueController. |
25 class ProtectedMediaIdentifierPermissionContext | 20 class ProtectedMediaIdentifierPermissionContext |
26 : public base::RefCountedThreadSafe< | 21 : public PermissionContextBase, |
27 ProtectedMediaIdentifierPermissionContext> { | 22 public base::RefCountedThreadSafe< |
Miguel Garcia
2014/12/03 18:57:37
Do you still need this RefCounted inheritance? Per
timvolodine
2014/12/04 17:22:26
Done.
| |
23 ProtectedMediaIdentifierPermissionContext> { | |
28 public: | 24 public: |
29 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile); | 25 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile); |
30 | 26 |
31 void RequestProtectedMediaIdentifierPermission( | 27 // In addition to the base class flow checks that it is only code from |
32 content::WebContents* web_contents, | 28 // valid iframes. It also adds special logic when called through an extension. |
33 const GURL& origin, | 29 void RequestPermission(content::WebContents* web_contents, |
34 base::Callback<void(bool)> result_callback); | 30 const PermissionRequestID& id, |
35 | 31 const GURL& requesting_frame_origin, |
36 void CancelProtectedMediaIdentifierPermissionRequests(int render_process_id, | 32 bool user_gesture, |
37 int render_view_id, | 33 const BrowserPermissionCallback& callback) override; |
38 const GURL& origin); | |
39 | |
40 // Called on the UI thread when the profile is about to be destroyed. | |
41 void ShutdownOnUIThread(); | |
42 | 34 |
43 private: | 35 private: |
44 friend class base::RefCountedThreadSafe< | 36 friend class base::RefCountedThreadSafe< |
45 ProtectedMediaIdentifierPermissionContext>; | 37 ProtectedMediaIdentifierPermissionContext>; |
46 ~ProtectedMediaIdentifierPermissionContext(); | |
47 | 38 |
48 Profile* profile() const { return profile_; } | 39 ~ProtectedMediaIdentifierPermissionContext() override; |
49 | 40 |
50 // Return an instance of the infobar queue controller, creating it | 41 void UpdateTabContext(const PermissionRequestID& id, |
51 // if necessary. | 42 const GURL& requesting_frame, |
52 PermissionQueueController* QueueController(); | 43 bool allowed) override; |
53 | |
54 // Notifies whether or not the corresponding bridge is allowed to use | |
55 // protected media identifier via | |
56 // SetProtectedMediaIdentifierPermissionResponse(). Called on the UI thread. | |
57 void NotifyPermissionSet(const PermissionRequestID& id, | |
58 const GURL& origin, | |
59 const base::Callback<void(bool)>& callback, | |
60 bool allowed); | |
61 | |
62 // Decide whether the protected media identifier permission should be granted. | |
63 // Calls PermissionDecided if permission can be decided non-interactively, | |
64 // or NotifyPermissionSet if permission decided by presenting an | |
65 // infobar to the user. Called on the UI thread. | |
66 void DecidePermission(const PermissionRequestID& id, | |
67 const GURL& origin, | |
68 const GURL& embedder, | |
69 content::RenderViewHost* rvh, | |
70 const base::Callback<void(bool)>& callback); | |
71 | |
72 // Called when permission is granted without interactively asking | |
73 // the user. Can be overridden to introduce additional UI flow. | |
74 // Should ultimately ensure that NotifyPermissionSet is called. | |
75 // Called on the UI thread. | |
76 void PermissionDecided(const PermissionRequestID& id, | |
77 const GURL& origin, | |
78 const GURL& embedder, | |
79 const base::Callback<void(bool)>& callback, | |
80 bool allowed); | |
81 | |
82 // Create an PermissionQueueController. overridden in derived classes to | |
83 // provide additional UI flow. Called on the UI thread. | |
84 PermissionQueueController* CreateQueueController(); | |
85 | |
86 // Removes pending InfoBar requests that match |bridge_id| from the tab | |
87 // given by |render_process_id| and |render_view_id|. | |
88 void CancelPendingInfobarRequests(int render_process_id, | |
89 int render_view_id, | |
90 const GURL& origin); | |
91 | |
92 // These must only be accessed from the UI thread. | |
93 Profile* const profile_; | |
94 bool shutting_down_; | |
95 scoped_ptr<PermissionQueueController> permission_queue_controller_; | |
96 | 44 |
97 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext); | 45 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext); |
98 }; | 46 }; |
99 | 47 |
100 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ | 48 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ |
OLD | NEW |