Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2485693003: Drag-and-drop: DragEnter, DragOver, DragLeave, DragDrop (Closed)
Patch Set: Rebased. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "content/public/common/content_constants.h" 72 #include "content/public/common/content_constants.h"
73 #include "content/public/common/content_switches.h" 73 #include "content/public/common/content_switches.h"
74 #include "content/public/common/result_codes.h" 74 #include "content/public/common/result_codes.h"
75 #include "content/public/common/web_preferences.h" 75 #include "content/public/common/web_preferences.h"
76 #include "gpu/GLES2/gl2extchromium.h" 76 #include "gpu/GLES2/gl2extchromium.h"
77 #include "gpu/command_buffer/service/gpu_switches.h" 77 #include "gpu/command_buffer/service/gpu_switches.h"
78 #include "gpu/ipc/common/gpu_messages.h" 78 #include "gpu/ipc/common/gpu_messages.h"
79 #include "skia/ext/image_operations.h" 79 #include "skia/ext/image_operations.h"
80 #include "skia/ext/platform_canvas.h" 80 #include "skia/ext/platform_canvas.h"
81 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 81 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
82 #include "ui/base/clipboard/clipboard.h"
82 #include "ui/events/blink/web_input_event_traits.h" 83 #include "ui/events/blink/web_input_event_traits.h"
83 #include "ui/events/event.h" 84 #include "ui/events/event.h"
84 #include "ui/events/keycodes/keyboard_codes.h" 85 #include "ui/events/keycodes/keyboard_codes.h"
85 #include "ui/gfx/color_space.h" 86 #include "ui/gfx/color_space.h"
86 #include "ui/gfx/geometry/size_conversions.h" 87 #include "ui/gfx/geometry/size_conversions.h"
87 #include "ui/gfx/geometry/vector2d_conversions.h" 88 #include "ui/gfx/geometry/vector2d_conversions.h"
88 #include "ui/gfx/image/image_skia.h" 89 #include "ui/gfx/image/image_skia.h"
89 #include "ui/gfx/skbitmap_operations.h" 90 #include "ui/gfx/skbitmap_operations.h"
90 #include "ui/snapshot/snapshot.h" 91 #include "ui/snapshot/snapshot.h"
91 92
92 #if defined(OS_MACOSX) 93 #if defined(OS_MACOSX)
93 #include "device/power_save_blocker/power_save_blocker.h" 94 #include "device/power_save_blocker/power_save_blocker.h"
94 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" 95 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
95 #endif 96 #endif
96 97
97 using base::Time; 98 using base::Time;
98 using base::TimeDelta; 99 using base::TimeDelta;
99 using base::TimeTicks; 100 using base::TimeTicks;
101 using blink::WebDragOperationsMask;
100 using blink::WebGestureEvent; 102 using blink::WebGestureEvent;
101 using blink::WebInputEvent; 103 using blink::WebInputEvent;
102 using blink::WebKeyboardEvent; 104 using blink::WebKeyboardEvent;
103 using blink::WebMouseEvent; 105 using blink::WebMouseEvent;
104 using blink::WebMouseWheelEvent; 106 using blink::WebMouseWheelEvent;
105 using blink::WebTextDirection; 107 using blink::WebTextDirection;
106 108
107 namespace content { 109 namespace content {
108 namespace { 110 namespace {
109 111
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 wrap_gesture_scroll_end.type = blink::WebInputEvent::GestureScrollEnd; 177 wrap_gesture_scroll_end.type = blink::WebInputEvent::GestureScrollEnd;
176 wrap_gesture_scroll_end.timeStampSeconds = gesture_event.timeStampSeconds; 178 wrap_gesture_scroll_end.timeStampSeconds = gesture_event.timeStampSeconds;
177 wrap_gesture_scroll_end.sourceDevice = gesture_event.sourceDevice; 179 wrap_gesture_scroll_end.sourceDevice = gesture_event.sourceDevice;
178 wrap_gesture_scroll_end.resendingPluginId = gesture_event.resendingPluginId; 180 wrap_gesture_scroll_end.resendingPluginId = gesture_event.resendingPluginId;
179 wrap_gesture_scroll_end.data.scrollEnd.deltaUnits = 181 wrap_gesture_scroll_end.data.scrollEnd.deltaUnits =
180 gesture_event.data.scrollUpdate.deltaUnits; 182 gesture_event.data.scrollUpdate.deltaUnits;
181 183
182 return wrap_gesture_scroll_end; 184 return wrap_gesture_scroll_end;
183 } 185 }
184 186
187 std::vector<DropData::Metadata> DropDataToMetaData(const DropData& drop_data) {
188 std::vector<DropData::Metadata> metadata;
189 if (!drop_data.text.is_null()) {
190 metadata.push_back(DropData::Metadata::CreateForMimeType(
191 DropData::Kind::STRING,
192 base::ASCIIToUTF16(ui::Clipboard::kMimeTypeText)));
193 }
194
195 if (drop_data.url.is_valid()) {
196 metadata.push_back(DropData::Metadata::CreateForMimeType(
197 DropData::Kind::STRING,
198 base::ASCIIToUTF16(ui::Clipboard::kMimeTypeURIList)));
199 }
200
201 if (!drop_data.html.is_null()) {
202 metadata.push_back(DropData::Metadata::CreateForMimeType(
203 DropData::Kind::STRING,
204 base::ASCIIToUTF16(ui::Clipboard::kMimeTypeHTML)));
205 }
206
207 // On Aura, filenames are available before drop.
208 for (const auto& file_info : drop_data.filenames) {
209 if (!file_info.path.empty()) {
210 metadata.push_back(DropData::Metadata::CreateForFilePath(file_info.path));
211 }
212 }
213
214 // On Android, only files' mime types are available before drop.
215 for (const auto& mime_type : drop_data.file_mime_types) {
216 if (!mime_type.empty()) {
217 metadata.push_back(DropData::Metadata::CreateForMimeType(
218 DropData::Kind::FILENAME, mime_type));
219 }
220 }
221
222 for (const auto& file_system_file : drop_data.file_system_files) {
223 if (!file_system_file.url.is_empty()) {
224 metadata.push_back(
225 DropData::Metadata::CreateForFileSystemUrl(file_system_file.url));
226 }
227 }
228
229 for (const auto& custom_data_item : drop_data.custom_data) {
230 metadata.push_back(DropData::Metadata::CreateForMimeType(
231 DropData::Kind::STRING, custom_data_item.first));
232 }
233
234 return metadata;
235 }
236
185 } // namespace 237 } // namespace
186 238
187 /////////////////////////////////////////////////////////////////////////////// 239 ///////////////////////////////////////////////////////////////////////////////
188 // RenderWidgetHostImpl 240 // RenderWidgetHostImpl
189 241
190 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, 242 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
191 RenderProcessHost* process, 243 RenderProcessHost* process,
192 int32_t routing_id, 244 int32_t routing_id,
193 bool hidden) 245 bool hidden)
194 : renderer_initialized_(false), 246 : renderer_initialized_(false),
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 if (IsUseZoomForDSFEnabled()) 1322 if (IsUseZoomForDSFEnabled())
1271 input_router_->SetDeviceScaleFactor(result->device_scale_factor); 1323 input_router_->SetDeviceScaleFactor(result->device_scale_factor);
1272 } 1324 }
1273 1325
1274 void RenderWidgetHostImpl::HandleCompositorProto( 1326 void RenderWidgetHostImpl::HandleCompositorProto(
1275 const std::vector<uint8_t>& proto) { 1327 const std::vector<uint8_t>& proto) {
1276 DCHECK(!proto.empty()); 1328 DCHECK(!proto.empty());
1277 Send(new ViewMsg_HandleCompositorProto(GetRoutingID(), proto)); 1329 Send(new ViewMsg_HandleCompositorProto(GetRoutingID(), proto));
1278 } 1330 }
1279 1331
1332 void RenderWidgetHostImpl::DragTargetDragEnter(
1333 const DropData& drop_data,
1334 const gfx::Point& client_pt,
1335 const gfx::Point& screen_pt,
1336 WebDragOperationsMask operations_allowed,
1337 int key_modifiers) {
1338 std::vector<DropData::Metadata> metadata = DropDataToMetaData(drop_data);
1339 Send(new DragMsg_TargetDragEnter(GetRoutingID(), metadata, client_pt,
1340 screen_pt, operations_allowed,
1341 key_modifiers));
1342 }
1343
1344 void RenderWidgetHostImpl::DragTargetDragOver(
1345 const gfx::Point& client_pt,
1346 const gfx::Point& screen_pt,
1347 WebDragOperationsMask operations_allowed,
1348 int key_modifiers) {
1349 Send(new DragMsg_TargetDragOver(GetRoutingID(), client_pt, screen_pt,
1350 operations_allowed, key_modifiers));
1351 }
1352
1353 void RenderWidgetHostImpl::DragTargetDragLeave() {
1354 Send(new DragMsg_TargetDragLeave(GetRoutingID()));
1355 }
1356
1357 void RenderWidgetHostImpl::DragTargetDrop(const DropData& drop_data,
1358 const gfx::Point& client_pt,
1359 const gfx::Point& screen_pt,
1360 int key_modifiers) {
1361 DropData drop_data_with_permissions(drop_data);
1362 delegate()->GetRenderViewHost()->GrantFileAccessFromDropData(
1363 &drop_data_with_permissions);
1364 Send(new DragMsg_TargetDrop(GetRoutingID(), drop_data_with_permissions,
1365 client_pt, screen_pt, key_modifiers));
1366 }
1367
1280 void RenderWidgetHostImpl::NotifyScreenInfoChanged() { 1368 void RenderWidgetHostImpl::NotifyScreenInfoChanged() {
1281 if (delegate_) 1369 if (delegate_)
1282 delegate_->ScreenInfoChanged(); 1370 delegate_->ScreenInfoChanged();
1283 1371
1284 // The resize message (which may not happen immediately) will carry with it 1372 // The resize message (which may not happen immediately) will carry with it
1285 // the screen info as well as the new size (if the screen has changed scale 1373 // the screen info as well as the new size (if the screen has changed scale
1286 // factor). 1374 // factor).
1287 WasResized(); 1375 WasResized();
1288 } 1376 }
1289 1377
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2360 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2273 } 2361 }
2274 2362
2275 BrowserAccessibilityManager* 2363 BrowserAccessibilityManager*
2276 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2364 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2277 return delegate_ ? 2365 return delegate_ ?
2278 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2366 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2279 } 2367 }
2280 2368
2281 } // namespace content 2369 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698