function getTrusted(type, maybeTrusted) {
      if (maybeTrusted === null || maybeTrusted === undefined || maybeTrusted === '') {
        return maybeTrusted;
      }
      var constructor = (byType.hasOwnProperty(type) ? byType[type] : null);
      if (constructor && maybeTrusted instanceof constructor) {
        return maybeTrusted.$$unwrapTrustedValue();
      }
      // If we get here, then we may only take one of two actions.
      // 1. sanitize the value for the requested type, or
      // 2. throw an exception.
      if (type === SCE_CONTEXTS.RESOURCE_URL) {
        if (isResourceUrlAllowedByPolicy(maybeTrusted)) {
          return maybeTrusted;
        } else {
          throw $sceMinErr('insecurl',
              'Blocked loading resource from url not allowed by $sceDelegate policy.  URL: {0}',
              maybeTrusted.toString());
        }
      } else if (type === SCE_CONTEXTS.HTML) {
        return htmlSanitizer(maybeTrusted);
      }
      throw $sceMinErr('unsafe', 'Attempting to use an unsafe value in a safe context.');
    }
@ngdoc method
@name ng.$sceDelegate#getTrusted
@methodOf ng.$sceDelegate

@description
Takes the result of a {@link ng.$sceDelegate#methods_trustAs `$sceDelegate.trustAs`} call and
returns the originally supplied value if the queried context type is a supertype of the
created type.  If this condition isn't satisfied, throws an exception.

@param {string} type The kind of context in which this value is to be used.
@param {*} maybeTrusted The result of a prior {@link ng.$sceDelegate#methods_trustAs
    `$sceDelegate.trustAs`} call.
@returns {*} The value the was originally provided to {@link ng.$sceDelegate#methods_trustAs
    `$sceDelegate.trustAs`} if valid in this context.  Otherwise, throws an exception.