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