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

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: add #ifdef OS_CHROMEOS and clean-up includes 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> {
28 public: 22 public:
29 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile); 23 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile);
30 24
31 void RequestProtectedMediaIdentifierPermission( 25 // In addition to the base class flow checks that it is only code from
32 content::WebContents* web_contents, 26 // valid iframes. It also adds special logic when called through an extension.
33 const GURL& origin, 27 void RequestPermission(content::WebContents* web_contents,
34 base::Callback<void(bool)> result_callback); 28 const PermissionRequestID& id,
35 29 const GURL& requesting_frame_origin,
36 void CancelProtectedMediaIdentifierPermissionRequests(int render_process_id, 30 bool user_gesture,
37 int render_view_id, 31 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 32
43 private: 33 private:
44 friend class base::RefCountedThreadSafe< 34 ~ProtectedMediaIdentifierPermissionContext() override;
45 ProtectedMediaIdentifierPermissionContext>;
46 ~ProtectedMediaIdentifierPermissionContext();
47 35
48 Profile* profile() const { return profile_; } 36 void UpdateTabContext(const PermissionRequestID& id,
49 37 const GURL& requesting_frame,
50 // Return an instance of the infobar queue controller, creating it 38 bool allowed) override;
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_;
95 scoped_ptr<PermissionQueueController> permission_queue_controller_;
96 39
97 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext); 40 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext);
98 }; 41 };
99 42
100 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ 43 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698