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