| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override { | 422 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override { |
| 423 // The WebWidget handles mouse lock in WebKit's handleInputEvent(). | 423 // The WebWidget handles mouse lock in WebKit's handleInputEvent(). |
| 424 return false; | 424 return false; |
| 425 } | 425 } |
| 426 | 426 |
| 427 private: | 427 private: |
| 428 blink::WebWidget* webwidget_; | 428 blink::WebWidget* webwidget_; |
| 429 }; | 429 }; |
| 430 | 430 |
| 431 WebDragData DropDataToWebDragData(const DropData& drop_data) { | 431 WebDragData DropDataToWebDragData(const DropData& drop_data, |
| 432 bool is_meta_data) { |
| 432 std::vector<WebDragData::Item> item_list; | 433 std::vector<WebDragData::Item> item_list; |
| 433 | 434 |
| 434 // These fields are currently unused when dragging into WebKit. | 435 // These fields are currently unused when dragging into WebKit. |
| 435 DCHECK(drop_data.download_metadata.empty()); | 436 DCHECK(drop_data.download_metadata.empty()); |
| 436 DCHECK(drop_data.file_contents.empty()); | 437 DCHECK(drop_data.file_contents.empty()); |
| 437 DCHECK(drop_data.file_description_filename.empty()); | 438 DCHECK(drop_data.file_description_filename.empty()); |
| 438 | 439 |
| 439 if (!drop_data.text.is_null()) { | 440 if (!drop_data.text.is_null()) { |
| 440 WebDragData::Item item; | 441 WebDragData::Item item; |
| 441 item.storageType = WebDragData::Item::StorageTypeString; | 442 item.storageType = WebDragData::Item::StorageTypeString; |
| 442 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText); | 443 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText); |
| 443 item.stringData = drop_data.text.string(); | 444 item.stringData = is_meta_data ? WebString::fromUTF8("") |
| 445 : WebString(drop_data.text.string()); |
| 444 item_list.push_back(item); | 446 item_list.push_back(item); |
| 445 } | 447 } |
| 446 | 448 |
| 447 // TODO(dcheng): Do we need to distinguish between null and empty URLs? Is it | 449 // TODO(dcheng): Do we need to distinguish between null and empty URLs? Is it |
| 448 // meaningful to write an empty URL to the clipboard? | 450 // meaningful to write an empty URL to the clipboard? |
| 449 if (!drop_data.url.is_empty()) { | 451 if (drop_data.has_url) { |
| 450 WebDragData::Item item; | 452 WebDragData::Item item; |
| 451 item.storageType = WebDragData::Item::StorageTypeString; | 453 item.storageType = WebDragData::Item::StorageTypeString; |
| 452 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList); | 454 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList); |
| 453 item.stringData = WebString::fromUTF8(drop_data.url.spec()); | 455 item.stringData = is_meta_data ? WebString::fromUTF8("") |
| 454 item.title = drop_data.url_title; | 456 : WebString::fromUTF8(drop_data.url.spec()); |
| 457 item.title = |
| 458 is_meta_data ? WebString::fromUTF8("") : WebString(drop_data.url_title); |
| 455 item_list.push_back(item); | 459 item_list.push_back(item); |
| 456 } | 460 } |
| 457 | 461 |
| 458 if (!drop_data.html.is_null()) { | 462 if (!drop_data.html.is_null()) { |
| 459 WebDragData::Item item; | 463 WebDragData::Item item; |
| 460 item.storageType = WebDragData::Item::StorageTypeString; | 464 item.storageType = WebDragData::Item::StorageTypeString; |
| 461 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeHTML); | 465 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeHTML); |
| 462 item.stringData = drop_data.html.string(); | 466 item.stringData = is_meta_data ? WebString::fromUTF8("") |
| 463 item.baseURL = drop_data.html_base_url; | 467 : WebString(drop_data.html.string()); |
| 468 item.baseURL = is_meta_data ? GURL() : drop_data.html_base_url; |
| 464 item_list.push_back(item); | 469 item_list.push_back(item); |
| 465 } | 470 } |
| 466 | 471 |
| 467 for (std::vector<ui::FileInfo>::const_iterator it = | 472 for (std::vector<ui::FileInfo>::const_iterator it = |
| 468 drop_data.filenames.begin(); | 473 drop_data.filenames.begin(); |
| 469 it != drop_data.filenames.end(); | 474 it != drop_data.filenames.end(); |
| 470 ++it) { | 475 ++it) { |
| 471 WebDragData::Item item; | 476 WebDragData::Item item; |
| 472 item.storageType = WebDragData::Item::StorageTypeFilename; | 477 item.storageType = WebDragData::Item::StorageTypeFilename; |
| 473 item.filenameData = it->path.AsUTF16Unsafe(); | 478 item.filenameData = is_meta_data ? WebString::fromUTF8("") |
| 474 item.displayNameData = it->display_name.AsUTF16Unsafe(); | 479 : WebString(it->path.AsUTF16Unsafe()); |
| 480 item.displayNameData = is_meta_data |
| 481 ? WebString::fromUTF8("") |
| 482 : WebString(it->display_name.AsUTF16Unsafe()); |
| 475 item_list.push_back(item); | 483 item_list.push_back(item); |
| 476 } | 484 } |
| 477 | 485 |
| 478 for (std::vector<DropData::FileSystemFileInfo>::const_iterator it = | 486 for (std::vector<DropData::FileSystemFileInfo>::const_iterator it = |
| 479 drop_data.file_system_files.begin(); | 487 drop_data.file_system_files.begin(); |
| 480 it != drop_data.file_system_files.end(); | 488 it != drop_data.file_system_files.end(); |
| 481 ++it) { | 489 ++it) { |
| 482 WebDragData::Item item; | 490 WebDragData::Item item; |
| 483 item.storageType = WebDragData::Item::StorageTypeFileSystemFile; | 491 item.storageType = WebDragData::Item::StorageTypeFileSystemFile; |
| 484 item.fileSystemURL = it->url; | 492 item.fileSystemURL = is_meta_data ? GURL() : it->url; |
| 485 item.fileSystemFileSize = it->size; | 493 item.fileSystemFileSize = is_meta_data ? 0 : it->size; |
| 486 item_list.push_back(item); | 494 item_list.push_back(item); |
| 487 } | 495 } |
| 488 | 496 |
| 489 for (std::map<base::string16, base::string16>::const_iterator it = | 497 for (std::map<base::string16, base::string16>::const_iterator it = |
| 490 drop_data.custom_data.begin(); | 498 drop_data.custom_data.begin(); |
| 491 it != drop_data.custom_data.end(); | 499 it != drop_data.custom_data.end(); |
| 492 ++it) { | 500 ++it) { |
| 493 WebDragData::Item item; | 501 WebDragData::Item item; |
| 494 item.storageType = WebDragData::Item::StorageTypeString; | 502 item.storageType = WebDragData::Item::StorageTypeString; |
| 495 item.stringType = it->first; | 503 item.stringType = it->first; |
| 496 item.stringData = it->second; | 504 item.stringData = |
| 505 is_meta_data ? WebString::fromUTF8("") : WebString(it->second); |
| 497 item_list.push_back(item); | 506 item_list.push_back(item); |
| 498 } | 507 } |
| 499 | 508 |
| 500 WebDragData result; | 509 WebDragData result; |
| 501 result.initialize(); | 510 result.initialize(); |
| 502 result.setItems(item_list); | 511 result.setItems(item_list); |
| 503 result.setFilesystemId(drop_data.filesystem_id); | 512 result.setFilesystemId(drop_data.filesystem_id); |
| 513 result.setCanReadContent(!is_meta_data); |
| 504 return result; | 514 return result; |
| 505 } | 515 } |
| 506 | 516 |
| 507 typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, | 517 typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, |
| 508 const base::string16&, | 518 const base::string16&, |
| 509 UScriptCode); | 519 UScriptCode); |
| 510 | 520 |
| 511 void SetStandardFontFamilyWrapper(WebSettings* settings, | 521 void SetStandardFontFamilyWrapper(WebSettings* settings, |
| 512 const base::string16& font, | 522 const base::string16& font, |
| 513 UScriptCode script) { | 523 UScriptCode script) { |
| (...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2375 if (main_render_frame_) | 2385 if (main_render_frame_) |
| 2376 main_render_frame_->MaybeEnableMojoBindings(); | 2386 main_render_frame_->MaybeEnableMojoBindings(); |
| 2377 } | 2387 } |
| 2378 | 2388 |
| 2379 void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, | 2389 void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, |
| 2380 const gfx::Point& client_point, | 2390 const gfx::Point& client_point, |
| 2381 const gfx::Point& screen_point, | 2391 const gfx::Point& screen_point, |
| 2382 WebDragOperationsMask ops, | 2392 WebDragOperationsMask ops, |
| 2383 int key_modifiers) { | 2393 int key_modifiers) { |
| 2384 WebDragOperation operation = webview()->dragTargetDragEnter( | 2394 WebDragOperation operation = webview()->dragTargetDragEnter( |
| 2385 DropDataToWebDragData(drop_data), | 2395 DropDataToWebDragData(drop_data, true), client_point, screen_point, ops, |
| 2386 ConvertWindowPointToViewport(client_point), | |
| 2387 screen_point, | |
| 2388 ops, | |
| 2389 key_modifiers); | 2396 key_modifiers); |
| 2390 | 2397 |
| 2391 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); | 2398 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
| 2392 } | 2399 } |
| 2393 | 2400 |
| 2394 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, | 2401 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
| 2395 const gfx::Point& screen_point, | 2402 const gfx::Point& screen_point, |
| 2396 WebDragOperationsMask ops, | 2403 WebDragOperationsMask ops, |
| 2397 int key_modifiers) { | 2404 int key_modifiers) { |
| 2398 WebDragOperation operation = webview()->dragTargetDragOver( | 2405 WebDragOperation operation = webview()->dragTargetDragOver( |
| 2399 ConvertWindowPointToViewport(client_point), | 2406 ConvertWindowPointToViewport(client_point), |
| 2400 screen_point, | 2407 screen_point, |
| 2401 ops, | 2408 ops, |
| 2402 key_modifiers); | 2409 key_modifiers); |
| 2403 | 2410 |
| 2404 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); | 2411 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
| 2405 } | 2412 } |
| 2406 | 2413 |
| 2407 void RenderViewImpl::OnDragTargetDragLeave() { | 2414 void RenderViewImpl::OnDragTargetDragLeave() { |
| 2408 webview()->dragTargetDragLeave(); | 2415 webview()->dragTargetDragLeave(); |
| 2409 } | 2416 } |
| 2410 | 2417 |
| 2411 void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, | 2418 void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data, |
| 2419 const gfx::Point& client_point, |
| 2412 const gfx::Point& screen_point, | 2420 const gfx::Point& screen_point, |
| 2413 int key_modifiers) { | 2421 int key_modifiers) { |
| 2414 webview()->dragTargetDrop( | 2422 webview()->dragTargetDrop(DropDataToWebDragData(drop_data, false), |
| 2415 ConvertWindowPointToViewport(client_point), screen_point, key_modifiers); | 2423 client_point, screen_point, key_modifiers); |
| 2416 } | 2424 } |
| 2417 | 2425 |
| 2418 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, | 2426 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, |
| 2419 const gfx::Point& screen_point, | 2427 const gfx::Point& screen_point, |
| 2420 WebDragOperation op) { | 2428 WebDragOperation op) { |
| 2421 webview()->dragSourceEndedAt( | 2429 webview()->dragSourceEndedAt( |
| 2422 ConvertWindowPointToViewport(client_point), screen_point, op); | 2430 ConvertWindowPointToViewport(client_point), screen_point, op); |
| 2423 } | 2431 } |
| 2424 | 2432 |
| 2425 void RenderViewImpl::OnDragSourceSystemDragEnded() { | 2433 void RenderViewImpl::OnDragSourceSystemDragEnded() { |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3439 if (IsUseZoomForDSFEnabled()) { | 3447 if (IsUseZoomForDSFEnabled()) { |
| 3440 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); | 3448 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
| 3441 } else { | 3449 } else { |
| 3442 webview()->setDeviceScaleFactor(device_scale_factor_); | 3450 webview()->setDeviceScaleFactor(device_scale_factor_); |
| 3443 } | 3451 } |
| 3444 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3452 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
| 3445 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 3453 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
| 3446 } | 3454 } |
| 3447 | 3455 |
| 3448 } // namespace content | 3456 } // namespace content |
| OLD | NEW |