| 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/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // a shortcut so we add it first. | 343 // a shortcut so we add it first. |
| 344 if (!drop_data.file_contents.empty()) | 344 if (!drop_data.file_contents.empty()) |
| 345 PrepareDragForFileContents(drop_data, provider); | 345 PrepareDragForFileContents(drop_data, provider); |
| 346 #endif | 346 #endif |
| 347 if (!drop_data.text.string().empty()) | 347 if (!drop_data.text.string().empty()) |
| 348 provider->SetString(drop_data.text.string()); | 348 provider->SetString(drop_data.text.string()); |
| 349 if (drop_data.url.is_valid()) | 349 if (drop_data.url.is_valid()) |
| 350 provider->SetURL(drop_data.url, drop_data.url_title); | 350 provider->SetURL(drop_data.url, drop_data.url_title); |
| 351 if (!drop_data.html.string().empty()) | 351 if (!drop_data.html.string().empty()) |
| 352 provider->SetHtml(drop_data.html.string(), drop_data.html_base_url); | 352 provider->SetHtml(drop_data.html.string(), drop_data.html_base_url); |
| 353 if (!drop_data.filenames.empty()) { | 353 if (!drop_data.filenames.empty()) |
| 354 std::vector<ui::OSExchangeData::FileInfo> filenames; | 354 provider->SetFilenames(drop_data.filenames); |
| 355 for (std::vector<DropData::FileInfo>::const_iterator it = | |
| 356 drop_data.filenames.begin(); | |
| 357 it != drop_data.filenames.end(); ++it) { | |
| 358 filenames.push_back( | |
| 359 ui::OSExchangeData::FileInfo( | |
| 360 base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(it->path)), | |
| 361 base::FilePath::FromUTF8Unsafe( | |
| 362 base::UTF16ToUTF8(it->display_name)))); | |
| 363 } | |
| 364 provider->SetFilenames(filenames); | |
| 365 } | |
| 366 if (!drop_data.custom_data.empty()) { | 355 if (!drop_data.custom_data.empty()) { |
| 367 Pickle pickle; | 356 Pickle pickle; |
| 368 ui::WriteCustomDataToPickle(drop_data.custom_data, &pickle); | 357 ui::WriteCustomDataToPickle(drop_data.custom_data, &pickle); |
| 369 provider->SetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), | 358 provider->SetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), |
| 370 pickle); | 359 pickle); |
| 371 } | 360 } |
| 372 } | 361 } |
| 373 | 362 |
| 374 // Utility to fill a DropData object from ui::OSExchangeData. | 363 // Utility to fill a DropData object from ui::OSExchangeData. |
| 375 void PrepareDropData(DropData* drop_data, const ui::OSExchangeData& data) { | 364 void PrepareDropData(DropData* drop_data, const ui::OSExchangeData& data) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 390 } | 379 } |
| 391 | 380 |
| 392 base::string16 html; | 381 base::string16 html; |
| 393 GURL html_base_url; | 382 GURL html_base_url; |
| 394 data.GetHtml(&html, &html_base_url); | 383 data.GetHtml(&html, &html_base_url); |
| 395 if (!html.empty()) | 384 if (!html.empty()) |
| 396 drop_data->html = base::NullableString16(html, false); | 385 drop_data->html = base::NullableString16(html, false); |
| 397 if (html_base_url.is_valid()) | 386 if (html_base_url.is_valid()) |
| 398 drop_data->html_base_url = html_base_url; | 387 drop_data->html_base_url = html_base_url; |
| 399 | 388 |
| 400 std::vector<ui::OSExchangeData::FileInfo> files; | 389 data.GetFilenames(&drop_data->filenames); |
| 401 if (data.GetFilenames(&files) && !files.empty()) { | |
| 402 for (std::vector<ui::OSExchangeData::FileInfo>::const_iterator | |
| 403 it = files.begin(); it != files.end(); ++it) { | |
| 404 drop_data->filenames.push_back( | |
| 405 DropData::FileInfo( | |
| 406 base::UTF8ToUTF16(it->path.AsUTF8Unsafe()), | |
| 407 base::UTF8ToUTF16(it->display_name.AsUTF8Unsafe()))); | |
| 408 } | |
| 409 } | |
| 410 | 390 |
| 411 Pickle pickle; | 391 Pickle pickle; |
| 412 if (data.GetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), &pickle)) | 392 if (data.GetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), &pickle)) |
| 413 ui::ReadCustomDataIntoMap( | 393 ui::ReadCustomDataIntoMap( |
| 414 pickle.data(), pickle.size(), &drop_data->custom_data); | 394 pickle.data(), pickle.size(), &drop_data->custom_data); |
| 415 } | 395 } |
| 416 | 396 |
| 417 // Utilities to convert between blink::WebDragOperationsMask and | 397 // Utilities to convert between blink::WebDragOperationsMask and |
| 418 // ui::DragDropTypes. | 398 // ui::DragDropTypes. |
| 419 int ConvertFromWeb(blink::WebDragOperationsMask ops) { | 399 int ConvertFromWeb(blink::WebDragOperationsMask ops) { |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1529 event.location(), | 1509 event.location(), |
| 1530 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1510 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
| 1531 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1511 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1532 if (drag_dest_delegate_) | 1512 if (drag_dest_delegate_) |
| 1533 drag_dest_delegate_->OnDrop(); | 1513 drag_dest_delegate_->OnDrop(); |
| 1534 current_drop_data_.reset(); | 1514 current_drop_data_.reset(); |
| 1535 return ConvertFromWeb(current_drag_op_); | 1515 return ConvertFromWeb(current_drag_op_); |
| 1536 } | 1516 } |
| 1537 | 1517 |
| 1538 } // namespace content | 1518 } // namespace content |
| OLD | NEW |