• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package 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  */
25 public class WebMessage {
26 
27     private String mData;
28     private WebMessagePort[] mPorts;
29 
30     /**
31      * Creates a WebMessage.
32      * @param data  the data of the message.
33      */
WebMessage(String data)34     public WebMessage(String data) {
35         mData = data;
36     }
37 
38     /**
39      * Creates a WebMessage.
40      * @param data  the data of the message.
41      * @param ports  the ports that are sent with the message.
42      */
WebMessage(String data, WebMessagePort[] ports)43     public WebMessage(String data, WebMessagePort[] ports) {
44         mData = data;
45         mPorts = ports;
46     }
47 
48     /**
49      * Returns the data of the message.
50      */
getData()51     public String getData() {
52         return mData;
53     }
54 
55     /**
56      * Returns the ports that are sent with the message, or null if no port
57      * is sent.
58      */
getPorts()59     public WebMessagePort[] getPorts() {
60         return mPorts;
61     }
62 }
63