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/content_export.h"
11 #include "ipc/ipc_message_macros.h"
13 #undef IPC_MESSAGE_EXPORT
14 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
15 #define IPC_MESSAGE_START GinJavaBridgeMsgStart
17 // Messages for handling Java objects injected into JavaScript -----------------
19 // Sent from browser to renderer to add a Java object with the given name.
20 // Object IDs are generated on the browser side.
21 IPC_MESSAGE_ROUTED2(GinJavaBridgeMsg_AddNamedObject
,
22 std::string
/* name */,
23 int32
/* object_id */)
25 // Sent from browser to renderer to remove a Java object with the given name.
26 IPC_MESSAGE_ROUTED1(GinJavaBridgeMsg_RemoveNamedObject
,
27 std::string
/* name */)
29 // Sent from renderer to browser to get information about methods of
30 // the given object. The query will only succeed if inspection of injected
31 // objects is enabled on the browser side.
32 IPC_SYNC_MESSAGE_ROUTED1_1(GinJavaBridgeHostMsg_GetMethods
,
33 int32
/* object_id */,
34 std::set
<std::string
> /* returned_method_names */)
36 // Sent from renderer to browser to find out, if an object has a method with
38 IPC_SYNC_MESSAGE_ROUTED2_1(GinJavaBridgeHostMsg_HasMethod
,
39 int32
/* object_id */,
40 std::string
/* method_name */,
43 // Sent from renderer to browser to invoke a method. Method arguments
44 // are chained into |arguments| list. base::ListValue is used for |result| as
45 // a container to work around immutability of base::Value.
46 // 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
48 // must be thrown into JavaScript.
49 // Some special value types that are not supported by base::Value are encoded
50 // as BinaryValues via GinJavaBridgeValue.
51 IPC_SYNC_MESSAGE_ROUTED3_1(GinJavaBridgeHostMsg_InvokeMethod
,
52 int32
/* object_id */,
53 std::string
/* method_name */,
54 base::ListValue
/* arguments */,
55 base::ListValue
/* result */)
57 // Sent from renderer to browser in two cases:
59 // 1. (Main usage) To inform that the JS wrapper of the object has
60 // been completely dereferenced and garbage-collected.
62 // 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
64 // method, the corresponding wrapper object will be successfully created on
65 // the renderer side. Sending of this message informs the browser whether
66 // this expectation has failed.
67 IPC_MESSAGE_ROUTED1(GinJavaBridgeHostMsg_ObjectWrapperDeleted
,
68 int32
/* object_id */)