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/view_messages.h"
9 #include "content/public/common/content_client.h"
13 bool SwappedOutMessages::CanSendWhileSwappedOut(const IPC::Message
* msg
) {
14 // We filter out most IPC messages when swapped out. However, some are
15 // important (e.g., ACKs) for keeping the browser and renderer state
16 // consistent in case we later return to the same renderer.
17 switch (msg
->type()) {
18 // Handled by RenderWidget.
19 case ViewHostMsg_HandleInputEvent_ACK::ID
:
20 case ViewHostMsg_PaintAtSize_ACK::ID
:
21 case ViewHostMsg_UpdateRect::ID
:
22 // Allow targeted navigations while swapped out.
23 case ViewHostMsg_OpenURL::ID
:
24 case ViewHostMsg_Focus::ID
:
25 // Handled by RenderView.
26 case ViewHostMsg_RenderViewGone::ID
:
27 case ViewHostMsg_ShouldClose_ACK::ID
:
28 case ViewHostMsg_SwapOut_ACK::ID
:
29 case ViewHostMsg_ClosePage_ACK::ID
:
30 case ViewHostMsg_DomOperationResponse::ID
:
31 // Allow cross-process JavaScript calls.
32 case ViewHostMsg_RouteCloseEvent::ID
:
33 case ViewHostMsg_RouteMessageEvent::ID
:
39 // Check with the embedder as well.
40 ContentClient
* client
= GetContentClient();
41 return client
->CanSendWhileSwappedOut(msg
);
44 bool SwappedOutMessages::CanHandleWhileSwappedOut(
45 const IPC::Message
& msg
) {
46 // Any message the renderer is allowed to send while swapped out should
47 // be handled by the browser.
48 if (CanSendWhileSwappedOut(&msg
))
51 // We drop most other messages that arrive from a swapped out renderer.
52 // However, some are important (e.g., ACKs) for keeping the browser and
53 // renderer state consistent in case we later return to the renderer.
54 // Note that synchronous messages that are not handled will receive an
55 // error reply instead, to avoid leaving the renderer in a stuck state.
58 case ViewHostMsg_ShowView::ID
:
60 case ViewHostMsg_ShowWidget::ID
:
62 case ViewHostMsg_ShowFullscreenWidget::ID
:
63 // Updates browser state.
64 case ViewHostMsg_RenderViewReady::ID
:
65 // Updates the previous navigation entry.
66 case ViewHostMsg_UpdateState::ID
:
68 case ViewHostMsg_UpdateTargetURL::ID
:
69 // We allow closing even if we are in the process of swapping out.
70 case ViewHostMsg_Close::ID
:
72 case ViewHostMsg_RequestMove::ID
:
74 case AccessibilityHostMsg_Notifications::ID
:
76 // Synchronous message when leaving a page with plugin. In this case,
77 // we want to destroy the plugin rather than return an error message.
78 case ViewHostMsg_DestroyPluginContainer::ID
:
85 // Check with the embedder as well.
86 ContentClient
* client
= GetContentClient();
87 return client
->CanHandleWhileSwappedOut(msg
);
90 } // namespace content