|
| 1 | +package gwt.material.design.client.ui.html; |
| 2 | + |
| 3 | +import com.google.gwt.dom.client.Document; |
| 4 | +import gwt.material.design.client.base.MaterialWidget; |
| 5 | +import gwt.material.design.client.base.mixin.AttributeMixin; |
| 6 | + |
| 7 | +public class IFrame extends MaterialWidget { |
| 8 | + |
| 9 | + enum Sandbox { |
| 10 | + ALL_RESTRICTIONS(""), |
| 11 | + ALLOW_FORMS("allow-forms"), |
| 12 | + ALLOW_POINTER_LOCK("allow-pointer-lock"), |
| 13 | + ALLOW_POPUPS("allow-popups"), |
| 14 | + ALLOW_SAME_ORIGIN("allow-same-origin"), |
| 15 | + ALLOW_SCRIPTS("allow-scripts"), |
| 16 | + ALLOW_TOP_NAVIGATION("allow-top-navigation"); |
| 17 | + |
| 18 | + private String restriction; |
| 19 | + |
| 20 | + Sandbox(String restriction) { |
| 21 | + this.restriction = restriction; |
| 22 | + } |
| 23 | + |
| 24 | + public String getRestriction() { |
| 25 | + return restriction; |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + private AttributeMixin<IFrame> attributeMixin; |
| 30 | + |
| 31 | + public IFrame() { |
| 32 | + super(Document.get().createIFrameElement()); |
| 33 | + setSandBoxRestriction(Sandbox.ALL_RESTRICTIONS); |
| 34 | + } |
| 35 | + |
| 36 | + public void setSandBoxRestriction(Sandbox restriction) { |
| 37 | + getAttributeMixin().setAttribute(restriction.getRestriction()); |
| 38 | + } |
| 39 | + |
| 40 | + public String getSandBoxRestriction() { |
| 41 | + return getAttributeMixin().getAttribute(); |
| 42 | + } |
| 43 | + |
| 44 | + public AttributeMixin<IFrame> getAttributeMixin() { |
| 45 | + if (attributeMixin == null) { |
| 46 | + attributeMixin = new AttributeMixin<>(this, "sandbox"); |
| 47 | + } |
| 48 | + return attributeMixin; |
| 49 | + } |
| 50 | +} |
0 commit comments