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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/views/tabs/tab_strip.h" 5 #include "chrome/browser/ui/views/tabs/tab_strip.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windowsx.h> 8 #include <windowsx.h>
9 #endif 9 #endif
10 10
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 void TabStrip::StopAnimating(bool layout) { 983 void TabStrip::StopAnimating(bool layout) {
984 if (!IsAnimating()) 984 if (!IsAnimating())
985 return; 985 return;
986 986
987 bounds_animator_.Cancel(); 987 bounds_animator_.Cancel();
988 988
989 if (layout) 989 if (layout)
990 DoLayout(); 990 DoLayout();
991 } 991 }
992 992
993 void TabStrip::FileSupported(const GURL& url, bool supported) {
994 if (drop_info_->url == url)
995 drop_info_->file_supported = supported;
996 }
997
993 const ui::ListSelectionModel& TabStrip::GetSelectionModel() { 998 const ui::ListSelectionModel& TabStrip::GetSelectionModel() {
994 return controller_->GetSelectionModel(); 999 return controller_->GetSelectionModel();
995 } 1000 }
996 1001
997 bool TabStrip::SupportsMultipleSelection() { 1002 bool TabStrip::SupportsMultipleSelection() {
998 // TODO: currently only allow single selection in touch layout mode. 1003 // TODO: currently only allow single selection in touch layout mode.
999 return touch_layout_.get() == NULL; 1004 return touch_layout_.get() == NULL;
1000 } 1005 }
1001 1006
1002 void TabStrip::SelectTab(Tab* tab) { 1007 void TabStrip::SelectTab(Tab* tab) {
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 if (immersive_style_) 1411 if (immersive_style_)
1407 return gfx::Size(needed_width, Tab::GetImmersiveHeight()); 1412 return gfx::Size(needed_width, Tab::GetImmersiveHeight());
1408 return gfx::Size(needed_width, Tab::GetMinimumUnselectedSize().height()); 1413 return gfx::Size(needed_width, Tab::GetMinimumUnselectedSize().height());
1409 } 1414 }
1410 1415
1411 void TabStrip::OnDragEntered(const DropTargetEvent& event) { 1416 void TabStrip::OnDragEntered(const DropTargetEvent& event) {
1412 // Force animations to stop, otherwise it makes the index calculation tricky. 1417 // Force animations to stop, otherwise it makes the index calculation tricky.
1413 StopAnimating(true); 1418 StopAnimating(true);
1414 1419
1415 UpdateDropIndex(event); 1420 UpdateDropIndex(event);
1421
1422 GURL url;
1423 string16 title;
1424
1425 // Check whether the event data includes supported drop data.
1426 if (event.data().GetURLAndTitle(&url, &title) && url.is_valid()) {
1427 drop_info_->url = url;
1428
1429 // For file:// URLs, kick off a MIME type request in case they're dropped.
1430 if (url.SchemeIsFile())
1431 controller()->CheckFileSupported(url);
1432 } else {
1433 drop_info_->file_supported = false;
1434 }
1416 } 1435 }
1417 1436
1418 int TabStrip::OnDragUpdated(const DropTargetEvent& event) { 1437 int TabStrip::OnDragUpdated(const DropTargetEvent& event) {
1419 UpdateDropIndex(event); 1438 UpdateDropIndex(event);
1439
1440 if (!drop_info_->file_supported)
1441 return ui::DragDropTypes::DRAG_NONE;
1442
1420 return GetDropEffect(event); 1443 return GetDropEffect(event);
1421 } 1444 }
1422 1445
1423 void TabStrip::OnDragExited() { 1446 void TabStrip::OnDragExited() {
1424 SetDropIndex(-1, false); 1447 SetDropIndex(-1, false);
1425 } 1448 }
1426 1449
1427 int TabStrip::OnPerformDrop(const DropTargetEvent& event) { 1450 int TabStrip::OnPerformDrop(const DropTargetEvent& event) {
1428 if (!drop_info_.get()) 1451 if (!drop_info_.get())
1429 return ui::DragDropTypes::DRAG_NONE; 1452 return ui::DragDropTypes::DRAG_NONE;
1430 1453
1454 if (!drop_info_->file_supported) {
1455 SetDropIndex(-1, false);
1456 return ui::DragDropTypes::DRAG_NONE;
1457 }
1458
1431 const int drop_index = drop_info_->drop_index; 1459 const int drop_index = drop_info_->drop_index;
1432 const bool drop_before = drop_info_->drop_before; 1460 const bool drop_before = drop_info_->drop_before;
1461 const GURL drop_url = drop_info_->url;
1433 1462
1434 // Hide the drop indicator. 1463 // Hide the drop indicator.
1435 SetDropIndex(-1, false); 1464 SetDropIndex(-1, false);
1436 1465
1437 GURL url; 1466 controller()->PerformDrop(drop_before, drop_index, drop_url);
1438 string16 title;
1439 if (!event.data().GetURLAndTitle(&url, &title) || !url.is_valid())
1440 return ui::DragDropTypes::DRAG_NONE;
1441
1442 controller()->PerformDrop(drop_before, drop_index, url);
1443 1467
1444 return GetDropEffect(event); 1468 return GetDropEffect(event);
1445 } 1469 }
1446 1470
1447 void TabStrip::GetAccessibleState(ui::AccessibleViewState* state) { 1471 void TabStrip::GetAccessibleState(ui::AccessibleViewState* state) {
1448 state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST; 1472 state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST;
1449 } 1473 }
1450 1474
1451 views::View* TabStrip::GetEventHandlerForRect(const gfx::Rect& rect) { 1475 views::View* TabStrip::GetEventHandlerForRect(const gfx::Rect& rect) {
1452 if (!views::UsePointBasedTargeting(rect)) 1476 if (!views::UsePointBasedTargeting(rect))
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
2438 } 2462 }
2439 2463
2440 // TabStrip::DropInfo ---------------------------------------------------------- 2464 // TabStrip::DropInfo ----------------------------------------------------------
2441 2465
2442 TabStrip::DropInfo::DropInfo(int drop_index, 2466 TabStrip::DropInfo::DropInfo(int drop_index,
2443 bool drop_before, 2467 bool drop_before,
2444 bool point_down, 2468 bool point_down,
2445 views::Widget* context) 2469 views::Widget* context)
2446 : drop_index(drop_index), 2470 : drop_index(drop_index),
2447 drop_before(drop_before), 2471 drop_before(drop_before),
2448 point_down(point_down) { 2472 point_down(point_down),
2473 file_supported(true) {
2449 arrow_view = new views::ImageView; 2474 arrow_view = new views::ImageView;
2450 arrow_view->SetImage(GetDropArrowImage(point_down)); 2475 arrow_view->SetImage(GetDropArrowImage(point_down));
2451 2476
2452 arrow_window = new views::Widget; 2477 arrow_window = new views::Widget;
2453 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 2478 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
2454 params.keep_on_top = true; 2479 params.keep_on_top = true;
2455 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 2480 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
2456 params.accept_events = false; 2481 params.accept_events = false;
2457 params.can_activate = false; 2482 params.can_activate = false;
2458 params.bounds = gfx::Rect(drop_indicator_width, drop_indicator_height); 2483 params.bounds = gfx::Rect(drop_indicator_width, drop_indicator_height);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2756 #if defined(USE_AURA) 2781 #if defined(USE_AURA)
2757 return chrome::GetHostDesktopTypeForNativeView( 2782 return chrome::GetHostDesktopTypeForNativeView(
2758 GetWidget()->GetNativeView()) == chrome::HOST_DESKTOP_TYPE_ASH; 2783 GetWidget()->GetNativeView()) == chrome::HOST_DESKTOP_TYPE_ASH;
2759 #else 2784 #else
2760 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) 2785 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH)
2761 return false; 2786 return false;
2762 #endif 2787 #endif
2763 2788
2764 return true; 2789 return true;
2765 } 2790 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698