()
| 17982 | /* jshint maxlen: 100 */ |
| 17983 | |
| 17984 | function $SceProvider() { |
| 17985 | var enabled = true; |
| 17986 | |
| 17987 | /** |
| 17988 | * @ngdoc method |
| 17989 | * @name $sceProvider#enabled |
| 17990 | * @kind function |
| 17991 | * |
| 17992 | * @param {boolean=} value If provided, then enables/disables SCE. |
| 17993 | * @return {boolean} true if SCE is enabled, false otherwise. |
| 17994 | * |
| 17995 | * @description |
| 17996 | * Enables/disables SCE and returns the current value. |
| 17997 | */ |
| 17998 | this.enabled = function(value) { |
| 17999 | if (arguments.length) { |
| 18000 | enabled = !!value; |
| 18001 | } |
| 18002 | return enabled; |
| 18003 | }; |
| 18004 | |
| 18005 | |
| 18006 | /* Design notes on the default implementation for SCE. |
| 18007 | * |
| 18008 | * The API contract for the SCE delegate |
| 18009 | * ------------------------------------- |
| 18010 | * The SCE delegate object must provide the following 3 methods: |
| 18011 | * |
| 18012 | * - trustAs(contextEnum, value) |
| 18013 | * This method is used to tell the SCE service that the provided value is OK to use in the |
| 18014 | * contexts specified by contextEnum. It must return an object that will be accepted by |
| 18015 | * getTrusted() for a compatible contextEnum and return this value. |
| 18016 | * |
| 18017 | * - valueOf(value) |
| 18018 | * For values that were not produced by trustAs(), return them as is. For values that were |
| 18019 | * produced by trustAs(), return the corresponding input value to trustAs. Basically, if |
| 18020 | * trustAs is wrapping the given values into some type, this operation unwraps it when given |
| 18021 | * such a value. |
| 18022 | * |
| 18023 | * - getTrusted(contextEnum, value) |
| 18024 | * This function should return the a value that is safe to use in the context specified by |
| 18025 | * contextEnum or throw and exception otherwise. |
| 18026 | * |
| 18027 | * NOTE: This contract deliberately does NOT state that values returned by trustAs() must be |
| 18028 | * opaque or wrapped in some holder object. That happens to be an implementation detail. For |
| 18029 | * instance, an implementation could maintain a registry of all trusted objects by context. In |
| 18030 | * such a case, trustAs() would return the same object that was passed in. getTrusted() would |
| 18031 | * return the same object passed in if it was found in the registry under a compatible context or |
| 18032 | * throw an exception otherwise. An implementation might only wrap values some of the time based |
| 18033 | * on some criteria. getTrusted() might return a value and not throw an exception for special |
| 18034 | * constants or objects even if not wrapped. All such implementations fulfill this contract. |
| 18035 | * |
| 18036 | * |
| 18037 | * A note on the inheritance model for SCE contexts |
| 18038 | * ------------------------------------------------ |
| 18039 | * I've used inheritance and made RESOURCE_URL wrapped types a subtype of URL wrapped types. This |
| 18040 | * is purely an implementation details. |
| 18041 | * |
nothing calls this directly
no test coverage detected