blob: bfc00e7a01452622364d5b843f8750e49c1e87fd [file] [log] [blame]
Selim Gurun4c8093a2015-03-10 17:40:06 -07001/*
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
Nate Fischer3442c742017-09-08 17:02:00 -070019import android.annotation.Nullable;
20
Selim Gurun4c8093a2015-03-10 17:40:06 -070021/**
22 * The Java representation of the HTML5 PostMessage event. See
23 * https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces
24 * for definition of a MessageEvent in HTML5.
25 *
26 */
27public class WebMessage {
28
29 private String mData;
30 private WebMessagePort[] mPorts;
31
32 /**
33 * Creates a WebMessage.
34 * @param data the data of the message.
35 */
36 public WebMessage(String data) {
37 mData = data;
38 }
39
40 /**
41 * Creates a WebMessage.
42 * @param data the data of the message.
43 * @param ports the ports that are sent with the message.
44 */
45 public WebMessage(String data, WebMessagePort[] ports) {
46 mData = data;
47 mPorts = ports;
48 }
49
50 /**
51 * Returns the data of the message.
52 */
53 public String getData() {
54 return mData;
55 }
56
57 /**
Nate Fischer0a6140d2017-09-05 12:37:49 -070058 * Returns the ports that are sent with the message, or {@code null} if no port
Selim Gurun4c8093a2015-03-10 17:40:06 -070059 * is sent.
60 */
Nate Fischer3442c742017-09-08 17:02:00 -070061 @Nullable
Selim Gurun4c8093a2015-03-10 17:40:06 -070062 public WebMessagePort[] getPorts() {
63 return mPorts;
64 }
65}