Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / media / protected_media_identifier_permission_context.h
blob1c438ec05f0bf604bce8dfd4e99bff90cc31cc29
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 namespace user_prefs {
31 class PrefRegistrySyncable;
34 // Manages protected media identifier permissions flow, and delegates UI
35 // handling via PermissionQueueController.
36 class ProtectedMediaIdentifierPermissionContext
37 : public PermissionContextBase {
38 public:
39 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile);
41 // In addition to the base class flow checks that it is only code from
42 // valid iframes. It also adds special logic when called through an extension.
43 void RequestPermission(content::WebContents* web_contents,
44 const PermissionRequestID& id,
45 const GURL& requesting_origin,
46 bool user_gesture,
47 const BrowserPermissionCallback& callback) override;
48 ContentSetting GetPermissionStatus(
49 const GURL& requesting_origin,
50 const GURL& embedding_origin) const override;
51 void CancelPermissionRequest(content::WebContents* web_contents,
52 const PermissionRequestID& id) override;
54 private:
55 ~ProtectedMediaIdentifierPermissionContext() override;
57 void UpdateTabContext(const PermissionRequestID& id,
58 const GURL& requesting_frame,
59 bool allowed) override;
61 // Returns whether "Protected content" is enabled based on factors other
62 // than the protected media identifier content setting itself. For example,
63 // it can be disabled by a master switch in content settings, in incognito or
64 // guest mode, or by the device policy.
65 bool IsProtectedMediaIdentifierEnabled() const;
67 #if defined(OS_CHROMEOS)
68 void OnPlatformVerificationConsentResponse(
69 content::WebContents* web_contents,
70 const PermissionRequestID& id,
71 const GURL& requesting_origin,
72 const GURL& embedding_origin,
73 const BrowserPermissionCallback& callback,
74 chromeos::attestation::PlatformVerificationDialog::ConsentResponse
75 response);
77 // |this| is shared among multiple WebContents, so we could receive multiple
78 // permission requests. This map tracks all pending requests. Note that we
79 // only allow one request per WebContents.
80 typedef std::map<content::WebContents*,
81 std::pair<views::Widget*, PermissionRequestID>>
82 PendingRequestMap;
83 PendingRequestMap pending_requests_;
85 // Must be the last member, to ensure that it will be
86 // destroyed first, which will invalidate weak pointers
87 base::WeakPtrFactory<ProtectedMediaIdentifierPermissionContext> weak_factory_;
88 #endif
90 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext);
93 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_