ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / media / protected_media_identifier_permission_context.h
blob4cc94f55d2beea10025b9de9975dea2da739e30c
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 "chrome/browser/content_settings/permission_context_base.h"
9 #include "components/content_settings/core/common/permission_request_id.h"
11 #if defined(OS_CHROMEOS)
12 #include <map>
14 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h"
16 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
17 #endif
19 class Profile;
21 namespace views {
22 class Widget;
25 namespace content {
26 class RenderViewHost;
27 class WebContents;
30 // Manages protected media identifier permissions flow, and delegates UI
31 // handling via PermissionQueueController.
32 class ProtectedMediaIdentifierPermissionContext
33 : public PermissionContextBase {
34 public:
35 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile);
37 // In addition to the base class flow checks that it is only code from
38 // valid iframes. It also adds special logic when called through an extension.
39 void RequestPermission(content::WebContents* web_contents,
40 const PermissionRequestID& id,
41 const GURL& requesting_origin,
42 bool user_gesture,
43 const BrowserPermissionCallback& callback) override;
44 ContentSetting GetPermissionStatus(
45 const GURL& requesting_origin,
46 const GURL& embedding_origin) const override;
47 void CancelPermissionRequest(content::WebContents* web_contents,
48 const PermissionRequestID& id) override;
50 private:
51 ~ProtectedMediaIdentifierPermissionContext() override;
53 void UpdateTabContext(const PermissionRequestID& id,
54 const GURL& requesting_frame,
55 bool allowed) override;
57 // Returns whether "Protected content" is enabled. It can be disabled by a
58 // user in the master switch in content settings, or by the device policy.
59 bool IsProtectedMediaIdentifierEnabled() const;
61 #if defined(OS_CHROMEOS)
62 void OnPlatformVerificationResult(
63 content::WebContents* web_contents,
64 const PermissionRequestID& id,
65 const GURL& requesting_origin,
66 const GURL& embedding_origin,
67 const BrowserPermissionCallback& callback,
68 chromeos::attestation::PlatformVerificationFlow::ConsentResponse
69 response);
71 // |this| is shared among multiple WebContents, so we could receive multiple
72 // permission requests. This map tracks all pending requests. Note that we
73 // only allow one request per WebContents.
74 typedef std::map<content::WebContents*,
75 std::pair<views::Widget*, PermissionRequestID>>
76 PendingRequestMap;
77 PendingRequestMap pending_requests_;
79 // Must be the last member, to ensure that it will be
80 // destroyed first, which will invalidate weak pointers
81 base::WeakPtrFactory<ProtectedMediaIdentifierPermissionContext> weak_factory_;
82 #endif
84 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext);
87 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_