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

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

Issue 68133020: Fix dragging supported files to tab strip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved logic to BrowserTabStripController Created 7 years, 1 month 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 fb7b300fa02953729cddb5c1817e1ef105e4f231..aeb81c0b73847b1ea338f6f1016af641e7119125 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -990,6 +990,11 @@ void TabStrip::StopAnimating(bool layout) {
DoLayout();
}
+void TabStrip::FileSupported(const GURL& url, bool supported) {
+ if (drop_info_->url == url)
+ drop_info_->file_supported = supported;
+}
+
const ui::ListSelectionModel& TabStrip::GetSelectionModel() {
return controller_->GetSelectionModel();
}
@@ -1413,10 +1418,28 @@ void TabStrip::OnDragEntered(const DropTargetEvent& event) {
StopAnimating(true);
UpdateDropIndex(event);
+
+ GURL url;
+ string16 title;
+
+ // Check whether the event data includes supported drop data.
+ if (event.data().GetURLAndTitle(&url, &title) && url.is_valid()) {
+ drop_info_->url = url;
+
+ // For file:// URLs, kick off a MIME type request in case they're dropped.
+ if (url.SchemeIsFile())
+ controller()->CheckFileSupported(url);
+ } else {
+ drop_info_->file_supported = false;
+ }
}
int TabStrip::OnDragUpdated(const DropTargetEvent& event) {
UpdateDropIndex(event);
+
+ if (!drop_info_->file_supported)
+ return ui::DragDropTypes::DRAG_NONE;
+
return GetDropEffect(event);
}
@@ -1428,18 +1451,19 @@ int TabStrip::OnPerformDrop(const DropTargetEvent& event) {
if (!drop_info_.get())
return ui::DragDropTypes::DRAG_NONE;
+ if (!drop_info_->file_supported) {
+ SetDropIndex(-1, false);
+ return ui::DragDropTypes::DRAG_NONE;
+ }
+
const int drop_index = drop_info_->drop_index;
const bool drop_before = drop_info_->drop_before;
+ const GURL drop_url = drop_info_->url;
// Hide the drop indicator.
SetDropIndex(-1, false);
- GURL url;
- string16 title;
- if (!event.data().GetURLAndTitle(&url, &title) || !url.is_valid())
- return ui::DragDropTypes::DRAG_NONE;
-
- controller()->PerformDrop(drop_before, drop_index, url);
+ controller()->PerformDrop(drop_before, drop_index, drop_url);
return GetDropEffect(event);
}
@@ -2445,7 +2469,8 @@ TabStrip::DropInfo::DropInfo(int drop_index,
views::Widget* context)
: drop_index(drop_index),
drop_before(drop_before),
- point_down(point_down) {
+ point_down(point_down),
+ file_supported(true) {
arrow_view = new views::ImageView;
arrow_view->SetImage(GetDropArrowImage(point_down));

Powered by Google App Engine
This is Rietveld 408576698