| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // IPC messages for injected Java objects (Gin-based implementation). | 5 // IPC messages for injected Java objects (Gin-based implementation). |
| 6 | 6 |
| 7 // Multiply-included message file, hence no include guard. | 7 // Multiply-included message file, hence no include guard. |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "content/common/android/gin_java_bridge_errors.h" |
| 10 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 11 #include "ipc/ipc_message_macros.h" | 12 #include "ipc/ipc_message_macros.h" |
| 12 | 13 |
| 13 #undef IPC_MESSAGE_EXPORT | 14 #undef IPC_MESSAGE_EXPORT |
| 14 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT | 15 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT |
| 15 #define IPC_MESSAGE_START GinJavaBridgeMsgStart | 16 #define IPC_MESSAGE_START GinJavaBridgeMsgStart |
| 16 | 17 |
| 17 // Messages for handling Java objects injected into JavaScript ----------------- | 18 // Messages for handling Java objects injected into JavaScript ----------------- |
| 18 | 19 |
| 20 IPC_ENUM_TRAITS(content::GinJavaBridgeError) |
| 21 |
| 19 // Sent from browser to renderer to add a Java object with the given name. | 22 // Sent from browser to renderer to add a Java object with the given name. |
| 20 // Object IDs are generated on the browser side. | 23 // Object IDs are generated on the browser side. |
| 21 IPC_MESSAGE_ROUTED2(GinJavaBridgeMsg_AddNamedObject, | 24 IPC_MESSAGE_ROUTED2(GinJavaBridgeMsg_AddNamedObject, |
| 22 std::string /* name */, | 25 std::string /* name */, |
| 23 int32 /* object_id */) | 26 int32 /* object_id */) |
| 24 | 27 |
| 25 // Sent from browser to renderer to remove a Java object with the given name. | 28 // Sent from browser to renderer to remove a Java object with the given name. |
| 26 IPC_MESSAGE_ROUTED1(GinJavaBridgeMsg_RemoveNamedObject, | 29 IPC_MESSAGE_ROUTED1(GinJavaBridgeMsg_RemoveNamedObject, |
| 27 std::string /* name */) | 30 std::string /* name */) |
| 28 | 31 |
| 29 // Sent from renderer to browser to get information about methods of | 32 // Sent from renderer to browser to get information about methods of |
| 30 // the given object. The query will only succeed if inspection of injected | 33 // the given object. The query will only succeed if inspection of injected |
| 31 // objects is enabled on the browser side. | 34 // objects is enabled on the browser side. |
| 32 IPC_SYNC_MESSAGE_ROUTED1_1(GinJavaBridgeHostMsg_GetMethods, | 35 IPC_SYNC_MESSAGE_ROUTED1_1(GinJavaBridgeHostMsg_GetMethods, |
| 33 int32 /* object_id */, | 36 int32 /* object_id */, |
| 34 std::set<std::string> /* returned_method_names */) | 37 std::set<std::string> /* returned_method_names */) |
| 35 | 38 |
| 36 // Sent from renderer to browser to find out, if an object has a method with | 39 // Sent from renderer to browser to find out, if an object has a method with |
| 37 // the given name. | 40 // the given name. |
| 38 IPC_SYNC_MESSAGE_ROUTED2_1(GinJavaBridgeHostMsg_HasMethod, | 41 IPC_SYNC_MESSAGE_ROUTED2_1(GinJavaBridgeHostMsg_HasMethod, |
| 39 int32 /* object_id */, | 42 int32 /* object_id */, |
| 40 std::string /* method_name */, | 43 std::string /* method_name */, |
| 41 bool /* result */) | 44 bool /* result */) |
| 42 | 45 |
| 43 // Sent from renderer to browser to invoke a method. Method arguments | 46 // Sent from renderer to browser to invoke a method. Method arguments |
| 44 // are chained into |arguments| list. base::ListValue is used for |result| as | 47 // are chained into |arguments| list. base::ListValue is used for |result| as |
| 45 // a container to work around immutability of base::Value. | 48 // a container to work around immutability of base::Value. |
| 46 // Empty result list indicates that an error has happened on the Java side | 49 // Empty result list indicates that an error has happened on the Java side |
| 47 // (either bridge-induced error or an unhandled Java exception) and an exception | 50 // (either bridge-induced error or an unhandled Java exception) and an exception |
| 48 // must be thrown into JavaScript. | 51 // must be thrown into JavaScript. |error_code| indicates the cause of |
| 52 // the error. |
| 49 // Some special value types that are not supported by base::Value are encoded | 53 // Some special value types that are not supported by base::Value are encoded |
| 50 // as BinaryValues via GinJavaBridgeValue. | 54 // as BinaryValues via GinJavaBridgeValue. |
| 51 IPC_SYNC_MESSAGE_ROUTED3_1(GinJavaBridgeHostMsg_InvokeMethod, | 55 IPC_SYNC_MESSAGE_ROUTED3_2(GinJavaBridgeHostMsg_InvokeMethod, |
| 52 int32 /* object_id */, | 56 int32 /* object_id */, |
| 53 std::string /* method_name */, | 57 std::string /* method_name */, |
| 54 base::ListValue /* arguments */, | 58 base::ListValue /* arguments */, |
| 55 base::ListValue /* result */) | 59 base::ListValue /* result */, |
| 60 content::GinJavaBridgeError /* error_code */) |
| 56 | 61 |
| 57 // Sent from renderer to browser in two cases: | 62 // Sent from renderer to browser in two cases: |
| 58 // | 63 // |
| 59 // 1. (Main usage) To inform that the JS wrapper of the object has | 64 // 1. (Main usage) To inform that the JS wrapper of the object has |
| 60 // been completely dereferenced and garbage-collected. | 65 // been completely dereferenced and garbage-collected. |
| 61 // | 66 // |
| 62 // 2. To notify the browser that wrapper creation has failed. The browser side | 67 // 2. To notify the browser that wrapper creation has failed. The browser side |
| 63 // assumes optimistically that every time an object is returned from a | 68 // assumes optimistically that every time an object is returned from a |
| 64 // method, the corresponding wrapper object will be successfully created on | 69 // method, the corresponding wrapper object will be successfully created on |
| 65 // the renderer side. Sending of this message informs the browser whether | 70 // the renderer side. Sending of this message informs the browser whether |
| 66 // this expectation has failed. | 71 // this expectation has failed. |
| 67 IPC_MESSAGE_ROUTED1(GinJavaBridgeHostMsg_ObjectWrapperDeleted, | 72 IPC_MESSAGE_ROUTED1(GinJavaBridgeHostMsg_ObjectWrapperDeleted, |
| 68 int32 /* object_id */) | 73 int32 /* object_id */) |
| OLD | NEW |