| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 46 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 47 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 47 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 48 #include "content/browser/renderer_host/render_widget_resize_helper.h" | 48 #include "content/browser/renderer_host/render_widget_resize_helper.h" |
| 49 #include "content/common/content_constants_internal.h" | 49 #include "content/common/content_constants_internal.h" |
| 50 #include "content/common/cursors/webcursor.h" | 50 #include "content/common/cursors/webcursor.h" |
| 51 #include "content/common/frame_messages.h" | 51 #include "content/common/frame_messages.h" |
| 52 #include "content/common/gpu/gpu_messages.h" | 52 #include "content/common/gpu/gpu_messages.h" |
| 53 #include "content/common/host_shared_bitmap_manager.h" | 53 #include "content/common/host_shared_bitmap_manager.h" |
| 54 #include "content/common/input_messages.h" | 54 #include "content/common/input_messages.h" |
| 55 #include "content/common/view_messages.h" | 55 #include "content/common/view_messages.h" |
| 56 #include "content/public/browser/bad_message.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 GetProcess()->ReceivedBadMessage(BadMessage::RWH_SYNTHETIC_GESTURE); |
| 1604 GetProcess()->ReceivedBadMessage(); | |
| 1605 return; | 1604 return; |
| 1606 } | 1605 } |
| 1607 | 1606 |
| 1608 QueueSyntheticGesture( | 1607 QueueSyntheticGesture( |
| 1609 SyntheticGesture::Create(*gesture_packet.gesture_params()), | 1608 SyntheticGesture::Create(*gesture_packet.gesture_params()), |
| 1610 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, | 1609 base::Bind(&RenderWidgetHostImpl::OnSyntheticGestureCompleted, |
| 1611 weak_factory_.GetWeakPtr())); | 1610 weak_factory_.GetWeakPtr())); |
| 1612 } | 1611 } |
| 1613 | 1612 |
| 1614 void RenderWidgetHostImpl::OnFocus() { | 1613 void RenderWidgetHostImpl::OnFocus() { |
| 1615 // Only RenderViewHost can deal with that message. | 1614 // Only RenderViewHost can deal with that message. |
| 1616 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH4")); | 1615 GetProcess()->ReceivedBadMessage(BadMessage::RWH_FOCUS); |
| 1617 GetProcess()->ReceivedBadMessage(); | |
| 1618 } | 1616 } |
| 1619 | 1617 |
| 1620 void RenderWidgetHostImpl::OnBlur() { | 1618 void RenderWidgetHostImpl::OnBlur() { |
| 1621 // Only RenderViewHost can deal with that message. | 1619 // Only RenderViewHost can deal with that message. |
| 1622 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH5")); | 1620 GetProcess()->ReceivedBadMessage(BadMessage::RWH_BLUR); |
| 1623 GetProcess()->ReceivedBadMessage(); | |
| 1624 } | 1621 } |
| 1625 | 1622 |
| 1626 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { | 1623 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { |
| 1627 SetCursor(cursor); | 1624 SetCursor(cursor); |
| 1628 } | 1625 } |
| 1629 | 1626 |
| 1630 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( | 1627 void RenderWidgetHostImpl::SetTouchEventEmulationEnabled( |
| 1631 bool enabled, ui::GestureProviderConfigType config_type) { | 1628 bool enabled, ui::GestureProviderConfigType config_type) { |
| 1632 if (enabled) { | 1629 if (enabled) { |
| 1633 if (!touch_emulator_) | 1630 if (!touch_emulator_) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 void RenderWidgetHostImpl::OnShowDisambiguationPopup( | 1685 void RenderWidgetHostImpl::OnShowDisambiguationPopup( |
| 1689 const gfx::Rect& rect_pixels, | 1686 const gfx::Rect& rect_pixels, |
| 1690 const gfx::Size& size, | 1687 const gfx::Size& size, |
| 1691 const cc::SharedBitmapId& id) { | 1688 const cc::SharedBitmapId& id) { |
| 1692 DCHECK(!rect_pixels.IsEmpty()); | 1689 DCHECK(!rect_pixels.IsEmpty()); |
| 1693 DCHECK(!size.IsEmpty()); | 1690 DCHECK(!size.IsEmpty()); |
| 1694 | 1691 |
| 1695 scoped_ptr<cc::SharedBitmap> bitmap = | 1692 scoped_ptr<cc::SharedBitmap> bitmap = |
| 1696 HostSharedBitmapManager::current()->GetSharedBitmapFromId(size, id); | 1693 HostSharedBitmapManager::current()->GetSharedBitmapFromId(size, id); |
| 1697 if (!bitmap) { | 1694 if (!bitmap) { |
| 1698 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH6")); | 1695 GetProcess()->ReceivedBadMessage(BadMessage::RWH_SHARED_BITMAP); |
| 1699 GetProcess()->ReceivedBadMessage(); | |
| 1700 return; | 1696 return; |
| 1701 } | 1697 } |
| 1702 | 1698 |
| 1703 DCHECK(bitmap->pixels()); | 1699 DCHECK(bitmap->pixels()); |
| 1704 | 1700 |
| 1705 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); | 1701 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); |
| 1706 SkBitmap zoomed_bitmap; | 1702 SkBitmap zoomed_bitmap; |
| 1707 zoomed_bitmap.installPixels(info, bitmap->pixels(), info.minRowBytes()); | 1703 zoomed_bitmap.installPixels(info, bitmap->pixels(), info.minRowBytes()); |
| 1708 | 1704 |
| 1709 // Note that |rect| is in coordinates of pixels relative to the window origin. | 1705 // 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)) { | 1880 touch_emulator_->HandleTouchEventAck(event.event, ack_result)) { |
| 1885 return; | 1881 return; |
| 1886 } | 1882 } |
| 1887 | 1883 |
| 1888 if (view_) | 1884 if (view_) |
| 1889 view_->ProcessAckedTouchEvent(event, ack_result); | 1885 view_->ProcessAckedTouchEvent(event, ack_result); |
| 1890 } | 1886 } |
| 1891 | 1887 |
| 1892 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) { | 1888 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) { |
| 1893 if (type == BAD_ACK_MESSAGE) { | 1889 if (type == BAD_ACK_MESSAGE) { |
| 1894 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH2")); | 1890 process_->ReceivedBadMessage(BadMessage::RWH_BAD_ACK_MESSAGE); |
| 1895 process_->ReceivedBadMessage(); | |
| 1896 } else if (type == UNEXPECTED_EVENT_TYPE) { | 1891 } else if (type == UNEXPECTED_EVENT_TYPE) { |
| 1897 suppress_next_char_events_ = false; | 1892 suppress_next_char_events_ = false; |
| 1898 } | 1893 } |
| 1899 } | 1894 } |
| 1900 | 1895 |
| 1901 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( | 1896 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( |
| 1902 SyntheticGesture::Result result) { | 1897 SyntheticGesture::Result result) { |
| 1903 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); | 1898 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); |
| 1904 } | 1899 } |
| 1905 | 1900 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 } | 2180 } |
| 2186 #endif | 2181 #endif |
| 2187 | 2182 |
| 2188 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2183 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2189 if (view_) | 2184 if (view_) |
| 2190 return view_->PreferredReadbackFormat(); | 2185 return view_->PreferredReadbackFormat(); |
| 2191 return kN32_SkColorType; | 2186 return kN32_SkColorType; |
| 2192 } | 2187 } |
| 2193 | 2188 |
| 2194 } // namespace content | 2189 } // namespace content |
| OLD | NEW |