WebMessage.java revision 37bd8907cb94be69c9bd4c308e49c38524e87269
1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.webkit; 18 19/** 20 * The Java representation of the HTML5 PostMessage event. See 21 * https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces 22 * for definition of a MessageEvent in HTML5. 23 * 24 * @hide unhide when implementation is complete 25 */ 26public class WebMessage { 27 28 private String mData; 29 private WebMessagePort[] mPorts; 30 31 /** 32 * Creates a WebMessage. 33 * @param data the data of the message. 34 */ 35 public WebMessage(String data) { 36 mData = data; 37 } 38 39 /** 40 * Creates a WebMessage. 41 * @param data the data of the message. 42 * @param ports the ports array that are sent with the message. 43 */ 44 public WebMessage(String data, WebMessagePort[] ports) { 45 mData = data; 46 mPorts = ports; 47 } 48 49 /** 50 * Returns the data of the message. 51 */ 52 public String getData() { 53 return mData; 54 } 55 56 /** 57 * Returns the ports that are sent with the message, or null if no port 58 * is sent. 59 */ 60 public WebMessagePort[] getPorts() { 61 return mPorts; 62 } 63} 64