OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 bool RenderWidgetHostImpl::IsLoading() const { | 442 bool RenderWidgetHostImpl::IsLoading() const { |
443 return is_loading_; | 443 return is_loading_; |
444 } | 444 } |
445 | 445 |
446 bool RenderWidgetHostImpl::IsRenderView() const { | 446 bool RenderWidgetHostImpl::IsRenderView() const { |
447 return false; | 447 return false; |
448 } | 448 } |
449 | 449 |
450 bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) { | 450 bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) { |
451 bool handled = true; | 451 bool handled = true; |
452 bool msg_is_ok = true; | 452 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostImpl, msg) |
453 IPC_BEGIN_MESSAGE_MAP_EX(RenderWidgetHostImpl, msg, msg_is_ok) | |
454 IPC_MESSAGE_HANDLER(InputHostMsg_QueueSyntheticGesture, | 453 IPC_MESSAGE_HANDLER(InputHostMsg_QueueSyntheticGesture, |
455 OnQueueSyntheticGesture) | 454 OnQueueSyntheticGesture) |
456 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) | 455 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) |
457 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) | 456 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) |
458 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) | 457 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) |
459 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK, | 458 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK, |
460 OnUpdateScreenRectsAck) | 459 OnUpdateScreenRectsAck) |
461 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) | 460 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) |
462 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnSetTooltipText) | 461 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnSetTooltipText) |
463 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_SwapCompositorFrame, | 462 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_SwapCompositorFrame, |
464 msg_is_ok = OnSwapCompositorFrame(msg)) | 463 OnSwapCompositorFrame(msg)) |
465 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStopFlinging, OnFlingingStopped) | 464 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStopFlinging, OnFlingingStopped) |
466 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) | 465 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
467 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) | 466 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) |
468 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) | 467 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) |
469 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) | 468 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) |
470 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTouchEventEmulationEnabled, | 469 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTouchEventEmulationEnabled, |
471 OnSetTouchEventEmulationEnabled) | 470 OnSetTouchEventEmulationEnabled) |
472 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, | 471 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, |
473 OnTextInputTypeChanged) | 472 OnTextInputTypeChanged) |
474 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, | 473 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, |
(...skipping 13 matching lines...) Expand all Loading... |
488 #endif | 487 #endif |
489 #if defined(OS_MACOSX) | 488 #if defined(OS_MACOSX) |
490 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, | 489 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, |
491 OnCompositorSurfaceBuffersSwapped) | 490 OnCompositorSurfaceBuffersSwapped) |
492 #endif | 491 #endif |
493 #if defined(OS_MACOSX) || defined(USE_AURA) | 492 #if defined(OS_MACOSX) || defined(USE_AURA) |
494 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCompositionRangeChanged, | 493 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCompositionRangeChanged, |
495 OnImeCompositionRangeChanged) | 494 OnImeCompositionRangeChanged) |
496 #endif | 495 #endif |
497 IPC_MESSAGE_UNHANDLED(handled = false) | 496 IPC_MESSAGE_UNHANDLED(handled = false) |
498 IPC_END_MESSAGE_MAP_EX() | 497 IPC_END_MESSAGE_MAP() |
499 | 498 |
500 if (!handled && input_router_ && input_router_->OnMessageReceived(msg)) | 499 if (!handled && input_router_ && input_router_->OnMessageReceived(msg)) |
501 return true; | 500 return true; |
502 | 501 |
503 if (!handled && view_ && view_->OnMessageReceived(msg)) | 502 if (!handled && view_ && view_->OnMessageReceived(msg)) |
504 return true; | 503 return true; |
505 | 504 |
506 if (!msg_is_ok) { | |
507 // The message de-serialization failed. Kill the renderer process. | |
508 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH")); | |
509 GetProcess()->ReceivedBadMessage(); | |
510 } | |
511 return handled; | 505 return handled; |
512 } | 506 } |
513 | 507 |
514 bool RenderWidgetHostImpl::Send(IPC::Message* msg) { | 508 bool RenderWidgetHostImpl::Send(IPC::Message* msg) { |
515 if (IPC_MESSAGE_ID_CLASS(msg->type()) == InputMsgStart) | 509 if (IPC_MESSAGE_ID_CLASS(msg->type()) == InputMsgStart) |
516 return input_router_->SendInput(make_scoped_ptr(msg)); | 510 return input_router_->SendInput(make_scoped_ptr(msg)); |
517 | 511 |
518 return process_->Send(msg); | 512 return process_->Send(msg); |
519 } | 513 } |
520 | 514 |
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 } | 2315 } |
2322 } | 2316 } |
2323 | 2317 |
2324 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { | 2318 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { |
2325 if (view_) | 2319 if (view_) |
2326 return view_->PreferredReadbackFormat(); | 2320 return view_->PreferredReadbackFormat(); |
2327 return SkBitmap::kARGB_8888_Config; | 2321 return SkBitmap::kARGB_8888_Config; |
2328 } | 2322 } |
2329 | 2323 |
2330 } // namespace content | 2324 } // namespace content |
OLD | NEW |