[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / chrome / browser / media / protected_media_identifier_permission_context.h
blobeaa53313c64c920fcd0f651b8dc4addbb62b0463
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/memory/scoped_ptr.h"
12 #include "chrome/browser/content_settings/permission_queue_controller.h"
14 class PermissionRequestID;
15 class Profile;
17 namespace content {
18 class RenderViewHost;
21 // Manages protected media identifier permissions flow, and delegates UI
22 // handling via PermissionQueueController.
23 class ProtectedMediaIdentifierPermissionContext
24 : public base::RefCountedThreadSafe<
25 ProtectedMediaIdentifierPermissionContext> {
26 public:
27 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile);
29 void RequestProtectedMediaIdentifierPermission(
30 int render_process_id,
31 int render_view_id,
32 int bridge_id,
33 int group_id,
34 const GURL& requesting_frame,
35 const base::Callback<void(bool)>& callback);
36 void CancelProtectedMediaIdentifierPermissionRequests(
37 int group_id);
39 // Called on the UI thread when the profile is about to be destroyed.
40 void ShutdownOnUIThread();
42 private:
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
50 // if necessary.
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,
59 bool allowed);
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,
67 const GURL& embedder,
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,
77 const GURL& embedder,
78 const base::Callback<void(bool)>& callback,
79 bool allowed);
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_;
90 bool shutting_down_;
91 scoped_ptr<PermissionQueueController> permission_queue_controller_;
93 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext);
96 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_