()
| 13954 | /* jshint maxlen: 100 */ |
| 13955 | |
| 13956 | function $SceProvider() { |
| 13957 | var enabled = true; |
| 13958 | |
| 13959 | /** |
| 13960 | * @ngdoc method |
| 13961 | * @name $sceProvider#enabled |
| 13962 | * @kind function |
| 13963 | * |
| 13964 | * @param {boolean=} value If provided, then enables/disables SCE. |
| 13965 | * @return {boolean} true if SCE is enabled, false otherwise. |
| 13966 | * |
| 13967 | * @description |
| 13968 | * Enables/disables SCE and returns the current value. |
| 13969 | */ |
| 13970 | this.enabled = function (value) { |
| 13971 | if (arguments.length) { |
| 13972 | enabled = !!value; |
| 13973 | } |
| 13974 | return enabled; |
| 13975 | }; |
| 13976 | |
| 13977 | |
| 13978 | /* Design notes on the default implementation for SCE. |
| 13979 | * |
| 13980 | * The API contract for the SCE delegate |
| 13981 | * ------------------------------------- |
| 13982 | * The SCE delegate object must provide the following 3 methods: |
| 13983 | * |
| 13984 | * - trustAs(contextEnum, value) |
| 13985 | * This method is used to tell the SCE service that the provided value is OK to use in the |
| 13986 | * contexts specified by contextEnum. It must return an object that will be accepted by |
| 13987 | * getTrusted() for a compatible contextEnum and return this value. |
| 13988 | * |
| 13989 | * - valueOf(value) |
| 13990 | * For values that were not produced by trustAs(), return them as is. For values that were |
| 13991 | * produced by trustAs(), return the corresponding input value to trustAs. Basically, if |
| 13992 | * trustAs is wrapping the given values into some type, this operation unwraps it when given |
| 13993 | * such a value. |
| 13994 | * |
| 13995 | * - getTrusted(contextEnum, value) |
| 13996 | * This function should return the a value that is safe to use in the context specified by |
| 13997 | * contextEnum or throw and exception otherwise. |
| 13998 | * |
| 13999 | * NOTE: This contract deliberately does NOT state that values returned by trustAs() must be |
| 14000 | * opaque or wrapped in some holder object. That happens to be an implementation detail. For |
| 14001 | * instance, an implementation could maintain a registry of all trusted objects by context. In |
| 14002 | * such a case, trustAs() would return the same object that was passed in. getTrusted() would |
| 14003 | * return the same object passed in if it was found in the registry under a compatible context or |
| 14004 | * throw an exception otherwise. An implementation might only wrap values some of the time based |
| 14005 | * on some criteria. getTrusted() might return a value and not throw an exception for special |
| 14006 | * constants or objects even if not wrapped. All such implementations fulfill this contract. |
| 14007 | * |
| 14008 | * |
| 14009 | * A note on the inheritance model for SCE contexts |
| 14010 | * ------------------------------------------------ |
| 14011 | * I've used inheritance and made RESOURCE_URL wrapped types a subtype of URL wrapped types. This |
| 14012 | * is purely an implementation details. |
| 14013 | * |
nothing calls this directly
no test coverage detected