1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_
#define CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/permissions/permission_context_base.h"
#include "chrome/browser/permissions/permission_request_id.h"
#if defined(OS_CHROMEOS)
#include <map>
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/attestation/platform_verification_dialog.h"
#include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
#endif
class Profile;
namespace views {
class Widget;
}
namespace content {
class RenderViewHost;
class WebContents;
}
namespace user_prefs {
class PrefRegistrySyncable;
}
// Manages protected media identifier permissions flow, and delegates UI
// handling via PermissionQueueController.
class ProtectedMediaIdentifierPermissionContext
: public PermissionContextBase {
public:
explicit ProtectedMediaIdentifierPermissionContext(Profile* profile);
// PermissionContextBase implementation.
#if defined(OS_CHROMEOS)
void RequestPermission(content::WebContents* web_contents,
const PermissionRequestID& id,
const GURL& requesting_origin,
const BrowserPermissionCallback& callback) override;
#endif // defined(OS_CHROMEOS)
ContentSetting GetPermissionStatus(
const GURL& requesting_origin,
const GURL& embedding_origin) const override;
void CancelPermissionRequest(content::WebContents* web_contents,
const PermissionRequestID& id) override;
private:
~ProtectedMediaIdentifierPermissionContext() override;
void UpdateTabContext(const PermissionRequestID& id,
const GURL& requesting_frame,
bool allowed) override;
bool IsRestrictedToSecureOrigins() const override;
// Returns whether "Protected content" is enabled based on factors other
// than the protected media identifier content setting itself. For example,
// it can be disabled by a master switch in content settings, in incognito or
// guest mode, or by the device policy.
bool IsProtectedMediaIdentifierEnabled() const;
#if defined(OS_CHROMEOS)
void OnPlatformVerificationConsentResponse(
content::WebContents* web_contents,
const PermissionRequestID& id,
const GURL& requesting_origin,
const GURL& embedding_origin,
const BrowserPermissionCallback& callback,
chromeos::attestation::PlatformVerificationDialog::ConsentResponse
response);
// |this| is shared among multiple WebContents, so we could receive multiple
// permission requests. This map tracks all pending requests. Note that we
// only allow one request per WebContents.
typedef std::map<content::WebContents*,
std::pair<views::Widget*, PermissionRequestID>>
PendingRequestMap;
PendingRequestMap pending_requests_;
// Must be the last member, to ensure that it will be
// destroyed first, which will invalidate weak pointers
base::WeakPtrFactory<ProtectedMediaIdentifierPermissionContext> weak_factory_;
#endif
DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext);
};
#endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_
|