Benjamin Lerman | 1a8ef40 | 2015-04-08 13:47:49 +0200 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | [JavaPackage="org.chromium.mojo.intent"] |
| 6 | module intent_receiver; |
| 7 | |
| 8 | // Service to interact with android intents. |
Benjamin Lerman | 38b3d0f | 2015-11-20 10:52:59 +0100 | [diff] [blame] | 9 | [ServiceName="intent_receiver::IntentReceiverManager"] |
Benjamin Lerman | 1a8ef40 | 2015-04-08 13:47:49 +0200 | [diff] [blame] | 10 | interface IntentReceiverManager { |
| 11 | // This method takes an |IntentReceiver| and returns a serialized intent. |
| 12 | // The serialized intent can be deserialized using an android parcel. The |
| 13 | // caller can then transform this intent into a PendingIntent using |
Benjamin Lerman | f3ca9fa | 2015-11-26 11:11:43 +0100 | [diff] [blame] | 14 | // |PendingIntent#getActivity| and send it to another android application. |
Benjamin Lerman | 1a8ef40 | 2015-04-08 13:47:49 +0200 | [diff] [blame] | 15 | // Whenever the pending intent is executed, the receiver will be called with |
Benjamin Lerman | 9b79e2c | 2015-04-29 17:33:12 +0200 | [diff] [blame] | 16 | // the content of the received intent. |
| 17 | // To be noted, this will fail if the received intent is active (contains |
| 18 | // either a Binder or a file descriptor). |
| 19 | RegisterIntentReceiver(IntentReceiver receiver) => (array<uint8>? intent); |
| 20 | |
| 21 | // This method takes an |IntentReceiver| and returns a serialized intent. |
| 22 | // The serialized intent can be deserialized using an android parcel. The |
| 23 | // caller can then add an intent it wants the system to send using |
| 24 | // |Activity#startActivityForResult| and then send it using |
| 25 | // |Context#startService|. Whenever the started activity sends a result, the |
| 26 | // receiver will be called with the content of the received intent. If the |
| 27 | // activity is cancelled, the receiver will be closed. |
Alexandre Zani | d26dd21 | 2016-03-24 13:24:48 -0700 | [diff] [blame] | 28 | RegisterActivityResultReceiver(IntentReceiver receiver) |
| 29 | => (array<uint8>? intent); |
Benjamin Lerman | 1a8ef40 | 2015-04-08 13:47:49 +0200 | [diff] [blame] | 30 | }; |
| 31 | |
Benjamin Lerman | 9b79e2c | 2015-04-29 17:33:12 +0200 | [diff] [blame] | 32 | // Receiver interface, to be used with |IntentReceiverManager|. |
Benjamin Lerman | 1a8ef40 | 2015-04-08 13:47:49 +0200 | [diff] [blame] | 33 | interface IntentReceiver { |
Benjamin Lerman | 4bc7f92 | 2015-09-29 16:33:29 +0200 | [diff] [blame] | 34 | OnIntent(array<uint8>? intent); |
Benjamin Lerman | 1a8ef40 | 2015-04-08 13:47:49 +0200 | [diff] [blame] | 35 | }; |