| 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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 DCHECK(sizes->empty()); | 385 DCHECK(sizes->empty()); |
| 386 sizes->reserve(web_sizes.size()); | 386 sizes->reserve(web_sizes.size()); |
| 387 for (size_t i = 0; i < web_sizes.size(); ++i) | 387 for (size_t i = 0; i < web_sizes.size(); ++i) |
| 388 sizes->push_back(gfx::Size(web_sizes[i])); | 388 sizes->push_back(gfx::Size(web_sizes[i])); |
| 389 } | 389 } |
| 390 | 390 |
| 391 /////////////////////////////////////////////////////////////////////////////// | 391 /////////////////////////////////////////////////////////////////////////////// |
| 392 | 392 |
| 393 namespace { | 393 namespace { |
| 394 | 394 |
| 395 WebDragData DropMetaDataToWebDragData( |
| 396 const std::vector<DropData::Metadata>& drop_meta_data) { |
| 397 std::vector<WebDragData::Item> item_list; |
| 398 for (const auto& meta_data_item : drop_meta_data) { |
| 399 if (meta_data_item.kind == DropData::Kind::STRING) { |
| 400 WebDragData::Item item; |
| 401 item.storageType = WebDragData::Item::StorageTypeString; |
| 402 item.stringType = meta_data_item.mime_type; |
| 403 item_list.push_back(item); |
| 404 continue; |
| 405 } |
| 406 |
| 407 // TODO(hush): crbug.com/584789. Blink needs to support creating a file with |
| 408 // just the mimetype. This is needed to drag files to WebView on Android |
| 409 // platform. |
| 410 if ((meta_data_item.kind == DropData::Kind::FILENAME) && |
| 411 !meta_data_item.filename.empty()) { |
| 412 WebDragData::Item item; |
| 413 item.storageType = WebDragData::Item::StorageTypeFilename; |
| 414 item.filenameData = meta_data_item.filename.AsUTF16Unsafe(); |
| 415 item_list.push_back(item); |
| 416 continue; |
| 417 } |
| 418 |
| 419 if (meta_data_item.kind == DropData::Kind::FILESYSTEMFILE) { |
| 420 WebDragData::Item item; |
| 421 item.storageType = WebDragData::Item::StorageTypeFileSystemFile; |
| 422 item.fileSystemURL = meta_data_item.file_system_url; |
| 423 item_list.push_back(item); |
| 424 continue; |
| 425 } |
| 426 } |
| 427 |
| 428 WebDragData result; |
| 429 result.initialize(); |
| 430 result.setItems(item_list); |
| 431 return result; |
| 432 } |
| 433 |
| 395 WebDragData DropDataToWebDragData(const DropData& drop_data) { | 434 WebDragData DropDataToWebDragData(const DropData& drop_data) { |
| 396 std::vector<WebDragData::Item> item_list; | 435 std::vector<WebDragData::Item> item_list; |
| 397 | 436 |
| 398 // These fields are currently unused when dragging into WebKit. | 437 // These fields are currently unused when dragging into WebKit. |
| 399 DCHECK(drop_data.download_metadata.empty()); | 438 DCHECK(drop_data.download_metadata.empty()); |
| 400 DCHECK(drop_data.file_contents.empty()); | 439 DCHECK(drop_data.file_contents.empty()); |
| 401 DCHECK(drop_data.file_description_filename.empty()); | 440 DCHECK(drop_data.file_description_filename.empty()); |
| 402 | 441 |
| 403 if (!drop_data.text.is_null()) { | 442 if (!drop_data.text.is_null()) { |
| 404 WebDragData::Item item; | 443 WebDragData::Item item; |
| 405 item.storageType = WebDragData::Item::StorageTypeString; | 444 item.storageType = WebDragData::Item::StorageTypeString; |
| 406 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText); | 445 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText); |
| 407 item.stringData = drop_data.text.string(); | 446 item.stringData = drop_data.text.string(); |
| 408 item_list.push_back(item); | 447 item_list.push_back(item); |
| 409 } | 448 } |
| 410 | 449 |
| 411 // TODO(dcheng): Do we need to distinguish between null and empty URLs? Is it | |
| 412 // meaningful to write an empty URL to the clipboard? | |
| 413 if (!drop_data.url.is_empty()) { | 450 if (!drop_data.url.is_empty()) { |
| 414 WebDragData::Item item; | 451 WebDragData::Item item; |
| 415 item.storageType = WebDragData::Item::StorageTypeString; | 452 item.storageType = WebDragData::Item::StorageTypeString; |
| 416 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList); | 453 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList); |
| 417 item.stringData = WebString::fromUTF8(drop_data.url.spec()); | 454 item.stringData = WebString::fromUTF8(drop_data.url.spec()); |
| 418 item.title = drop_data.url_title; | 455 item.title = drop_data.url_title; |
| 419 item_list.push_back(item); | 456 item_list.push_back(item); |
| 420 } | 457 } |
| 421 | 458 |
| 422 if (!drop_data.html.is_null()) { | 459 if (!drop_data.html.is_null()) { |
| (...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2324 | 2361 |
| 2325 enabled_bindings_ |= enabled_bindings_flags; | 2362 enabled_bindings_ |= enabled_bindings_flags; |
| 2326 | 2363 |
| 2327 // Keep track of the total bindings accumulated in this process. | 2364 // Keep track of the total bindings accumulated in this process. |
| 2328 RenderProcess::current()->AddBindings(enabled_bindings_flags); | 2365 RenderProcess::current()->AddBindings(enabled_bindings_flags); |
| 2329 | 2366 |
| 2330 if (main_render_frame_) | 2367 if (main_render_frame_) |
| 2331 main_render_frame_->MaybeEnableMojoBindings(); | 2368 main_render_frame_->MaybeEnableMojoBindings(); |
| 2332 } | 2369 } |
| 2333 | 2370 |
| 2334 void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, | 2371 void RenderViewImpl::OnDragTargetDragEnter( |
| 2335 const gfx::Point& client_point, | 2372 const std::vector<DropData::Metadata>& drop_meta_data, |
| 2336 const gfx::Point& screen_point, | 2373 const gfx::Point& client_point, |
| 2337 WebDragOperationsMask ops, | 2374 const gfx::Point& screen_point, |
| 2338 int key_modifiers) { | 2375 WebDragOperationsMask ops, |
| 2376 int key_modifiers) { |
| 2339 WebDragOperation operation = webview()->dragTargetDragEnter( | 2377 WebDragOperation operation = webview()->dragTargetDragEnter( |
| 2340 DropDataToWebDragData(drop_data), | 2378 DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point, |
| 2341 ConvertWindowPointToViewport(client_point), | 2379 ops, key_modifiers); |
| 2342 screen_point, | |
| 2343 ops, | |
| 2344 key_modifiers); | |
| 2345 | 2380 |
| 2346 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); | 2381 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
| 2347 } | 2382 } |
| 2348 | 2383 |
| 2349 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, | 2384 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
| 2350 const gfx::Point& screen_point, | 2385 const gfx::Point& screen_point, |
| 2351 WebDragOperationsMask ops, | 2386 WebDragOperationsMask ops, |
| 2352 int key_modifiers) { | 2387 int key_modifiers) { |
| 2353 WebDragOperation operation = webview()->dragTargetDragOver( | 2388 WebDragOperation operation = webview()->dragTargetDragOver( |
| 2354 ConvertWindowPointToViewport(client_point), | 2389 ConvertWindowPointToViewport(client_point), |
| 2355 screen_point, | 2390 screen_point, |
| 2356 ops, | 2391 ops, |
| 2357 key_modifiers); | 2392 key_modifiers); |
| 2358 | 2393 |
| 2359 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); | 2394 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
| 2360 } | 2395 } |
| 2361 | 2396 |
| 2362 void RenderViewImpl::OnDragTargetDragLeave() { | 2397 void RenderViewImpl::OnDragTargetDragLeave() { |
| 2363 webview()->dragTargetDragLeave(); | 2398 webview()->dragTargetDragLeave(); |
| 2364 } | 2399 } |
| 2365 | 2400 |
| 2366 void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, | 2401 void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data, |
| 2402 const gfx::Point& client_point, |
| 2367 const gfx::Point& screen_point, | 2403 const gfx::Point& screen_point, |
| 2368 int key_modifiers) { | 2404 int key_modifiers) { |
| 2369 webview()->dragTargetDrop( | 2405 webview()->dragTargetDrop(DropDataToWebDragData(drop_data), client_point, |
| 2370 ConvertWindowPointToViewport(client_point), screen_point, key_modifiers); | 2406 screen_point, key_modifiers); |
| 2371 } | 2407 } |
| 2372 | 2408 |
| 2373 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, | 2409 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, |
| 2374 const gfx::Point& screen_point, | 2410 const gfx::Point& screen_point, |
| 2375 WebDragOperation op) { | 2411 WebDragOperation op) { |
| 2376 webview()->dragSourceEndedAt( | 2412 webview()->dragSourceEndedAt( |
| 2377 ConvertWindowPointToViewport(client_point), screen_point, op); | 2413 ConvertWindowPointToViewport(client_point), screen_point, op); |
| 2378 } | 2414 } |
| 2379 | 2415 |
| 2380 void RenderViewImpl::OnDragSourceSystemDragEnded() { | 2416 void RenderViewImpl::OnDragSourceSystemDragEnded() { |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3236 return render_frame->focused_pepper_plugin(); | 3272 return render_frame->focused_pepper_plugin(); |
| 3237 } | 3273 } |
| 3238 frame = frame->traverseNext(false); | 3274 frame = frame->traverseNext(false); |
| 3239 } | 3275 } |
| 3240 | 3276 |
| 3241 return nullptr; | 3277 return nullptr; |
| 3242 } | 3278 } |
| 3243 #endif | 3279 #endif |
| 3244 | 3280 |
| 3245 } // namespace content | 3281 } // namespace content |
| OLD | NEW |