Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4493)

Unified Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 2322253004: Drag and dropping text, parsable as url (Closed)
Patch Set: Moving url logic out of os_exchange_data Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld 408576698