Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 WebFeaturePolicy_h | 5 #ifndef WebFeaturePolicy_h |
| 6 #define WebFeaturePolicy_h | 6 #define WebFeaturePolicy_h |
| 7 | 7 |
| 8 #include "WebCommon.h" | 8 #include "WebCommon.h" |
| 9 #include "WebSecurityOrigin.h" | 9 #include "WebSecurityOrigin.h" |
| 10 #include "WebString.h" | 10 #include "WebString.h" |
| 11 #include "WebVector.h" | 11 #include "WebVector.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 // These values map to the features which can be controlled by Feature Policy. | 15 // These values map to the features which can be controlled by Feature Policy. |
| 16 // TODO(iclelland): Link to the spec where the behaviour for each of these is | 16 // TODO(iclelland): Link to the spec where the behaviour for each of these is |
|
Rick Byers
2017/03/27 21:19:46
nit: can you remove the TODO now?
| |
| 17 // defined. | 17 // defined. |
| 18 // | |
| 19 // Below are the features currently defined in the spec: | |
| 20 // https://wicg.github.io/feature-policy/#defined-features | |
| 21 // Camera | |
| 22 // Eme | |
| 23 // Fullscreen | |
| 24 // Geolocation | |
| 25 // Microphone | |
| 26 // Midi | |
| 27 // Payment | |
| 28 // Speaker | |
| 29 // Vibrate | |
| 30 // Below are the features currently implemented in Blink: | |
|
Rick Byers
2017/03/27 21:19:46
I was initially confused by this (if the others ar
| |
| 31 // Fullscreen | |
| 32 // Payment | |
| 33 // Vibrate | |
| 18 enum class WebFeaturePolicyFeature { | 34 enum class WebFeaturePolicyFeature { |
| 19 NotFound = 0, | 35 NotFound = 0, |
| 36 // Controls access to video input devices. | |
| 37 Camera, | |
| 38 // Controls whether navigator.requestMediaKeySystemAccess is allowed. | |
| 39 Eme, | |
| 40 // Controls whether Element.requestFullscreen is allowed. | |
| 41 Fullscreen, | |
| 42 // Controls access to Geolocation interface. | |
| 43 Geolocation, | |
| 44 // Controls access to audio input devices. | |
| 45 Microphone, | |
| 46 // Controls access to requestMIDIAccess method. | |
| 47 MidiFeature, | |
| 48 // Controls access to PaymentRequest interface. | |
| 49 Payment, | |
| 50 // Controls access to audio output devices. | |
| 51 Speaker, | |
| 52 // Controls access to navigator.vibrate method. | |
| 53 Vibrate, | |
| 20 // Controls access to document.cookie attribute. | 54 // Controls access to document.cookie attribute. |
| 21 DocumentCookie, | 55 DocumentCookie, |
| 22 // Contols access to document.domain attribute. | 56 // Contols access to document.domain attribute. |
| 23 DocumentDomain, | 57 DocumentDomain, |
| 24 // Controls access to document.write and document.writeln methods. | 58 // Controls access to document.write and document.writeln methods. |
| 25 DocumentWrite, | 59 DocumentWrite, |
| 26 // Controls whether Element.requestFullscreen is allowed. | |
| 27 Fullscreen, | |
| 28 // Controls access to Geolocation interface. | |
| 29 Geolocation, | |
| 30 // Controls access to requestMIDIAccess method. | |
| 31 MidiFeature, | |
| 32 // Controls access to Notification interface. | 60 // Controls access to Notification interface. |
| 33 Notifications, | 61 Notifications, |
| 34 // Controls access to PaymentRequest interface. | |
| 35 Payment, | |
| 36 // Controls access to PushManager interface. | 62 // Controls access to PushManager interface. |
| 37 Push, | 63 Push, |
| 38 // Controls whether synchronous script elements will run. | 64 // Controls whether synchronous script elements will run. |
| 39 SyncScript, | 65 SyncScript, |
| 40 // Controls use of synchronous XMLHTTPRequest API. | 66 // Controls use of synchronous XMLHTTPRequest API. |
| 41 SyncXHR, | 67 SyncXHR, |
| 42 // Controls access to NavigatorUserMedia interface. | |
| 43 Usermedia, | |
| 44 // Controls access to navigator.vibrate method. | |
| 45 Vibrate, | |
| 46 // Controls access to RTCPeerConnection interface. | 68 // Controls access to RTCPeerConnection interface. |
| 47 WebRTC, | 69 WebRTC, |
| 48 LAST_FEATURE = WebRTC | 70 LAST_FEATURE = WebRTC |
| 49 }; | 71 }; |
| 50 | 72 |
| 51 struct BLINK_PLATFORM_EXPORT WebParsedFeaturePolicyDeclaration { | 73 struct BLINK_PLATFORM_EXPORT WebParsedFeaturePolicyDeclaration { |
| 52 WebParsedFeaturePolicyDeclaration() : matchesAllOrigins(false) {} | 74 WebParsedFeaturePolicyDeclaration() : matchesAllOrigins(false) {} |
| 53 WebFeaturePolicyFeature feature; | 75 WebFeaturePolicyFeature feature; |
| 54 bool matchesAllOrigins; | 76 bool matchesAllOrigins; |
| 55 WebVector<WebSecurityOrigin> origins; | 77 WebVector<WebSecurityOrigin> origins; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 66 virtual ~WebFeaturePolicy() {} | 88 virtual ~WebFeaturePolicy() {} |
| 67 | 89 |
| 68 // Returns whether or not the given feature is enabled for the origin of the | 90 // Returns whether or not the given feature is enabled for the origin of the |
| 69 // document that owns the policy. | 91 // document that owns the policy. |
| 70 virtual bool IsFeatureEnabled(blink::WebFeaturePolicyFeature) const = 0; | 92 virtual bool IsFeatureEnabled(blink::WebFeaturePolicyFeature) const = 0; |
| 71 }; | 93 }; |
| 72 | 94 |
| 73 } // namespace blink | 95 } // namespace blink |
| 74 | 96 |
| 75 #endif // WebFeaturePolicy_h | 97 #endif // WebFeaturePolicy_h |
| OLD | NEW |