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/common/swapped_out_messages.h"
7 #include "content/common/accessibility_messages.h"
8 #include "content/common/frame_messages.h"
9 #include "content/common/input_messages.h"
10 #include "content/common/view_messages.h"
11 #include "content/public/common/content_client.h"
15 bool SwappedOutMessages::CanSendWhileSwappedOut(const IPC::Message
* msg
) {
16 // We filter out most IPC messages when swapped out. However, some are
17 // important (e.g., ACKs) for keeping the browser and renderer state
18 // consistent in case we later return to the same renderer.
19 switch (msg
->type()) {
20 // Handled by RenderWidgetHost.
21 case InputHostMsg_HandleInputEvent_ACK::ID
:
22 case ViewHostMsg_PaintAtSize_ACK::ID
:
23 case ViewHostMsg_UpdateRect::ID
:
24 // Allow targeted navigations while swapped out.
25 case ViewHostMsg_OpenURL::ID
:
26 case ViewHostMsg_Focus::ID
:
27 // Handled by RenderViewHost.
28 case ViewHostMsg_RenderProcessGone::ID
:
29 case ViewHostMsg_ShouldClose_ACK::ID
:
30 case ViewHostMsg_SwapOut_ACK::ID
:
31 case ViewHostMsg_ClosePage_ACK::ID
:
32 case ViewHostMsg_DomOperationResponse::ID
:
33 case ViewHostMsg_SwapCompositorFrame::ID
:
34 case ViewHostMsg_UpdateIsDelayed::ID
:
35 case ViewHostMsg_DidActivateAcceleratedCompositing::ID
:
36 // Allow cross-process JavaScript calls.
37 case ViewHostMsg_RouteCloseEvent::ID
:
38 case ViewHostMsg_RouteMessageEvent::ID
:
39 // Handled by RenderFrameHost.
40 case FrameHostMsg_SwapOut_ACK::ID
:
41 // Frame detach must occur after the RenderView has swapped out.
42 case FrameHostMsg_Detach::ID
:
48 // Check with the embedder as well.
49 ContentClient
* client
= GetContentClient();
50 return client
->CanSendWhileSwappedOut(msg
);
53 bool SwappedOutMessages::CanHandleWhileSwappedOut(
54 const IPC::Message
& msg
) {
55 // Any message the renderer is allowed to send while swapped out should
56 // be handled by the browser.
57 if (CanSendWhileSwappedOut(&msg
))
60 // We drop most other messages that arrive from a swapped out renderer.
61 // However, some are important (e.g., ACKs) for keeping the browser and
62 // renderer state consistent in case we later return to the renderer.
63 // Note that synchronous messages that are not handled will receive an
64 // error reply instead, to avoid leaving the renderer in a stuck state.
67 case ViewHostMsg_ShowView::ID
:
69 case ViewHostMsg_ShowWidget::ID
:
71 case ViewHostMsg_ShowFullscreenWidget::ID
:
72 // Updates browser state.
73 case ViewHostMsg_RenderViewReady::ID
:
74 // Updates the previous navigation entry.
75 case ViewHostMsg_UpdateState::ID
:
77 case ViewHostMsg_UpdateTargetURL::ID
:
78 // We allow closing even if we are in the process of swapping out.
79 case ViewHostMsg_Close::ID
:
81 case ViewHostMsg_RequestMove::ID
:
83 case AccessibilityHostMsg_Events::ID
:
85 // Synchronous message when leaving a page with plugin. In this case,
86 // we want to destroy the plugin rather than return an error message.
87 case ViewHostMsg_DestroyPluginContainer::ID
:
94 // Check with the embedder as well.
95 ContentClient
* client
= GetContentClient();
96 return client
->CanHandleWhileSwappedOut(msg
);
99 } // namespace content