/** * Serializes a SafeStyle 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 SafeStyle using * {@link #fromProto(SafeStyleProto)}. */ public static SafeStyleProto toProto(SafeStyle style) { return SafeStyleProto.newBuilder() .setPrivateDoNotAccessOrElseSafeStyleWrappedValue(style.getSafeStyleString()).build(); }
/** * Serializes a SafeScript 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 SafeScript using * {@link #fromProto(SafeScriptProto)}. */ public static SafeScriptProto toProto(SafeScript script) { return SafeScriptProto.newBuilder() .setPrivateDoNotAccessOrElseSafeScriptWrappedValue(script.getSafeScriptString()).build(); }
/** * Serializes a SafeHtml 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 SafeHtml using * {@link #fromProto(SafeHtmlProto)}. */ public static SafeHtmlProto toProto(SafeHtml safeHtml) { return SafeHtmlProto.newBuilder().setPrivateDoNotAccessOrElseSafeHtmlWrappedValue( safeHtml.getSafeHtmlString()).build(); }
/** * 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>"); }
/** * Serializes a SafeUrl 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 SafeUrl using * {@link #fromProto(SafeUrlProto)}. */ public static SafeUrlProto toProto(SafeUrl url) { return SafeUrlProto.newBuilder() .setPrivateDoNotAccessOrElseSafeUrlWrappedValue(url.getSafeUrlString()) .build(); }
public Builder mergeFrom(com.google.common.html.types.SafeScriptProto other) { if (other == com.google.common.html.types.SafeScriptProto.getDefaultInstance()) return this; if (other.hasPrivateDoNotAccessOrElseSafeScriptWrappedValue()) { bitField0_ |= 0x00000001; privateDoNotAccessOrElseSafeScriptWrappedValue_ = other.privateDoNotAccessOrElseSafeScriptWrappedValue_; onChanged(); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
public Builder mergeFrom(com.google.common.html.types.SafeHtmlProto other) { if (other == com.google.common.html.types.SafeHtmlProto.getDefaultInstance()) return this; if (other.hasPrivateDoNotAccessOrElseSafeHtmlWrappedValue()) { bitField0_ |= 0x00000001; privateDoNotAccessOrElseSafeHtmlWrappedValue_ = other.privateDoNotAccessOrElseSafeHtmlWrappedValue_; onChanged(); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
/** Sets the {@code href} attribute for this element. */ public SafeHtmlBuilder setHref(TrustedResourceUrl value) { hrefValueContract = AttributeContract.TRUSTED_RESOURCE_URL; return setAttribute("href", value.getTrustedResourceUrlString()); }
public com.google.common.html.types.SafeScriptProto build() { com.google.common.html.types.SafeScriptProto result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
public com.google.common.html.types.SafeStyleSheetProto build() { com.google.common.html.types.SafeStyleSheetProto result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
public com.google.common.html.types.SafeUrlProto build() { com.google.common.html.types.SafeUrlProto result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
public com.google.common.html.types.SafeStyleProto buildPartial() { com.google.common.html.types.SafeStyleProto result = new com.google.common.html.types.SafeStyleProto(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.privateDoNotAccessOrElseSafeStyleWrappedValue_ = privateDoNotAccessOrElseSafeStyleWrappedValue_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
public com.google.common.html.types.SafeStyleSheetProto buildPartial() { com.google.common.html.types.SafeStyleSheetProto result = new com.google.common.html.types.SafeStyleSheetProto(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.privateDoNotAccessOrElseSafeStyleSheetWrappedValue_ = privateDoNotAccessOrElseSafeStyleSheetWrappedValue_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
/** * HTML-escapes and appends {@code text} to this element's content. * * @throws IllegalStateException if this builder represents a void element */ public SafeHtmlBuilder escapeAndAppendContent(String text) { // htmlEscape() unicode coerces in non-portable version. return appendContent(SafeHtmls.htmlEscape(text)); }
public com.google.common.html.types.SafeScriptProto buildPartial() { com.google.common.html.types.SafeScriptProto result = new com.google.common.html.types.SafeScriptProto(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.privateDoNotAccessOrElseSafeScriptWrappedValue_ = privateDoNotAccessOrElseSafeScriptWrappedValue_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
public com.google.common.html.types.SafeHtmlProto buildPartial() { com.google.common.html.types.SafeHtmlProto result = new com.google.common.html.types.SafeHtmlProto(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.privateDoNotAccessOrElseSafeHtmlWrappedValue_ = privateDoNotAccessOrElseSafeHtmlWrappedValue_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
/** * 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}. * 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>"); }
/** * 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>"); }