Chromium Code Reviews| Index: chrome/browser/ui/views/tabs/tab_strip.cc |
| diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc |
| index 7800dc987e5ae98dd56dfdc7a7189dc17e99408a..ed4c52ef86be57f52ce7090c76b13e1e3e5d2175 100644 |
| --- a/chrome/browser/ui/views/tabs/tab_strip.cc |
| +++ b/chrome/browser/ui/views/tabs/tab_strip.cc |
| @@ -42,6 +42,7 @@ |
| #include "third_party/skia/include/pathops/SkPathOps.h" |
| #include "ui/accessibility/ax_view_state.h" |
| #include "ui/base/default_theme_provider.h" |
| +#include "ui/base/dragdrop/drag_and_drop_url_utils.h" |
| #include "ui/base/dragdrop/drag_drop_types.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/material_design/material_design_controller.h" |
| @@ -1610,14 +1611,15 @@ void TabStrip::OnDragEntered(const DropTargetEvent& event) { |
| base::string16 title; |
| // Check whether the event data includes supported drop data. |
| - if (event.data().GetURLAndTitle( |
| - ui::OSExchangeData::CONVERT_FILENAMES, &url, &title) && |
| - url.is_valid()) { |
| - drop_info_->url = url; |
| + if (auto url_and_title = ui::TryToInterpretAsURL( |
|
dyaroshev
2016/09/14 17:12:05
I'm still not so sure, how much of this code shoul
Peter Kasting
2016/09/15 21:26:52
Which logic are you referring to specifically?
Ma
|
| + event.data(), ui::OSExchangeData::CONVERT_FILENAMES)) { |
| + if (!url_and_title->first.is_valid()) |
| + return; |
| + drop_info_->url = url_and_title->first; |
| // For file:// URLs, kick off a MIME type request in case they're dropped. |
| - if (url.SchemeIsFile()) |
| - controller_->CheckFileSupported(url); |
| + if (url_and_title->first.SchemeIsFile()) |
| + controller_->CheckFileSupported(url_and_title->first); |
| } |
| } |
| @@ -1649,15 +1651,15 @@ int TabStrip::OnPerformDrop(const DropTargetEvent& event) { |
| // Do nothing if the file was unsupported or the URL is invalid. The URL may |
| // have been changed after |drop_info_| was created. |
| - GURL url; |
| - base::string16 title; |
| - if (!file_supported || |
| - !event.data().GetURLAndTitle( |
| - ui::OSExchangeData::CONVERT_FILENAMES, &url, &title) || |
| - !url.is_valid()) |
| + if (!file_supported) |
| + return ui::DragDropTypes::DRAG_NONE; |
| + |
| + auto url_and_title = ui::TryToInterpretAsURL( |
| + event.data(), ui::OSExchangeData::CONVERT_FILENAMES); |
| + if (!url_and_title || !url_and_title->first.is_valid()) |
| return ui::DragDropTypes::DRAG_NONE; |
| - controller_->PerformDrop(drop_before, drop_index, url); |
| + controller_->PerformDrop(drop_before, drop_index, url_and_title->first); |
| return GetDropEffect(event); |
| } |