Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

A Passible Advertising WebIDL

shawngao5 edited this page Sep 3, 2014 · 25 revisions

1.Interface

interface xwalk {
  attribute Experimental experimental;
}
interface experimental {
  attribute Advertising ad;
}

1.1 Attributes

ad of type Advertising, readonly

  • The object that exposes the Advertising functionality.

2. Advertising interface

The Advertising interface exposes the Advertising functionality.

interface Advertising {
  Promise createView (RequestOptions requestOptions);
  Promise destroyView ();
  Promise request (boolean isTesting);
  Promise show (boolean show);
  attribute EventHandler onreceivead;
  attribute EventHandler onreceivefailed;
  attribute EventHandler onpresent;
  attribute EventHandler onclick;
  attribute EventHandler onclose;
};

2.1 Attributes

onreceive

  • Handles the receive event, fired when an ad data is received.

onreceivefailed

  • Handles the receivefailed event, fired when fail to receive an ad.

onpresent

  • Handles the present event, fired when an ad is shown.

onopen

  • Handles the touch event, fired when an ad is opened by user.

onclose

  • Handles the close event, fired when an ad is closed by user.

2.2 Methods

createView

  • This method creates a view for ad.
  • Parameter: options
  • Type: RequestOptions
  • Nullable: N
  • Optinal: N
  • Return type: Promise

destroyView

  • This method destroys a view.
  • No parameters.
  • Return type: Promise

request

  • This method request a banner ad from server.
  • Parameter: isTesting
  • Type: boolean
  • Nullable: N
  • Optinal: N
  • Return type: Promise

show

  • This method controls the ad be shown and hidden.
  • Parameter: bShow
  • Type: boolean
  • Nullable: N
  • Optinal: N
  • Return type: Promise

2.3 Steps

1. The createView method when invoded Must run the following steps:
  1. Create a View with input options. Banner or Interstitial.
  2. Return a new Promise object.
  3. If an error occurs call promise's error method.
  4. When the method has been successfully completed, call success method of the promise.
3. The destroyView method when invoded Must run the following steps:
  1. Destroy a View.
  2. Return a new Promise object.
  3. If an error occurs call promise's error method.
  4. When the method has been successfully completed, call success method of the promise.
4. The request method when invoded Must run the following steps:
  1. request an ad from server.
  2. Return a new Promise object.
  3. If an error occurs call promise's error method.
  4. When the method has been successfully completed, call success method of the promise.
6. The showAd method when invoded Must run the following steps:
  1. Show ad when show is true. Hide ad when show is false.
  2. Return a new Promise object.
  3. If an error occurs call promise's error method.
  4. When the method has been successfully completed, call success method of the promise.

3. RequestOptions interface

The Advertising interface exposes the Advertising functionality.

interface RequestOptions {
  attribute DOMString publisherId;
  attribute DOMString adSize;
  optional attribute boolean bannerAtTop;
  optional attribute boolean overlap;
}

3.1 Attributes

publisherId of type DOMString

  • Represents a unique identifier of the publisher.

adSize of type DOMString

  • Represents the size of ad.

bannerAtTop of type boolean

  • Represents Whether or not the ad should be positioned at top or bottom of screen.

overlap of type boolean

  • Represents Whether or not the banner will overlap the webview instead of push it up or down.