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_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
12 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
13 #include "content/browser/renderer_host/backing_store_skia.h" | 14 #include "content/browser/renderer_host/backing_store_skia.h" |
14 #include "content/browser/renderer_host/image_transport_client.h" | 15 #include "content/browser/renderer_host/image_transport_client.h" |
15 #include "content/browser/renderer_host/render_widget_host_impl.h" | 16 #include "content/browser/renderer_host/render_widget_host_impl.h" |
16 #include "content/browser/renderer_host/web_input_event_aura.h" | 17 #include "content/browser/renderer_host/web_input_event_aura.h" |
17 #include "content/common/gpu/client/gl_helper.h" | 18 #include "content/common/gpu/client/gl_helper.h" |
18 #include "content/common/gpu/gpu_messages.h" | 19 #include "content/common/gpu/gpu_messages.h" |
19 #include "content/port/browser/render_widget_host_view_port.h" | 20 #include "content/port/browser/render_widget_host_view_port.h" |
20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/common/content_switches.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
24 #include "ui/aura/client/aura_constants.h" | 26 #include "ui/aura/client/aura_constants.h" |
25 #include "ui/aura/client/tooltip_client.h" | 27 #include "ui/aura/client/tooltip_client.h" |
26 #include "ui/aura/client/window_types.h" | 28 #include "ui/aura/client/window_types.h" |
27 #include "ui/aura/env.h" | 29 #include "ui/aura/env.h" |
28 #include "ui/aura/event.h" | 30 #include "ui/aura/event.h" |
29 #include "ui/aura/root_window.h" | 31 #include "ui/aura/root_window.h" |
30 #include "ui/aura/window.h" | 32 #include "ui/aura/window.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | 116 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
115 results->availableRect = results->rect; | 117 results->availableRect = results->rect; |
116 // TODO(derat|oshima): Don't hardcode this. Get this from monitor object. | 118 // TODO(derat|oshima): Don't hardcode this. Get this from monitor object. |
117 results->depth = 24; | 119 results->depth = 24; |
118 results->depthPerComponent = 8; | 120 results->depthPerComponent = 8; |
119 int default_dpi = monitor.device_scale_factor() * 160; | 121 int default_dpi = monitor.device_scale_factor() * 160; |
120 results->verticalDPI = default_dpi; | 122 results->verticalDPI = default_dpi; |
121 results->horizontalDPI = default_dpi; | 123 results->horizontalDPI = default_dpi; |
122 } | 124 } |
123 | 125 |
| 126 bool ShouldSendPinchGesture() { |
| 127 static bool pinch_allowed = |
| 128 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) || |
| 129 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch); |
| 130 return pinch_allowed; |
| 131 } |
| 132 |
124 } // namespace | 133 } // namespace |
125 | 134 |
126 // We have to implement the WindowObserver interface on a separate object | 135 // We have to implement the WindowObserver interface on a separate object |
127 // because clang doesn't like implementing multiple interfaces that have | 136 // because clang doesn't like implementing multiple interfaces that have |
128 // methods with the same name. This object is owned by the | 137 // methods with the same name. This object is owned by the |
129 // RenderWidgetHostViewAura. | 138 // RenderWidgetHostViewAura. |
130 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { | 139 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { |
131 public: | 140 public: |
132 WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {} | 141 WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {} |
133 virtual ~WindowObserver() {} | 142 virtual ~WindowObserver() {} |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 host_->ForwardTouchEvent(touch_event_); | 1066 host_->ForwardTouchEvent(touch_event_); |
1058 UpdateWebTouchEventAfterDispatch(&touch_event_, point); | 1067 UpdateWebTouchEventAfterDispatch(&touch_event_, point); |
1059 return DecideTouchStatus(touch_event_, point); | 1068 return DecideTouchStatus(touch_event_, point); |
1060 } | 1069 } |
1061 | 1070 |
1062 return ui::TOUCH_STATUS_UNKNOWN; | 1071 return ui::TOUCH_STATUS_UNKNOWN; |
1063 } | 1072 } |
1064 | 1073 |
1065 ui::GestureStatus RenderWidgetHostViewAura::OnGestureEvent( | 1074 ui::GestureStatus RenderWidgetHostViewAura::OnGestureEvent( |
1066 aura::GestureEvent* event) { | 1075 aura::GestureEvent* event) { |
| 1076 // Pinch gestures are currently disabled by default. See crbug.com/128477. |
| 1077 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
| 1078 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
| 1079 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { |
| 1080 return ui::GESTURE_STATUS_CONSUMED; |
| 1081 } |
| 1082 |
1067 WebKit::WebGestureEvent gesture = content::MakeWebGestureEvent(event); | 1083 WebKit::WebGestureEvent gesture = content::MakeWebGestureEvent(event); |
1068 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 1084 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
1069 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an | 1085 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an |
1070 // event to stop any in-progress flings. | 1086 // event to stop any in-progress flings. |
1071 WebKit::WebGestureEvent fling_cancel = gesture; | 1087 WebKit::WebGestureEvent fling_cancel = gesture; |
1072 fling_cancel.type = WebKit::WebInputEvent::GestureFlingCancel; | 1088 fling_cancel.type = WebKit::WebInputEvent::GestureFlingCancel; |
1073 host_->ForwardGestureEvent(fling_cancel); | 1089 host_->ForwardGestureEvent(fling_cancel); |
1074 } | 1090 } |
1075 host_->ForwardGestureEvent(gesture); | 1091 host_->ForwardGestureEvent(gesture); |
1076 | 1092 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 1309 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
1294 RenderWidgetHost* widget) { | 1310 RenderWidgetHost* widget) { |
1295 return new RenderWidgetHostViewAura(widget); | 1311 return new RenderWidgetHostViewAura(widget); |
1296 } | 1312 } |
1297 | 1313 |
1298 // static | 1314 // static |
1299 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( | 1315 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( |
1300 WebKit::WebScreenInfo* results) { | 1316 WebKit::WebScreenInfo* results) { |
1301 GetScreenInfoForWindow(results, NULL); | 1317 GetScreenInfoForWindow(results, NULL); |
1302 } | 1318 } |
OLD | NEW |