Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: chrome/browser/media/protected_media_identifier_permission_context.h

Issue 769103002: Refactor ProtectedMediaIdentifierPermissionContext to derive from PermissionContextBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup and fix compile Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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<
23 ProtectedMediaIdentifierPermissionContext> {
28 public: 24 public:
29 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile); 25 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile);
26 ~ProtectedMediaIdentifierPermissionContext() override;
30 27
31 void RequestProtectedMediaIdentifierPermission( 28 // In addition to the base class flow checks that it is only code from
32 content::WebContents* web_contents, 29 // valid iframes. It also adds special logic when called through an extension.
33 const GURL& origin, 30 void RequestPermission(content::WebContents* web_contents,
34 base::Callback<void(bool)> result_callback); 31 const PermissionRequestID& id,
32 const GURL& requesting_frame_origin,
33 bool user_gesture,
34 const BrowserPermissionCallback& callback) override;
35 35
36 void CancelProtectedMediaIdentifierPermissionRequests(int render_process_id, 36 // Withdraw an existing permission request, no op if the permission request
37 int render_view_id, 37 // was already cancelled by some other means.
38 const GURL& origin); 38 void CancelPermissionRequest(content::WebContents* web_contents,
39 const PermissionRequestID& id) override;
39 40
40 // Called on the UI thread when the profile is about to be destroyed. 41 // Called on the UI thread when the profile is about to be destroyed.
41 void ShutdownOnUIThread(); 42 void ShutdownOnUIThread();
mlamouri (slow - plz ping) 2014/12/02 22:43:30 Do you still need that? PermissionContextBase requ
timvolodine 2014/12/03 16:44:25 Done.
42 43
43 private: 44 private:
44 friend class base::RefCountedThreadSafe< 45 friend class base::RefCountedThreadSafe<
45 ProtectedMediaIdentifierPermissionContext>; 46 ProtectedMediaIdentifierPermissionContext>;
46 ~ProtectedMediaIdentifierPermissionContext();
47 47
48 Profile* profile() const { return profile_; } 48 void UpdateTabContext(const PermissionRequestID& id,
49 const GURL& requesting_frame,
50 bool allowed) override;
49 51
50 // Return an instance of the infobar queue controller, creating it 52 // This must only be accessed from the UI thread.
51 // if necessary.
52 PermissionQueueController* QueueController();
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_; 53 bool shutting_down_;
mlamouri (slow - plz ping) 2014/12/02 22:43:30 I guess that could go away too.
timvolodine 2014/12/03 16:44:25 Done.
95 scoped_ptr<PermissionQueueController> permission_queue_controller_;
96 54
97 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext); 55 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext);
98 }; 56 };
99 57
100 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ 58 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698