Chromium Code Reviews| 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 "chrome/browser/content_settings/permission_context_base.h" | 8 #include "chrome/browser/content_settings/permission_context_base.h" |
| 9 #include "components/content_settings/core/common/permission_request_id.h" | 9 #include "components/content_settings/core/common/permission_request_id.h" |
| 10 | 10 |
| 11 #if defined(OS_CHROMEOS) | 11 #if defined(OS_CHROMEOS) |
| 12 #include <map> | 12 #include <map> |
| 13 | 13 |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" | 15 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" |
| 16 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" | 16 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 class Profile; | 19 class Profile; |
| 20 | 20 |
| 21 namespace views { | 21 namespace views { |
| 22 class Widget; | 22 class Widget; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class RenderViewHost; | 26 class RenderViewHost; |
| 27 class WebContents; | 27 class WebContents; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace user_prefs { | |
| 31 class PrefRegistrySyncable; | |
| 32 } | |
| 33 | |
| 30 // Manages protected media identifier permissions flow, and delegates UI | 34 // Manages protected media identifier permissions flow, and delegates UI |
| 31 // handling via PermissionQueueController. | 35 // handling via PermissionQueueController. |
| 32 class ProtectedMediaIdentifierPermissionContext | 36 class ProtectedMediaIdentifierPermissionContext |
| 33 : public PermissionContextBase { | 37 : public PermissionContextBase { |
| 34 public: | 38 public: |
| 35 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile); | 39 explicit ProtectedMediaIdentifierPermissionContext(Profile* profile); |
| 36 | 40 |
| 41 #if defined(OS_CHROMEOS) | |
| 42 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs); | |
| 43 #endif | |
| 44 | |
| 37 // In addition to the base class flow checks that it is only code from | 45 // 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. | 46 // valid iframes. It also adds special logic when called through an extension. |
| 39 void RequestPermission(content::WebContents* web_contents, | 47 void RequestPermission(content::WebContents* web_contents, |
| 40 const PermissionRequestID& id, | 48 const PermissionRequestID& id, |
| 41 const GURL& requesting_origin, | 49 const GURL& requesting_origin, |
| 42 bool user_gesture, | 50 bool user_gesture, |
| 43 const BrowserPermissionCallback& callback) override; | 51 const BrowserPermissionCallback& callback) override; |
| 44 ContentSetting GetPermissionStatus( | 52 ContentSetting GetPermissionStatus( |
| 45 const GURL& requesting_origin, | 53 const GURL& requesting_origin, |
| 46 const GURL& embedding_origin) const override; | 54 const GURL& embedding_origin) const override; |
| 47 void CancelPermissionRequest(content::WebContents* web_contents, | 55 void CancelPermissionRequest(content::WebContents* web_contents, |
| 48 const PermissionRequestID& id) override; | 56 const PermissionRequestID& id) override; |
| 49 | 57 |
| 50 private: | 58 private: |
| 51 ~ProtectedMediaIdentifierPermissionContext() override; | 59 ~ProtectedMediaIdentifierPermissionContext() override; |
| 52 | 60 |
| 53 void UpdateTabContext(const PermissionRequestID& id, | 61 void UpdateTabContext(const PermissionRequestID& id, |
| 54 const GURL& requesting_frame, | 62 const GURL& requesting_frame, |
| 55 bool allowed) override; | 63 bool allowed) override; |
| 56 | 64 |
| 57 // Returns whether "Protected content" is enabled. It can be disabled by a | 65 // Returns whether "Protected content" is enabled considering factors other |
|
ddorwin
2015/03/12 21:38:54
s/considering/based on/ ?
xhwang
2015/03/13 00:54:42
Done.
| |
| 58 // user in the master switch in content settings, or by the device policy. | 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. | |
| 59 bool IsProtectedMediaIdentifierEnabled() const; | 69 bool IsProtectedMediaIdentifierEnabled() const; |
| 60 | 70 |
| 61 #if defined(OS_CHROMEOS) | 71 #if defined(OS_CHROMEOS) |
| 62 void OnPlatformVerificationResult( | 72 void OnPlatformVerificationConsentResponse( |
| 63 content::WebContents* web_contents, | 73 content::WebContents* web_contents, |
| 64 const PermissionRequestID& id, | 74 const PermissionRequestID& id, |
| 65 const GURL& requesting_origin, | 75 const GURL& requesting_origin, |
| 66 const GURL& embedding_origin, | 76 const GURL& embedding_origin, |
| 67 const BrowserPermissionCallback& callback, | 77 const BrowserPermissionCallback& callback, |
| 68 chromeos::attestation::PlatformVerificationFlow::ConsentResponse | 78 chromeos::attestation::PlatformVerificationDialog::ConsentResponse |
| 69 response); | 79 response); |
| 70 | 80 |
| 71 // |this| is shared among multiple WebContents, so we could receive multiple | 81 // |this| is shared among multiple WebContents, so we could receive multiple |
| 72 // permission requests. This map tracks all pending requests. Note that we | 82 // permission requests. This map tracks all pending requests. Note that we |
| 73 // only allow one request per WebContents. | 83 // only allow one request per WebContents. |
| 74 typedef std::map<content::WebContents*, | 84 typedef std::map<content::WebContents*, |
| 75 std::pair<views::Widget*, PermissionRequestID>> | 85 std::pair<views::Widget*, PermissionRequestID>> |
| 76 PendingRequestMap; | 86 PendingRequestMap; |
| 77 PendingRequestMap pending_requests_; | 87 PendingRequestMap pending_requests_; |
| 78 | 88 |
| 79 // Must be the last member, to ensure that it will be | 89 // Must be the last member, to ensure that it will be |
| 80 // destroyed first, which will invalidate weak pointers | 90 // destroyed first, which will invalidate weak pointers |
| 81 base::WeakPtrFactory<ProtectedMediaIdentifierPermissionContext> weak_factory_; | 91 base::WeakPtrFactory<ProtectedMediaIdentifierPermissionContext> weak_factory_; |
| 82 #endif | 92 #endif |
| 83 | 93 |
| 84 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext); | 94 DISALLOW_COPY_AND_ASSIGN(ProtectedMediaIdentifierPermissionContext); |
| 85 }; | 95 }; |
| 86 | 96 |
| 87 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ | 97 #endif // CHROME_BROWSER_MEDIA_PROTECTED_MEDIA_IDENTIFIER_PERMISSION_CONTEXT_H_ |
| OLD | NEW |