| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/renderer_host/render_widget_host.h" | 5 #include "chrome/browser/renderer_host/render_widget_host.h" |
| 6 | 6 |
| 7 #include "base/histogram.h" | 7 #include "base/histogram.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/keyboard_codes.h" | 9 #include "base/keyboard_codes.h" |
| 10 #include "chrome/browser/renderer_host/backing_store.h" | 10 #include "chrome/browser/renderer_host/backing_store.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnMsgFocus) | 128 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnMsgFocus) |
| 129 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnMsgBlur) | 129 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnMsgBlur) |
| 130 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnMsgSetCursor) | 130 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnMsgSetCursor) |
| 131 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeUpdateStatus, OnMsgImeUpdateStatus) | 131 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeUpdateStatus, OnMsgImeUpdateStatus) |
| 132 #if defined(OS_LINUX) | 132 #if defined(OS_LINUX) |
| 133 IPC_MESSAGE_HANDLER(ViewHostMsg_CreatePluginContainer, | 133 IPC_MESSAGE_HANDLER(ViewHostMsg_CreatePluginContainer, |
| 134 OnMsgCreatePluginContainer) | 134 OnMsgCreatePluginContainer) |
| 135 IPC_MESSAGE_HANDLER(ViewHostMsg_DestroyPluginContainer, | 135 IPC_MESSAGE_HANDLER(ViewHostMsg_DestroyPluginContainer, |
| 136 OnMsgDestroyPluginContainer) | 136 OnMsgDestroyPluginContainer) |
| 137 #elif defined(OS_MACOSX) | 137 #elif defined(OS_MACOSX) |
| 138 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_ShowPopup, OnMsgShowPopup(msg)) | 138 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) |
| 139 IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnMsgGetScreenInfo) | 139 IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnMsgGetScreenInfo) |
| 140 IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowRect, OnMsgGetWindowRect) | 140 IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowRect, OnMsgGetWindowRect) |
| 141 IPC_MESSAGE_HANDLER(ViewHostMsg_GetRootWindowRect, OnMsgGetRootWindowRect) | 141 IPC_MESSAGE_HANDLER(ViewHostMsg_GetRootWindowRect, OnMsgGetRootWindowRect) |
| 142 #endif | 142 #endif |
| 143 IPC_MESSAGE_UNHANDLED_ERROR() | 143 IPC_MESSAGE_UNHANDLED_ERROR() |
| 144 IPC_END_MESSAGE_MAP() | 144 IPC_END_MESSAGE_MAP() |
| 145 | 145 |
| 146 bool RenderWidgetHost::Send(IPC::Message* msg) { | 146 bool RenderWidgetHost::Send(IPC::Message* msg) { |
| 147 return process_->Send(msg); | 147 return process_->Send(msg); |
| 148 } | 148 } |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 } | 745 } |
| 746 | 746 |
| 747 void RenderWidgetHost::OnMsgImeUpdateStatus(int control, | 747 void RenderWidgetHost::OnMsgImeUpdateStatus(int control, |
| 748 const gfx::Rect& caret_rect) { | 748 const gfx::Rect& caret_rect) { |
| 749 if (view_) { | 749 if (view_) { |
| 750 view_->IMEUpdateStatus(control, caret_rect); | 750 view_->IMEUpdateStatus(control, caret_rect); |
| 751 } | 751 } |
| 752 } | 752 } |
| 753 | 753 |
| 754 #if defined(OS_LINUX) | 754 #if defined(OS_LINUX) |
| 755 |
| 755 void RenderWidgetHost::OnMsgCreatePluginContainer( | 756 void RenderWidgetHost::OnMsgCreatePluginContainer( |
| 756 gfx::PluginWindowHandle *container) { | 757 gfx::PluginWindowHandle *container) { |
| 757 *container = view_->CreatePluginContainer(); | 758 *container = view_->CreatePluginContainer(); |
| 758 } | 759 } |
| 759 | 760 |
| 760 void RenderWidgetHost::OnMsgDestroyPluginContainer( | 761 void RenderWidgetHost::OnMsgDestroyPluginContainer( |
| 761 gfx::PluginWindowHandle container) { | 762 gfx::PluginWindowHandle container) { |
| 762 view_->DestroyPluginContainer(container); | 763 view_->DestroyPluginContainer(container); |
| 763 } | 764 } |
| 765 |
| 764 #elif defined(OS_MACOSX) | 766 #elif defined(OS_MACOSX) |
| 765 void RenderWidgetHost::OnMsgShowPopup(const IPC::Message& message) { | |
| 766 void* iter = NULL; | |
| 767 ViewHostMsg_ShowPopup_Params validated_params; | |
| 768 if (!IPC::ParamTraits<ViewHostMsg_ShowPopup_Params>::Read(&message, &iter, | |
| 769 &validated_params)) | |
| 770 return; | |
| 771 | 767 |
| 772 view_->ShowPopupWithItems(validated_params.bounds, | 768 void RenderWidgetHost::OnMsgShowPopup( |
| 773 validated_params.item_height, | 769 const ViewHostMsg_ShowPopup_Params& params) { |
| 774 validated_params.selected_item, | 770 view_->ShowPopupWithItems(params.bounds, |
| 775 validated_params.popup_items); | 771 params.item_height, |
| 772 params.selected_item, |
| 773 params.popup_items); |
| 776 } | 774 } |
| 777 | 775 |
| 778 void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId view, | 776 void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId view, |
| 779 WebScreenInfo* results) { | 777 WebScreenInfo* results) { |
| 780 gfx::NativeView native_view = view_ ? view_->GetNativeView() : NULL; | 778 gfx::NativeView native_view = view_ ? view_->GetNativeView() : NULL; |
| 781 *results = WebScreenInfoFactory::screenInfo(native_view); | 779 *results = WebScreenInfoFactory::screenInfo(native_view); |
| 782 } | 780 } |
| 783 | 781 |
| 784 void RenderWidgetHost::OnMsgGetWindowRect(gfx::NativeViewId window_id, | 782 void RenderWidgetHost::OnMsgGetWindowRect(gfx::NativeViewId window_id, |
| 785 gfx::Rect* results) { | 783 gfx::Rect* results) { |
| 786 if (view_) { | 784 if (view_) { |
| 787 *results = view_->GetWindowRect(); | 785 *results = view_->GetWindowRect(); |
| 788 } | 786 } |
| 789 } | 787 } |
| 790 | 788 |
| 791 void RenderWidgetHost::OnMsgGetRootWindowRect(gfx::NativeViewId window_id, | 789 void RenderWidgetHost::OnMsgGetRootWindowRect(gfx::NativeViewId window_id, |
| 792 gfx::Rect* results) { | 790 gfx::Rect* results) { |
| 793 if (view_) { | 791 if (view_) { |
| 794 *results = view_->GetRootWindowRect(); | 792 *results = view_->GetRootWindowRect(); |
| 795 } | 793 } |
| 796 } | 794 } |
| 795 |
| 797 #endif | 796 #endif |
| 798 | 797 |
| 799 void RenderWidgetHost::PaintBackingStoreRect(TransportDIB* bitmap, | 798 void RenderWidgetHost::PaintBackingStoreRect(TransportDIB* bitmap, |
| 800 const gfx::Rect& bitmap_rect, | 799 const gfx::Rect& bitmap_rect, |
| 801 const gfx::Size& view_size) { | 800 const gfx::Size& view_size) { |
| 802 // The view may be destroyed already. | 801 // The view may be destroyed already. |
| 803 if (!view_) | 802 if (!view_) |
| 804 return; | 803 return; |
| 805 | 804 |
| 806 if (is_hidden_) { | 805 if (is_hidden_) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 | 839 |
| 841 // TODO(darin): do we need to do something else if our backing store is not | 840 // TODO(darin): do we need to do something else if our backing store is not |
| 842 // the same size as the advertised view? maybe we just assume there is a | 841 // the same size as the advertised view? maybe we just assume there is a |
| 843 // full paint on its way? | 842 // full paint on its way? |
| 844 BackingStore* backing_store = BackingStoreManager::Lookup(this); | 843 BackingStore* backing_store = BackingStoreManager::Lookup(this); |
| 845 if (!backing_store || (backing_store->size() != view_size)) | 844 if (!backing_store || (backing_store->size() != view_size)) |
| 846 return; | 845 return; |
| 847 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, | 846 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, |
| 848 dx, dy, clip_rect, view_size); | 847 dx, dy, clip_rect, view_size); |
| 849 } | 848 } |
| OLD | NEW |