/** * Converts a {@link TrustedResourceUrl} into a Soy {@link SanitizedContent} of kind * TRUSTED_RESOURCE_URI. */ public static SanitizedContent fromTrustedResourceUrl(TrustedResourceUrl url) { return SanitizedContent.create( url.getTrustedResourceUrlString(), ContentKind.TRUSTED_RESOURCE_URI); }
/** * Converts a {@link TrustedResourceUrl} into a Soy {@link SanitizedContent} of kind * TRUSTED_RESOURCE_URI. */ public static SanitizedContent fromTrustedResourceUrl(TrustedResourceUrl url) { return SanitizedContent.create( url.getTrustedResourceUrlString(), ContentKind.TRUSTED_RESOURCE_URI); }
/** Sets the {@code href} attribute for this element. */ public SafeHtmlBuilder setHref(TrustedResourceUrl value) { hrefValueContract = AttributeContract.TRUSTED_RESOURCE_URL; return setAttribute("href", value.getTrustedResourceUrlString()); }
/** Sets the {@code src} attribute for this element. */ public SafeHtmlBuilder setSrc(TrustedResourceUrl value) { return setAttribute("src", value.getTrustedResourceUrlString()); }
/** * Converts a {@link TrustedResourceUrlProto} into a Soy {@link SanitizedContent} of kind * TRUSTED_RESOURCE_URI. */ public static SanitizedContent fromTrustedResourceUrlProto(TrustedResourceUrlProto url) { return SanitizedContent.create( TrustedResourceUrls.fromProto(url).getTrustedResourceUrlString(), ContentKind.TRUSTED_RESOURCE_URI); }
/** * Converts a {@link TrustedResourceUrlProto} into a Soy {@link SanitizedContent} of kind * TRUSTED_RESOURCE_URI. */ public static SanitizedContent fromTrustedResourceUrlProto(TrustedResourceUrlProto url) { return SanitizedContent.create( TrustedResourceUrls.fromProto(url).getTrustedResourceUrlString(), ContentKind.TRUSTED_RESOURCE_URI); }
/** * Creates a <style type="text/css" src="<i>url</i>"><style> where the * {@code src} attribute points to the given {@code trustedResourceUrl}. */ public static SafeHtml fromStyleUrl(TrustedResourceUrl trustedResourceUrl) { String escapedUrl = htmlEscapeInternal(trustedResourceUrl.getTrustedResourceUrlString()); return create("<style type=\"text/css\" src=\"" + escapedUrl + "\"></style>"); }
/** * Creates a <script defer type="text/javascript" src="<i>url</i>"><script> where the * {@code src} attribute points to the given {@code trustedResourceUrl}. */ public static SafeHtml fromScriptUrlDeferred(TrustedResourceUrl trustedResourceUrl) { String escapedUrl = htmlEscapeInternal(trustedResourceUrl.getTrustedResourceUrlString()); return create("<script defer type=\"text/javascript\" src=\"" + escapedUrl + "\"></script>"); }
/** * Creates a <script type="text/javascript" src="<i>url</i>"><script> where the * {@code src} attribute points to the given {@code trustedResourceUrl}. */ public static SafeHtml fromScriptUrl(TrustedResourceUrl trustedResourceUrl) { String escapedUrl = htmlEscapeInternal(trustedResourceUrl.getTrustedResourceUrlString()); return create("<script type=\"text/javascript\" src=\"" + escapedUrl + "\"></script>"); }
/** * Creates a <script defer type="text/javascript" src="<i>url</i>"><script> where the * {@code src} attribute points to the given {@code trustedResourceUrl}. * The tag has a nonce attribute populated from the provided CSP nonce value. */ public static SafeHtml fromScriptUrlWithCspNonceDeferred(TrustedResourceUrl trustedResourceUrl, String cspNonce) { String escapedUrl = htmlEscapeInternal(trustedResourceUrl.getTrustedResourceUrlString()); return create("<script defer type=\"text/javascript\" nonce=\"" + htmlEscapeInternal(cspNonce) + "\" src=\"" + escapedUrl + "\"></script>"); }
/** * Creates a <script type="text/javascript" src="<i>url</i>"><script> where the * {@code src} attribute points to the given {@code trustedResourceUrl}. * The tag has a nonce attribute populated from the provided CSP nonce value. */ public static SafeHtml fromScriptUrlWithCspNonce(TrustedResourceUrl trustedResourceUrl, String cspNonce) { String escapedUrl = htmlEscapeInternal(trustedResourceUrl.getTrustedResourceUrlString()); return create("<script type=\"text/javascript\" nonce=\"" + htmlEscapeInternal(cspNonce) + "\" src=\"" + escapedUrl + "\"></script>"); }
/** * Serializes a TrustedResourceUrl into its opaque protocol message representation. * * <p>Protocol message forms of this type are intended to be opaque. The fields of the returned * protocol message should be considered encapsulated and are not intended for direct inspection * or manipulation. Protocol messages can be converted back into a TrustedResourceUrl using * {@link #fromProto(TrustedResourceUrlProto)}. */ public static TrustedResourceUrlProto toProto(TrustedResourceUrl url) { return TrustedResourceUrlProto.newBuilder() .setPrivateDoNotAccessOrElseTrustedResourceUrlWrappedValue( url.getTrustedResourceUrlString()) .build(); }