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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 ui::OSExchangeData::DownloadFileInfo file_download(base::FilePath(), | 320 ui::OSExchangeData::DownloadFileInfo file_download(base::FilePath(), |
321 download_file.get()); | 321 download_file.get()); |
322 provider->SetDownloadFileInfo(file_download); | 322 provider->SetDownloadFileInfo(file_download); |
323 } | 323 } |
324 #endif | 324 #endif |
325 | 325 |
326 // Utility to fill a ui::OSExchangeDataProvider object from DropData. | 326 // Utility to fill a ui::OSExchangeDataProvider object from DropData. |
327 void PrepareDragData(const DropData& drop_data, | 327 void PrepareDragData(const DropData& drop_data, |
328 ui::OSExchangeData::Provider* provider, | 328 ui::OSExchangeData::Provider* provider, |
329 WebContentsImpl* web_contents) { | 329 WebContentsImpl* web_contents) { |
| 330 provider->MarkRendererTainted(); |
330 #if defined(OS_WIN) | 331 #if defined(OS_WIN) |
331 // Put download before file contents to prefer the download of a image over | 332 // Put download before file contents to prefer the download of a image over |
332 // its thumbnail link. | 333 // its thumbnail link. |
333 if (!drop_data.download_metadata.empty()) | 334 if (!drop_data.download_metadata.empty()) |
334 PrepareDragForDownload(drop_data, provider, web_contents); | 335 PrepareDragForDownload(drop_data, provider, web_contents); |
335 // We set the file contents before the URL because the URL also sets file | 336 // We set the file contents before the URL because the URL also sets file |
336 // contents (to a .URL shortcut). We want to prefer file content data over | 337 // contents (to a .URL shortcut). We want to prefer file content data over |
337 // a shortcut so we add it first. | 338 // a shortcut so we add it first. |
338 if (!drop_data.file_contents.empty()) | 339 if (!drop_data.file_contents.empty()) |
339 PrepareDragForFileContents(drop_data, provider); | 340 PrepareDragForFileContents(drop_data, provider); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 383 } |
383 | 384 |
384 base::string16 html; | 385 base::string16 html; |
385 GURL html_base_url; | 386 GURL html_base_url; |
386 data.GetHtml(&html, &html_base_url); | 387 data.GetHtml(&html, &html_base_url); |
387 if (!html.empty()) | 388 if (!html.empty()) |
388 drop_data->html = base::NullableString16(html, false); | 389 drop_data->html = base::NullableString16(html, false); |
389 if (html_base_url.is_valid()) | 390 if (html_base_url.is_valid()) |
390 drop_data->html_base_url = html_base_url; | 391 drop_data->html_base_url = html_base_url; |
391 | 392 |
392 std::vector<ui::OSExchangeData::FileInfo> files; | 393 if (!data.IsRendererTainted()) { |
393 if (data.GetFilenames(&files) && !files.empty()) { | 394 std::vector<ui::OSExchangeData::FileInfo> files; |
394 for (std::vector<ui::OSExchangeData::FileInfo>::const_iterator | 395 if (data.GetFilenames(&files) && !files.empty()) { |
395 it = files.begin(); it != files.end(); ++it) { | 396 for (std::vector<ui::OSExchangeData::FileInfo>::const_iterator |
396 drop_data->filenames.push_back( | 397 it = files.begin(); it != files.end(); ++it) { |
397 DropData::FileInfo( | 398 drop_data->filenames.push_back( |
398 base::UTF8ToUTF16(it->path.AsUTF8Unsafe()), | 399 DropData::FileInfo( |
399 base::UTF8ToUTF16(it->display_name.AsUTF8Unsafe()))); | 400 base::UTF8ToUTF16(it->path.AsUTF8Unsafe()), |
| 401 base::UTF8ToUTF16(it->display_name.AsUTF8Unsafe()))); |
| 402 } |
400 } | 403 } |
401 } | 404 } |
402 | 405 |
403 Pickle pickle; | 406 Pickle pickle; |
404 if (data.GetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), &pickle)) | 407 if (data.GetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), &pickle)) |
405 ui::ReadCustomDataIntoMap( | 408 ui::ReadCustomDataIntoMap( |
406 pickle.data(), pickle.size(), &drop_data->custom_data); | 409 pickle.data(), pickle.size(), &drop_data->custom_data); |
407 } | 410 } |
408 | 411 |
409 // Utilities to convert between blink::WebDragOperationsMask and | 412 // Utilities to convert between blink::WebDragOperationsMask and |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 event.location(), | 1538 event.location(), |
1536 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1539 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
1537 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1540 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1538 if (drag_dest_delegate_) | 1541 if (drag_dest_delegate_) |
1539 drag_dest_delegate_->OnDrop(); | 1542 drag_dest_delegate_->OnDrop(); |
1540 current_drop_data_.reset(); | 1543 current_drop_data_.reset(); |
1541 return ConvertFromWeb(current_drag_op_); | 1544 return ConvertFromWeb(current_drag_op_); |
1542 } | 1545 } |
1543 | 1546 |
1544 } // namespace content | 1547 } // namespace content |
OLD | NEW |