Fire an error if a pref used in the UI is missing once all prefs are fetched.
[chromium-blink-merge.git] / chrome / browser / media / protected_media_identifier_permission_context.h
blobd5b2139cc8a30853378360617ae26da0d7604bfc
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 #if defined(OS_CHROMEOS)
42 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs);
43 #endif
45 // In addition to the base class flow checks that it is only code from
46 // valid iframes. It also adds special logic when called through an extension.
47 void RequestPermission(content::WebContents* web_contents,
48 const PermissionRequestID& id,
49 const GURL& requesting_origin,
50 bool user_gesture,
51 const BrowserPermissionCallback& callback) override;
52 ContentSetting GetPermissionStatus(
53 const GURL& requesting_origin,
54 const GURL& embedding_origin) const override;
55 void CancelPermissionRequest(content::WebContents* web_contents,
56 const PermissionRequestID& id) override;
58 private:
59 ~ProtectedMediaIdentifierPermissionContext() override;
61 void UpdateTabContext(const PermissionRequestID& id,
62 const GURL& requesting_frame,
63 bool allowed) override;
65 // Returns whether "Protected content" is enabled based on factors other
66 // than the protected media identifier content setting itself. For example,
67 // it can be disabled by a master switch in content settings, in incognito or
68 // guest mode, or by the device policy.
69 bool IsProtectedMediaIdentifierEnabled() const;
71 #if defined(OS_CHROMEOS)
72 void OnPlatformVerificationConsentResponse(
73 content::WebContents* web_contents,
74 const PermissionRequestID& id,
75 const GURL& requesting_origin,
76 const GURL& embedding_origin,
77 const BrowserPermissionCallback& callback,
78 chromeos::attestation::PlatformVerificationDialog::ConsentResponse
79 response);
81 // |this| is shared among multiple WebContents, so we could receive multiple
82 // permission requests. This map tracks all pending requests. Note that we
83 // only allow one request per WebContents.
84 typedef std::map<content::WebContents*,
85 std::pair<views::Widget*, PermissionRequestID>>
86 PendingRequestMap;
87 PendingRequestMap pending_requests_;
89 // Must be the last member, to ensure that it will be
90 // destroyed first, which will invalidate weak pointers
91 base::WeakPtrFactory<ProtectedMediaIdentifierPermissionContext> weak_factory_;
92 #endif
94 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext);
97 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_