1 // Copyright (c) 2012 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 #include "content/renderer/java/java_bridge_channel.h"
7 #include "content/common/child_process.h"
8 #include "content/common/java_bridge_messages.h"
9 #include "content/common/plugin_messages.h"
13 JavaBridgeChannel
* JavaBridgeChannel::GetJavaBridgeChannel(
14 const IPC::ChannelHandle
& channel_handle
,
15 base::MessageLoopProxy
* ipc_message_loop
) {
16 return static_cast<JavaBridgeChannel
*>(NPChannelBase::GetChannel(
18 IPC::Channel::MODE_CLIENT
,
22 ChildProcess::current()->GetShutDownEvent()));
25 JavaBridgeChannel::JavaBridgeChannel() {
28 JavaBridgeChannel::~JavaBridgeChannel() {
31 int JavaBridgeChannel::GenerateRouteID() {
32 // Use a control message as this going to the JavaBridgeChannelHost, not an
34 int route_id
= MSG_ROUTING_NONE
;
35 Send(new JavaBridgeMsg_GenerateRouteID(&route_id
));
36 // This should never fail, as the JavaBridgeChannelHost should always outlive
38 DCHECK_NE(MSG_ROUTING_NONE
, route_id
);
42 bool JavaBridgeChannel::OnControlMessageReceived(const IPC::Message
& msg
) {
43 // We need to intercept these two message types because the default
44 // implementation of NPChannelBase::OnControlMessageReceived() is to
45 // DCHECK(false). However, we don't need to do anything, as we don't need to
46 // worry about the window system hanging when a modal dialog is displayed.
47 // This is because, unlike in the case of plugins, the host does not need to
48 // pump the message queue to avoid hangs.
49 if (msg
.type() == PluginMsg_SignalModalDialogEvent::ID
||
50 msg
.type() == PluginMsg_ResetModalDialogEvent::ID
) {
53 return NPChannelBase::OnControlMessageReceived(msg
);
56 } // namespace content