[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / content / common / swapped_out_messages.cc
blobde5da6490eac516d0bef5790cf6ab309ff839548
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"
12 #include "content/shell/common/shell_messages.h"
14 namespace content {
16 bool SwappedOutMessages::CanSendWhileSwappedOut(const IPC::Message* msg) {
17 // We filter out most IPC messages when swapped out. However, some are
18 // important (e.g., ACKs) for keeping the browser and renderer state
19 // consistent in case we later return to the same renderer.
20 switch (msg->type()) {
21 // Handled by RenderWidgetHost.
22 case InputHostMsg_HandleInputEvent_ACK::ID:
23 case ViewHostMsg_UpdateRect::ID:
24 // Allow targeted navigations while swapped out.
25 case FrameHostMsg_OpenURL::ID:
26 case ViewHostMsg_Focus::ID:
27 // Handled by RenderViewHost.
28 case ViewHostMsg_ClosePage_ACK::ID:
29 case ViewHostMsg_SwapCompositorFrame::ID:
30 // Handled by WorkerMessageFilter (or by SharedWorkerMessageFilter when
31 // embedded-shared-worker is enabled).
32 case ViewHostMsg_DocumentDetached::ID:
33 // Allow cross-process JavaScript calls.
34 case ViewHostMsg_RouteCloseEvent::ID:
35 // Handled by RenderFrameHost.
36 case FrameHostMsg_BeforeUnload_ACK::ID:
37 case FrameHostMsg_SwapOut_ACK::ID:
38 case FrameHostMsg_RenderProcessGone::ID:
39 // Frame detach must occur after the RenderView has swapped out.
40 case FrameHostMsg_Detach::ID:
41 case FrameHostMsg_DomOperationResponse::ID:
42 case FrameHostMsg_CompositorFrameSwappedACK::ID:
43 case FrameHostMsg_ReclaimCompositorResources::ID:
44 // Input events propagate from parent to child.
45 case FrameHostMsg_ForwardInputEvent::ID:
46 case FrameHostMsg_InitializeChildFrame::ID:
47 // The browser should always have an accurate mirror of the renderer's
48 // notion of the current page id.
49 case FrameHostMsg_DidAssignPageId::ID:
50 // Used in layout tests; handled in BlinkTestController.
51 case ShellViewHostMsg_PrintMessage::ID:
52 return true;
53 default:
54 break;
57 // Check with the embedder as well.
58 ContentClient* client = GetContentClient();
59 return client->CanSendWhileSwappedOut(msg);
62 bool SwappedOutMessages::CanHandleWhileSwappedOut(
63 const IPC::Message& msg) {
64 // Any message the renderer is allowed to send while swapped out should
65 // be handled by the browser.
66 if (CanSendWhileSwappedOut(&msg))
67 return true;
69 // We drop most other messages that arrive from a swapped out renderer.
70 // However, some are important (e.g., ACKs) for keeping the browser and
71 // renderer state consistent in case we later return to the renderer.
72 // Note that synchronous messages that are not handled will receive an
73 // error reply instead, to avoid leaving the renderer in a stuck state.
74 switch (msg.type()) {
75 // Sends an ACK.
76 case ViewHostMsg_ShowView::ID:
77 // Sends an ACK.
78 case ViewHostMsg_ShowWidget::ID:
79 // Sends an ACK.
80 case ViewHostMsg_ShowFullscreenWidget::ID:
81 // Updates browser state.
82 case ViewHostMsg_RenderViewReady::ID:
83 // Updates the previous navigation entry.
84 case ViewHostMsg_UpdateState::ID:
85 // Sends an ACK.
86 case ViewHostMsg_UpdateTargetURL::ID:
87 // We allow closing even if we are in the process of swapping out.
88 case ViewHostMsg_Close::ID:
89 // Sends an ACK.
90 case ViewHostMsg_RequestMove::ID:
91 // Sends an ACK.
92 case AccessibilityHostMsg_Events::ID:
93 return true;
94 default:
95 break;
98 return false;
101 } // namespace content