Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 869133005: Post a Message from Java to JS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address mnaganov comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.android_webview; 5 package org.chromium.android_webview;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.content.ComponentCallbacks2; 9 import android.content.ComponentCallbacks2;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 * 1783 *
1784 * @param frameName The name of the frame. If the name is null the message i s posted 1784 * @param frameName The name of the frame. If the name is null the message i s posted
1785 * to the main frame. 1785 * to the main frame.
1786 * @param message The message 1786 * @param message The message
1787 * @param sourceOrigin The source origin 1787 * @param sourceOrigin The source origin
1788 * @param targetOrigin The target origin 1788 * @param targetOrigin The target origin
1789 * @param msgPorts The sent message ports, if any. Pass null if there is no 1789 * @param msgPorts The sent message ports, if any. Pass null if there is no
1790 * message ports to pass. 1790 * message ports to pass.
1791 */ 1791 */
1792 public void postMessageToFrame(String frameName, String message, 1792 public void postMessageToFrame(String frameName, String message,
1793 String sourceOrigin, String targetOrigin, MessagePort[] msgPorts) { 1793 String sourceOrigin, String targetOrigin, MessagePort[] sentPorts) {
1794 if (isDestroyed()) return; 1794 if (isDestroyed()) return;
1795 int[] portIds = null; 1795 int[] portIds = null;
1796 if (msgPorts != null) { 1796 if (sentPorts != null) {
1797 portIds = new int[msgPorts.length]; 1797 portIds = new int[sentPorts.length];
1798 for (int i = 0; i < msgPorts.length; i++) 1798 for (int i = 0; i < sentPorts.length; i++) {
1799 portIds[i] = msgPorts[i].portId(); 1799 portIds[i] = sentPorts[i].portId();
1800 }
1801 mBrowserContext.getMessagePortService().removeSentPorts(portIds);
1800 } 1802 }
1801 nativePostMessageToFrame(mNativeAwContents, frameName, message, sourceOr igin, 1803 nativePostMessageToFrame(mNativeAwContents, frameName, message, sourceOr igin,
1802 targetOrigin, portIds); 1804 targetOrigin, portIds);
1803 } 1805 }
1804 1806
1805 /** 1807 /**
1806 * Creates a message channel. 1808 * Creates a message channel.
1807 * 1809 *
1808 * @param callback The message channel created. 1810 * @param callback The message channel created.
1809 */ 1811 */
1810 public void createMessageChannel(ValueCallback<MessageChannel> callback) { 1812 public void createMessageChannel(ValueCallback<MessageChannel> callback) {
1811 if (isDestroyed()) return; 1813 if (isDestroyed()) return;
1812 // Make sure the message port service is created. 1814 // Make sure the message port service is created.
1813 mBrowserContext.createMessagePortService(); 1815 mBrowserContext.createMessagePortServiceIfNecessary();
1814 nativeCreateMessageChannel(mNativeAwContents, callback); 1816 nativeCreateMessageChannel(mNativeAwContents, callback);
1815 } 1817 }
1816 1818
1817 //-------------------------------------------------------------------------- ------------------ 1819 //-------------------------------------------------------------------------- ------------------
1818 // View and ViewGroup method implementations 1820 // View and ViewGroup method implementations
1819 //-------------------------------------------------------------------------- ------------------ 1821 //-------------------------------------------------------------------------- ------------------
1820 1822
1821 /** 1823 /**
1822 * @see android.webkit.View#onTouchEvent() 1824 * @see android.webkit.View#onTouchEvent()
1823 */ 1825 */
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 2708
2707 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin, 2709 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin,
2708 long resources); 2710 long resources);
2709 2711
2710 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId, 2712 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId,
2711 String message, String sourceOrigin, String targetOrigin, int[] msgP orts); 2713 String message, String sourceOrigin, String targetOrigin, int[] msgP orts);
2712 2714
2713 private native void nativeCreateMessageChannel(long nativeAwContents, 2715 private native void nativeCreateMessageChannel(long nativeAwContents,
2714 ValueCallback<MessageChannel> callback); 2716 ValueCallback<MessageChannel> callback);
2715 } 2717 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698