| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/swapped_out_messages.h" | 5 #include "content/common/swapped_out_messages.h" |
| 6 | 6 |
| 7 #include "content/common/view_messages.h" | 7 #include "content/common/view_messages.h" |
| 8 #include "content/public/common/content_client.h" | 8 #include "content/public/common/content_client.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 bool SwappedOutMessages::CanSendWhileSwappedOut(const IPC::Message* msg) { | 12 bool SwappedOutMessages::CanHandleWhileSwappedOut( |
| 13 // We filter out most IPC messages when swapped out. However, some are | 13 const IPC::Message& msg) { |
| 14 // important (e.g., ACKs) for keeping the browser and renderer state | 14 // We drop most other messages that arrive from a swapped out renderer. |
| 15 // consistent in case we later return to the same renderer. | 15 // However, some are important (e.g., ACKs) for keeping the browser and |
| 16 switch (msg->type()) { | 16 // renderer state consistent in case we later return to the renderer. |
| 17 switch (msg.type()) { |
| 17 // Handled by RenderWidget. | 18 // Handled by RenderWidget. |
| 18 case ViewHostMsg_HandleInputEvent_ACK::ID: | 19 case ViewHostMsg_HandleInputEvent_ACK::ID: |
| 19 case ViewHostMsg_PaintAtSize_ACK::ID: | 20 case ViewHostMsg_PaintAtSize_ACK::ID: |
| 20 case ViewHostMsg_UpdateRect::ID: | 21 case ViewHostMsg_UpdateRect::ID: |
| 21 // Handled by RenderView. | 22 // Handled by RenderView. |
| 22 case ViewHostMsg_RenderViewGone::ID: | 23 case ViewHostMsg_RenderViewGone::ID: |
| 23 case ViewHostMsg_ShouldClose_ACK::ID: | 24 case ViewHostMsg_ShouldClose_ACK::ID: |
| 24 case ViewHostMsg_SwapOut_ACK::ID: | 25 case ViewHostMsg_SwapOut_ACK::ID: |
| 25 case ViewHostMsg_ClosePage_ACK::ID: | 26 case ViewHostMsg_ClosePage_ACK::ID: |
| 26 return true; | |
| 27 default: | |
| 28 break; | |
| 29 } | |
| 30 | |
| 31 // Check with the embedder as well. | |
| 32 ContentClient* client = GetContentClient(); | |
| 33 return client->CanSendWhileSwappedOut(msg); | |
| 34 } | |
| 35 | |
| 36 bool SwappedOutMessages::CanHandleWhileSwappedOut( | |
| 37 const IPC::Message& msg) { | |
| 38 // Any message the renderer is allowed to send while swapped out should | |
| 39 // be handled by the browser. | |
| 40 if (CanSendWhileSwappedOut(&msg)) | |
| 41 return true; | |
| 42 | |
| 43 // We drop most other messages that arrive from a swapped out renderer. | |
| 44 // However, some are important (e.g., ACKs) for keeping the browser and | |
| 45 // renderer state consistent in case we later return to the renderer. | |
| 46 switch (msg.type()) { | |
| 47 // Sends an ACK. | 27 // Sends an ACK. |
| 48 case ViewHostMsg_ShowView::ID: | 28 case ViewHostMsg_ShowView::ID: |
| 49 // Sends an ACK. | 29 // Sends an ACK. |
| 50 case ViewHostMsg_ShowWidget::ID: | 30 case ViewHostMsg_ShowWidget::ID: |
| 51 // Sends an ACK. | 31 // Sends an ACK. |
| 52 case ViewHostMsg_ShowFullscreenWidget::ID: | 32 case ViewHostMsg_ShowFullscreenWidget::ID: |
| 53 // Updates browser state. | 33 // Updates browser state. |
| 54 case ViewHostMsg_RenderViewReady::ID: | 34 case ViewHostMsg_RenderViewReady::ID: |
| 55 // Updates the previous navigation entry. | 35 // Updates the previous navigation entry. |
| 56 case ViewHostMsg_UpdateState::ID: | 36 case ViewHostMsg_UpdateState::ID: |
| 57 // Sends an ACK. | 37 // Sends an ACK. |
| 58 case ViewHostMsg_UpdateTargetURL::ID: | 38 case ViewHostMsg_UpdateTargetURL::ID: |
| 59 // We allow closing even if we are in the process of swapping out. | 39 // We allow closing even if we are in the process of swapping out. |
| 60 case ViewHostMsg_Close::ID: | 40 case ViewHostMsg_Close::ID: |
| 61 // Sends an ACK. | 41 // Sends an ACK. |
| 62 case ViewHostMsg_RequestMove::ID: | 42 case ViewHostMsg_RequestMove::ID: |
| 63 // Suppresses dialog and sends an ACK. | 43 // Suppresses dialog and sends an ACK. |
| 64 case ViewHostMsg_RunJavaScriptMessage::ID: | 44 case ViewHostMsg_RunJavaScriptMessage::ID: |
| 65 // Suppresses dialog and sends an ACK. | 45 // Suppresses dialog and sends an ACK. |
| 66 case ViewHostMsg_RunBeforeUnloadConfirm::ID: | 46 case ViewHostMsg_RunBeforeUnloadConfirm::ID: |
| 67 // Sends an ACK. | 47 // Sends an ACK. |
| 68 case ViewHostMsg_AccessibilityNotifications::ID: | 48 case ViewHostMsg_AccessibilityNotifications::ID: |
| 69 #if defined(USE_X11) | 49 #if defined(USE_X11) |
| 70 // Synchronous message when leaving a page with plugin. | 50 // Synchronous message when leaving a page with plugin. |
| 71 case ViewHostMsg_DestroyPluginContainer::ID: | 51 case ViewHostMsg_DestroyPluginContainer::ID: |
| 72 #endif | 52 #endif |
| 53 case ViewHostMsg_SendPostMessage::ID: |
| 73 return true; | 54 return true; |
| 74 default: | 55 default: |
| 75 break; | 56 break; |
| 76 } | 57 } |
| 77 | 58 |
| 78 // Check with the embedder as well. | 59 // Check with the embedder as well. |
| 79 ContentClient* client = GetContentClient(); | 60 ContentClient* client = GetContentClient(); |
| 80 return client->CanHandleWhileSwappedOut(msg); | 61 return client->CanHandleWhileSwappedOut(msg); |
| 81 } | 62 } |
| 82 | 63 |
| 83 } // namespace content | 64 } // namespace content |
| OLD | NEW |