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)
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"
30 // Manages protected media identifier permissions flow, and delegates UI
31 // handling via PermissionQueueController.
32 class ProtectedMediaIdentifierPermissionContext
33 : public PermissionContextBase
{
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
,
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
;
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
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
>>
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_
;
84 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext
);
87 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_