()
| 15472 | /* jshint maxlen: 100 */ |
| 15473 | |
| 15474 | function $SceProvider() { |
| 15475 | var enabled = true; |
| 15476 | |
| 15477 | /** |
| 15478 | * @ngdoc method |
| 15479 | * @name $sceProvider#enabled |
| 15480 | * @kind function |
| 15481 | * |
| 15482 | * @param {boolean=} value If provided, then enables/disables SCE. |
| 15483 | * @return {boolean} true if SCE is enabled, false otherwise. |
| 15484 | * |
| 15485 | * @description |
| 15486 | * Enables/disables SCE and returns the current value. |
| 15487 | */ |
| 15488 | this.enabled = function(value) { |
| 15489 | if (arguments.length) { |
| 15490 | enabled = !!value; |
| 15491 | } |
| 15492 | return enabled; |
| 15493 | }; |
| 15494 | |
| 15495 | |
| 15496 | /* Design notes on the default implementation for SCE. |
| 15497 | * |
| 15498 | * The API contract for the SCE delegate |
| 15499 | * ------------------------------------- |
| 15500 | * The SCE delegate object must provide the following 3 methods: |
| 15501 | * |
| 15502 | * - trustAs(contextEnum, value) |
| 15503 | * This method is used to tell the SCE service that the provided value is OK to use in the |
| 15504 | * contexts specified by contextEnum. It must return an object that will be accepted by |
| 15505 | * getTrusted() for a compatible contextEnum and return this value. |
| 15506 | * |
| 15507 | * - valueOf(value) |
| 15508 | * For values that were not produced by trustAs(), return them as is. For values that were |
| 15509 | * produced by trustAs(), return the corresponding input value to trustAs. Basically, if |
| 15510 | * trustAs is wrapping the given values into some type, this operation unwraps it when given |
| 15511 | * such a value. |
| 15512 | * |
| 15513 | * - getTrusted(contextEnum, value) |
| 15514 | * This function should return the a value that is safe to use in the context specified by |
| 15515 | * contextEnum or throw and exception otherwise. |
| 15516 | * |
| 15517 | * NOTE: This contract deliberately does NOT state that values returned by trustAs() must be |
| 15518 | * opaque or wrapped in some holder object. That happens to be an implementation detail. For |
| 15519 | * instance, an implementation could maintain a registry of all trusted objects by context. In |
| 15520 | * such a case, trustAs() would return the same object that was passed in. getTrusted() would |
| 15521 | * return the same object passed in if it was found in the registry under a compatible context or |
| 15522 | * throw an exception otherwise. An implementation might only wrap values some of the time based |
| 15523 | * on some criteria. getTrusted() might return a value and not throw an exception for special |
| 15524 | * constants or objects even if not wrapped. All such implementations fulfill this contract. |
| 15525 | * |
| 15526 | * |
| 15527 | * A note on the inheritance model for SCE contexts |
| 15528 | * ------------------------------------------------ |
| 15529 | * I've used inheritance and made RESOURCE_URL wrapped types a subtype of URL wrapped types. This |
| 15530 | * is purely an implementation details. |
| 15531 | * |
nothing calls this directly
no test coverage detected