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