001package Torello.Browser.BrowserAPI; 002 003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 004// Java-HTML Imports 005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 006 007import Torello.Browser.*; 008import Torello.Browser.helper.*; 009import Torello.Browser.JavaScriptAPI.*; 010import Torello.JSON.*; 011 012import Torello.Java.ReadOnly.ReadOnlyList; 013import Torello.Java.ReadOnly.ReadOnlyArrayList; 014 015import Torello.JavaDoc.Annotations.StaticFunctional; 016import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg; 017 018 019// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 020// JDK Imports 021// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 022 023import javax.json.JsonObject; 024import javax.json.JsonValue; 025 026/** 027 * <SPAN CLASS=COPIEDJDK><B>A domain for interacting with Cast, Presentation API, and Remote Playback API 028 * functionalities.</B></SPAN> 029 * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.CODE_GEN_NOTE> 030 */ 031@StaticFunctional@JDHeaderBackgroundImg(EmbedTagFileID="CDP.WOOD_PLANK_NOTE") 032public class Cast 033{ 034 // No Pubic Constructors 035 private Cast() { } 036 037 038 039 // ******************************************************************************************** 040 // ******************************************************************************************** 041 // Basic Types 042 // ******************************************************************************************** 043 // ******************************************************************************************** 044 045 046 /** 047 * <CODE>[No Description Provided by Google]</CODE> 048 * 049 * <EMBED CLASS=globalDefs DATA-DOMAIN=Cast DATA-API=BrowserAPI> 050 */ 051 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI") 052 public static class Sink 053 extends BaseType<Sink> 054 implements java.io.Serializable 055 { 056 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 057 protected static final long serialVersionUID = 1; 058 059 private static final NestedHelper<Cast.Sink> singleton = 060 Torello.Browser.BrowserAPI.NestedHelpers.Types. 061 Cast$$Sink$$.singleton; 062 063 /** <CODE>[No Description Provided by Google]</CODE> */ 064 public final String name; 065 066 /** <CODE>[No Description Provided by Google]</CODE> */ 067 public final String id; 068 069 /** 070 * Text describing the current session. Present only if there is an active 071 * session on the sink. 072 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 073 */ 074 public final String session; 075 076 /** Constructor. Please review this class' fields for documentation. */ 077 public Sink(ReadOnlyList<Boolean> isPresent, String name, String id, String session) 078 { 079 super(singleton, Domains.Cast, "Sink", 3); 080 081 this.name = name; 082 this.id = id; 083 this.session = session; 084 085 this.isPresent = (isPresent == null) 086 ? singleton.generateIsPresentList(this) 087 : THROWS.check(isPresent, 3, "Cast.Sink"); 088 } 089 090 /** Creates an instance of this class from a {@link JsonObject}.*/ 091 public static Sink fromJSON(JsonObject jo) 092 { return singleton.fromJSON(jo); } 093 094 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 095 public static NestedDescriptor<Sink> descriptor() 096 { return singleton.descriptor(); } 097 } 098 099 100 // ******************************************************************************************** 101 // ******************************************************************************************** 102 // Event Types 103 // ******************************************************************************************** 104 // ******************************************************************************************** 105 106 107 /** 108 * This is fired whenever the outstanding issue/error message changes. 109 * |issueMessage| is empty if there is no issue. 110 * 111 * <EMBED CLASS=globalDefs DATA-DOMAIN=Cast DATA-API=BrowserAPI> 112 */ 113 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 114 public static class issueUpdated 115 extends BrowserEvent<issueUpdated> 116 implements java.io.Serializable 117 { 118 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 119 protected static final long serialVersionUID = 1; 120 121 private static final NestedHelper<Cast.issueUpdated> singleton = 122 Torello.Browser.BrowserAPI.NestedHelpers.Events. 123 Cast$$issueUpdated$$.singleton; 124 125 /** <CODE>[No Description Provided by Google]</CODE> */ 126 public final String issueMessage; 127 128 /** Constructor. Please review this class' fields for documentation. */ 129 public issueUpdated(ReadOnlyList<Boolean> isPresent, String issueMessage) 130 { 131 super(singleton, Domains.Cast, "issueUpdated", 1); 132 133 this.issueMessage = issueMessage; 134 135 this.isPresent = (isPresent == null) 136 ? singleton.generateIsPresentList(this) 137 : THROWS.check(isPresent, 1, "Cast.issueUpdated"); 138 } 139 140 /** Creates an instance of this class from a {@link JsonObject}.*/ 141 public static issueUpdated fromJSON(JsonObject jo) 142 { return singleton.fromJSON(jo); } 143 144 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 145 public static NestedDescriptor<issueUpdated> descriptor() 146 { return singleton.descriptor(); } 147 } 148 149 /** 150 * This is fired whenever the list of available sinks changes. A sink is a 151 * device or a software surface that you can cast to. 152 * 153 * <EMBED CLASS=globalDefs DATA-DOMAIN=Cast DATA-API=BrowserAPI> 154 */ 155 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 156 public static class sinksUpdated 157 extends BrowserEvent<sinksUpdated> 158 implements java.io.Serializable 159 { 160 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 161 protected static final long serialVersionUID = 1; 162 163 private static final NestedHelper<Cast.sinksUpdated> singleton = 164 Torello.Browser.BrowserAPI.NestedHelpers.Events. 165 Cast$$sinksUpdated$$.singleton; 166 167 /** <CODE>[No Description Provided by Google]</CODE> */ 168 public final Cast.Sink[] sinks; 169 170 /** Constructor. Please review this class' fields for documentation. */ 171 public sinksUpdated(ReadOnlyList<Boolean> isPresent, Sink[] sinks) 172 { 173 super(singleton, Domains.Cast, "sinksUpdated", 1); 174 175 this.sinks = sinks; 176 177 this.isPresent = (isPresent == null) 178 ? singleton.generateIsPresentList(this) 179 : THROWS.check(isPresent, 1, "Cast.sinksUpdated"); 180 } 181 182 /** Creates an instance of this class from a {@link JsonObject}.*/ 183 public static sinksUpdated fromJSON(JsonObject jo) 184 { return singleton.fromJSON(jo); } 185 186 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 187 public static NestedDescriptor<sinksUpdated> descriptor() 188 { return singleton.descriptor(); } 189 } 190 191 192 193 194 // ******************************************************************************************** 195 // ******************************************************************************************** 196 // Commands 197 // ******************************************************************************************** 198 // ******************************************************************************************** 199 200 201 /** 202 * Stops observing for sinks and issues. 203 * 204 * @return An instance of <CODE>{@link Script}<Void></CODE> 205 * 206 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 207 * browser receives the invocation-request. 208 * 209 * <BR /><BR /><DIV CLASS=JDHint> 210 * This Browser-Function <I>does not have</I> a return-value. You may choose to 211 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 212 * the Browser Function has run to completion. 213 * </DIV> 214 */ 215 public static Script<Void> disable() 216 { 217 // Ultra-Simple Request JSON - Because this method has no parameters 218 final String requestJSON = "{\"method\":\"Cast.disable\"}"; 219 220 return Script.NO_RET(Domains.Cast, "disable", requestJSON); 221 } 222 223 /** 224 * Starts observing for sinks that can be used for tab mirroring, and if set, 225 * sinks compatible with |presentationUrl| as well. When sinks are found, a 226 * |sinksUpdated| event is fired. 227 * Also starts observing for issue messages. When an issue is added or removed, 228 * an |issueUpdated| event is fired. 229 * 230 * @param presentationUrl - 231 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 232 * 233 * @return An instance of <CODE>{@link Script}<Void></CODE> 234 * 235 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 236 * browser receives the invocation-request. 237 * 238 * <BR /><BR /><DIV CLASS=JDHint> 239 * This Browser-Function <I>does not have</I> a return-value. You may choose to 240 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 241 * the Browser Function has run to completion. 242 * </DIV> 243 */ 244 public static Script<Void> enable(String presentationUrl) 245 { 246 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 247 final String requestJSON = WriteJSON.get 248 (CDPTypes.STRING, "presentationUrl", true, "Cast.enable", presentationUrl); 249 250 return Script.NO_RET(Domains.Cast, "enable", requestJSON); 251 } 252 253 /** 254 * Sets a sink to be used when the web page requests the browser to choose a 255 * sink via Presentation API, Remote Playback API, or Cast SDK. 256 * 257 * @param sinkName - 258 * 259 * @return An instance of <CODE>{@link Script}<Void></CODE> 260 * 261 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 262 * browser receives the invocation-request. 263 * 264 * <BR /><BR /><DIV CLASS=JDHint> 265 * This Browser-Function <I>does not have</I> a return-value. You may choose to 266 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 267 * the Browser Function has run to completion. 268 * </DIV> 269 */ 270 public static Script<Void> setSinkToUse(String sinkName) 271 { 272 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 273 final String requestJSON = WriteJSON.get 274 (CDPTypes.STRING, "sinkName", false, "Cast.setSinkToUse", sinkName); 275 276 return Script.NO_RET(Domains.Cast, "setSinkToUse", requestJSON); 277 } 278 279 /** 280 * Starts mirroring the desktop to the sink. 281 * 282 * @param sinkName - 283 * 284 * @return An instance of <CODE>{@link Script}<Void></CODE> 285 * 286 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 287 * browser receives the invocation-request. 288 * 289 * <BR /><BR /><DIV CLASS=JDHint> 290 * This Browser-Function <I>does not have</I> a return-value. You may choose to 291 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 292 * the Browser Function has run to completion. 293 * </DIV> 294 */ 295 public static Script<Void> startDesktopMirroring(String sinkName) 296 { 297 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 298 final String requestJSON = WriteJSON.get 299 (CDPTypes.STRING, "sinkName", false, "Cast.startDesktopMirroring", sinkName); 300 301 return Script.NO_RET(Domains.Cast, "startDesktopMirroring", requestJSON); 302 } 303 304 /** 305 * Starts mirroring the tab to the sink. 306 * 307 * @param sinkName - 308 * 309 * @return An instance of <CODE>{@link Script}<Void></CODE> 310 * 311 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 312 * browser receives the invocation-request. 313 * 314 * <BR /><BR /><DIV CLASS=JDHint> 315 * This Browser-Function <I>does not have</I> a return-value. You may choose to 316 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 317 * the Browser Function has run to completion. 318 * </DIV> 319 */ 320 public static Script<Void> startTabMirroring(String sinkName) 321 { 322 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 323 final String requestJSON = WriteJSON.get 324 (CDPTypes.STRING, "sinkName", false, "Cast.startTabMirroring", sinkName); 325 326 return Script.NO_RET(Domains.Cast, "startTabMirroring", requestJSON); 327 } 328 329 /** 330 * Stops the active Cast session on the sink. 331 * 332 * @param sinkName - 333 * 334 * @return An instance of <CODE>{@link Script}<Void></CODE> 335 * 336 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 337 * browser receives the invocation-request. 338 * 339 * <BR /><BR /><DIV CLASS=JDHint> 340 * This Browser-Function <I>does not have</I> a return-value. You may choose to 341 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 342 * the Browser Function has run to completion. 343 * </DIV> 344 */ 345 public static Script<Void> stopCasting(String sinkName) 346 { 347 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 348 final String requestJSON = WriteJSON.get 349 (CDPTypes.STRING, "sinkName", false, "Cast.stopCasting", sinkName); 350 351 return Script.NO_RET(Domains.Cast, "stopCasting", requestJSON); 352 } 353 354 355}