Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chrome / browser / media / protected_media_identifier_permission_context.h
blob473aa4e8f5d42112d9ed54e9dfd1c5947b9b6e15
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_
8 #include <map>
9 #include <string>
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;
16 class Profile;
18 namespace content {
19 class RenderViewHost;
20 class WebContents;
23 // Manages protected media identifier permissions flow, and delegates UI
24 // handling via PermissionQueueController.
25 class ProtectedMediaIdentifierPermissionContext
26 : public base::RefCountedThreadSafe<
27 ProtectedMediaIdentifierPermissionContext> {
28 public:
29 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile);
31 void RequestProtectedMediaIdentifierPermission(
32 content::WebContents* web_contents,
33 const GURL& origin,
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();
40 private:
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
48 // if necessary.
49 PermissionQueueController* QueueController();
51 void CancelProtectedMediaIdentifierPermissionRequests(
52 int render_process_id,
53 int render_view_id,
54 const GURL& origin);
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,
60 const GURL& origin,
61 const base::Callback<void(bool)>& callback,
62 bool allowed);
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,
69 const GURL& origin,
70 const GURL& embedder,
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,
79 const GURL& origin,
80 const GURL& embedder,
81 const base::Callback<void(bool)>& callback,
82 bool allowed);
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,
91 int render_view_id,
92 const GURL& origin);
94 // These must only be accessed from the UI thread.
95 Profile* const profile_;
96 bool shutting_down_;
97 scoped_ptr<PermissionQueueController> permission_queue_controller_;
99 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext);
102 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_