[content shell] hook up testRunner.dumpEditingCallbacks
[chromium-blink-merge.git] / content / common / swapped_out_messages.cc
blob83fc39483cc220ea8f8c5b77fbd4a409897821fa
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"
11 namespace content {
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:
34 return true;
35 default:
36 break;
39 return false;
42 bool SwappedOutMessages::CanHandleWhileSwappedOut(
43 const IPC::Message& msg) {
44 // Any message the renderer is allowed to send while swapped out should
45 // be handled by the browser.
46 if (CanSendWhileSwappedOut(&msg))
47 return true;
49 // We drop most other messages that arrive from a swapped out renderer.
50 // However, some are important (e.g., ACKs) for keeping the browser and
51 // renderer state consistent in case we later return to the renderer.
52 // Note that synchronous messages that are not handled will receive an
53 // error reply instead, to avoid leaving the renderer in a stuck state.
54 switch (msg.type()) {
55 // Sends an ACK.
56 case ViewHostMsg_ShowView::ID:
57 // Sends an ACK.
58 case ViewHostMsg_ShowWidget::ID:
59 // Sends an ACK.
60 case ViewHostMsg_ShowFullscreenWidget::ID:
61 // Updates browser state.
62 case ViewHostMsg_RenderViewReady::ID:
63 // Updates the previous navigation entry.
64 case ViewHostMsg_UpdateState::ID:
65 // Sends an ACK.
66 case ViewHostMsg_UpdateTargetURL::ID:
67 // We allow closing even if we are in the process of swapping out.
68 case ViewHostMsg_Close::ID:
69 // Sends an ACK.
70 case ViewHostMsg_RequestMove::ID:
71 // Sends an ACK.
72 case AccessibilityHostMsg_Notifications::ID:
73 #if defined(USE_X11)
74 // Synchronous message when leaving a page with plugin. In this case,
75 // we want to destroy the plugin rather than return an error message.
76 case ViewHostMsg_DestroyPluginContainer::ID:
77 #endif
78 return true;
79 default:
80 break;
83 // Check with the embedder as well.
84 ContentClient* client = GetContentClient();
85 return client->CanHandleWhileSwappedOut(msg);
88 } // namespace content