| 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 |
| 11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
| 16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/metrics/field_trial.h" | 18 #include "base/metrics/field_trial.h" |
| 19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/thread_task_runner_handle.h" | 22 #include "base/thread_task_runner_handle.h" |
| 23 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
| 24 #include "cc/base/switches.h" | 24 #include "cc/base/switches.h" |
| 25 #include "cc/output/compositor_frame.h" | 25 #include "cc/output/compositor_frame.h" |
| 26 #include "cc/output/compositor_frame_ack.h" | 26 #include "cc/output/compositor_frame_ack.h" |
| 27 #include "content/browser/accessibility/accessibility_mode_helper.h" | 27 #include "content/browser/accessibility/accessibility_mode_helper.h" |
| 28 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 28 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 29 #include "content/browser/bad_message.h" |
| 29 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 30 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 30 #include "content/browser/gpu/compositor_util.h" | 31 #include "content/browser/gpu/compositor_util.h" |
| 31 #include "content/browser/gpu/gpu_process_host.h" | 32 #include "content/browser/gpu/gpu_process_host.h" |
| 32 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 33 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 33 #include "content/browser/gpu/gpu_surface_tracker.h" | 34 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 34 #include "content/browser/renderer_host/dip_util.h" | 35 #include "content/browser/renderer_host/dip_util.h" |
| 35 #include "content/browser/renderer_host/frame_metadata_util.h" | 36 #include "content/browser/renderer_host/frame_metadata_util.h" |
| 36 #include "content/browser/renderer_host/input/input_router_config_helper.h" | 37 #include "content/browser/renderer_host/input/input_router_config_helper.h" |
| 37 #include "content/browser/renderer_host/input/input_router_impl.h" | 38 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 38 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 39 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 #include "content/common/cursors/webcursor.h" | 51 #include "content/common/cursors/webcursor.h" |
| 51 #include "content/common/frame_messages.h" | 52 #include "content/common/frame_messages.h" |
| 52 #include "content/common/gpu/gpu_messages.h" | 53 #include "content/common/gpu/gpu_messages.h" |
| 53 #include "content/common/host_shared_bitmap_manager.h" | 54 #include "content/common/host_shared_bitmap_manager.h" |
| 54 #include "content/common/input_messages.h" | 55 #include "content/common/input_messages.h" |
| 55 #include "content/common/view_messages.h" | 56 #include "content/common/view_messages.h" |
| 56 #include "content/public/browser/native_web_keyboard_event.h" | 57 #include "content/public/browser/native_web_keyboard_event.h" |
| 57 #include "content/public/browser/notification_service.h" | 58 #include "content/public/browser/notification_service.h" |
| 58 #include "content/public/browser/notification_types.h" | 59 #include "content/public/browser/notification_types.h" |
| 59 #include "content/public/browser/render_widget_host_iterator.h" | 60 #include "content/public/browser/render_widget_host_iterator.h" |
| 60 #include "content/public/browser/user_metrics.h" | |
| 61 #include "content/public/common/content_constants.h" | 61 #include "content/public/common/content_constants.h" |
| 62 #include "content/public/common/content_switches.h" | 62 #include "content/public/common/content_switches.h" |
| 63 #include "content/public/common/result_codes.h" | 63 #include "content/public/common/result_codes.h" |
| 64 #include "content/public/common/web_preferences.h" | 64 #include "content/public/common/web_preferences.h" |
| 65 #include "gpu/GLES2/gl2extchromium.h" | 65 #include "gpu/GLES2/gl2extchromium.h" |
| 66 #include "gpu/command_buffer/service/gpu_switches.h" | 66 #include "gpu/command_buffer/service/gpu_switches.h" |
| 67 #include "skia/ext/image_operations.h" | 67 #include "skia/ext/image_operations.h" |
| 68 #include "skia/ext/platform_canvas.h" | 68 #include "skia/ext/platform_canvas.h" |
| 69 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 69 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 70 #include "ui/events/event.h" | 70 #include "ui/events/event.h" |
| (...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 TimeTicks now = TimeTicks::Now(); | 1593 TimeTicks now = TimeTicks::Now(); |
| 1594 TimeDelta delta = now - update_start; | 1594 TimeDelta delta = now - update_start; |
| 1595 UMA_HISTOGRAM_TIMES("MPArch.RWH_DidUpdateBackingStore", delta); | 1595 UMA_HISTOGRAM_TIMES("MPArch.RWH_DidUpdateBackingStore", delta); |
| 1596 } | 1596 } |
| 1597 | 1597 |
| 1598 void RenderWidgetHostImpl::OnQueueSyntheticGesture( | 1598 void RenderWidgetHostImpl::OnQueueSyntheticGesture( |
| 1599 const SyntheticGesturePacket& gesture_packet) { | 1599 const SyntheticGesturePacket& gesture_packet) { |
| 1600 // Only allow untrustworthy gestures if explicitly enabled. | 1600 // Only allow untrustworthy gestures if explicitly enabled. |
| 1601 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1601 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1602 cc::switches::kEnableGpuBenchmarking)) { | 1602 cc::switches::kEnableGpuBenchmarking)) { |
| 1603 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH7")); | 1603 bad_message::ReceivedBadMessage(GetProcess(), |
| 1604 GetProcess()->ReceivedBadMessage(); | 1604 bad_message::RWH_SYNTHETIC_GESTURE); |
| 1605 return; | 1605 return; |
| 1606 } | 1606 } |
| 1607 | 1607 |
| 1608 QueueSyntheticGesture( | 1608 QueueSyntheticGesture( |
| 1609 SyntheticGesture::Create(*gesture_packet.gesture_params()), | 1609 SyntheticGesture::Create(*gesture_packet.gesture_params()), |
| 1610 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, | 1610 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, |
| 1611 weak_factory_.GetWeakPtr())); | 1611 weak_factory_.GetWeakPtr())); |
| 1612 } | 1612 } |
| 1613 | 1613 |
| 1614 void RenderWidgetHostImpl::OnFocus() { | 1614 void RenderWidgetHostImpl::OnFocus() { |
| 1615 // Only RenderViewHost can deal with that message. | 1615 // Only RenderViewHost can deal with that message. |
| 1616 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH4")); | 1616 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RWH_FOCUS); |
| 1617 GetProcess()->ReceivedBadMessage(); | |
| 1618 } | 1617 } |
| 1619 | 1618 |
| 1620 void RenderWidgetHostImpl::OnBlur() { | 1619 void RenderWidgetHostImpl::OnBlur() { |
| 1621 // Only RenderViewHost can deal with that message. | 1620 // Only RenderViewHost can deal with that message. |
| 1622 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH5")); | 1621 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RWH_BLUR); |
| 1623 GetProcess()->ReceivedBadMessage(); | |
| 1624 } | 1622 } |
| 1625 | 1623 |
| 1626 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { | 1624 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { |
| 1627 SetCursor(cursor); | 1625 SetCursor(cursor); |
| 1628 } | 1626 } |
| 1629 | 1627 |
| 1630 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( | 1628 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( |
| 1631 bool enabled, ui::GestureProviderConfigType config_type) { | 1629 bool enabled, ui::GestureProviderConfigType config_type) { |
| 1632 if (enabled) { | 1630 if (enabled) { |
| 1633 if (!touch_emulator_) | 1631 if (!touch_emulator_) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 void RenderWidgetHostImpl::OnShowDisambiguationPopup( | 1686 void RenderWidgetHostImpl::OnShowDisambiguationPopup( |
| 1689 const gfx::Rect& rect_pixels, | 1687 const gfx::Rect& rect_pixels, |
| 1690 const gfx::Size& size, | 1688 const gfx::Size& size, |
| 1691 const cc::SharedBitmapId& id) { | 1689 const cc::SharedBitmapId& id) { |
| 1692 DCHECK(!rect_pixels.IsEmpty()); | 1690 DCHECK(!rect_pixels.IsEmpty()); |
| 1693 DCHECK(!size.IsEmpty()); | 1691 DCHECK(!size.IsEmpty()); |
| 1694 | 1692 |
| 1695 scoped_ptr<cc::SharedBitmap> bitmap = | 1693 scoped_ptr<cc::SharedBitmap> bitmap = |
| 1696 HostSharedBitmapManager::current()->GetSharedBitmapFromId(size, id); | 1694 HostSharedBitmapManager::current()->GetSharedBitmapFromId(size, id); |
| 1697 if (!bitmap) { | 1695 if (!bitmap) { |
| 1698 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH6")); | 1696 bad_message::ReceivedBadMessage(GetProcess(), |
| 1699 GetProcess()->ReceivedBadMessage(); | 1697 bad_message::RWH_SHARED_BITMAP); |
| 1700 return; | 1698 return; |
| 1701 } | 1699 } |
| 1702 | 1700 |
| 1703 DCHECK(bitmap->pixels()); | 1701 DCHECK(bitmap->pixels()); |
| 1704 | 1702 |
| 1705 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); | 1703 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); |
| 1706 SkBitmap zoomed_bitmap; | 1704 SkBitmap zoomed_bitmap; |
| 1707 zoomed_bitmap.installPixels(info, bitmap->pixels(), info.minRowBytes()); | 1705 zoomed_bitmap.installPixels(info, bitmap->pixels(), info.minRowBytes()); |
| 1708 | 1706 |
| 1709 // Note that |rect| is in coordinates of pixels relative to the window origin. | 1707 // Note that |rect| is in coordinates of pixels relative to the window origin. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 touch_emulator_->HandleTouchEventAck(event.event, ack_result)) { | 1882 touch_emulator_->HandleTouchEventAck(event.event, ack_result)) { |
| 1885 return; | 1883 return; |
| 1886 } | 1884 } |
| 1887 | 1885 |
| 1888 if (view_) | 1886 if (view_) |
| 1889 view_->ProcessAckedTouchEvent(event, ack_result); | 1887 view_->ProcessAckedTouchEvent(event, ack_result); |
| 1890 } | 1888 } |
| 1891 | 1889 |
| 1892 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) { | 1890 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) { |
| 1893 if (type == BAD_ACK_MESSAGE) { | 1891 if (type == BAD_ACK_MESSAGE) { |
| 1894 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH2")); | 1892 bad_message::ReceivedBadMessage(process_, bad_message::RWH_BAD_ACK_MESSAGE); |
| 1895 process_->ReceivedBadMessage(); | |
| 1896 } else if (type == UNEXPECTED_EVENT_TYPE) { | 1893 } else if (type == UNEXPECTED_EVENT_TYPE) { |
| 1897 suppress_next_char_events_ = false; | 1894 suppress_next_char_events_ = false; |
| 1898 } | 1895 } |
| 1899 } | 1896 } |
| 1900 | 1897 |
| 1901 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( | 1898 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( |
| 1902 SyntheticGesture::Result result) { | 1899 SyntheticGesture::Result result) { |
| 1903 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); | 1900 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); |
| 1904 } | 1901 } |
| 1905 | 1902 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2125 } | 2122 } |
| 2126 #endif | 2123 #endif |
| 2127 | 2124 |
| 2128 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2125 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2129 if (view_) | 2126 if (view_) |
| 2130 return view_->PreferredReadbackFormat(); | 2127 return view_->PreferredReadbackFormat(); |
| 2131 return kN32_SkColorType; | 2128 return kN32_SkColorType; |
| 2132 } | 2129 } |
| 2133 | 2130 |
| 2134 } // namespace content | 2131 } // namespace content |
| OLD | NEW |