| 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 "chrome/browser/ui/views/download/download_item_view.h" | 5 #include "chrome/browser/ui/views/download/download_item_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 } | 407 } |
| 408 | 408 |
| 409 // Handle drag (file copy) operations. | 409 // Handle drag (file copy) operations. |
| 410 bool DownloadItemView::OnMouseDragged(const ui::MouseEvent& event) { | 410 bool DownloadItemView::OnMouseDragged(const ui::MouseEvent& event) { |
| 411 // Mouse should not activate us in dangerous mode. | 411 // Mouse should not activate us in dangerous mode. |
| 412 if (IsShowingWarningDialog()) | 412 if (IsShowingWarningDialog()) |
| 413 return true; | 413 return true; |
| 414 | 414 |
| 415 if (!starting_drag_) { | 415 if (!starting_drag_) { |
| 416 starting_drag_ = true; | 416 starting_drag_ = true; |
| 417 drag_start_point_ = event.location(); | 417 drag_start_point_ = gfx::ToFlooredPoint(event.location()); |
| 418 } | 418 } |
| 419 if (dragging_) { | 419 if (dragging_) { |
| 420 if (download()->GetState() == DownloadItem::COMPLETE) { | 420 if (download()->GetState() == DownloadItem::COMPLETE) { |
| 421 IconManager* im = g_browser_process->icon_manager(); | 421 IconManager* im = g_browser_process->icon_manager(); |
| 422 gfx::Image* icon = im->LookupIconFromFilepath( | 422 gfx::Image* icon = im->LookupIconFromFilepath( |
| 423 download()->GetTargetFilePath(), IconLoader::SMALL); | 423 download()->GetTargetFilePath(), IconLoader::SMALL); |
| 424 views::Widget* widget = GetWidget(); | 424 views::Widget* widget = GetWidget(); |
| 425 DragDownloadItem( | 425 DragDownloadItem( |
| 426 download(), icon, widget ? widget->GetNativeView() : NULL); | 426 download(), icon, widget ? widget->GetNativeView() : NULL); |
| 427 } | 427 } |
| 428 } else if (ExceededDragThreshold(event.location() - drag_start_point_)) { | 428 } else if (ExceededDragThreshold(gfx::ToFlooredPoint(event.location()) - |
| 429 drag_start_point_)) { |
| 429 dragging_ = true; | 430 dragging_ = true; |
| 430 } | 431 } |
| 431 return true; | 432 return true; |
| 432 } | 433 } |
| 433 | 434 |
| 434 void DownloadItemView::OnMouseReleased(const ui::MouseEvent& event) { | 435 void DownloadItemView::OnMouseReleased(const ui::MouseEvent& event) { |
| 435 HandleClickEvent(event, event.IsOnlyLeftMouseButton()); | 436 HandleClickEvent(event, event.IsOnlyLeftMouseButton()); |
| 436 } | 437 } |
| 437 | 438 |
| 438 void DownloadItemView::OnMouseCaptureLost() { | 439 void DownloadItemView::OnMouseCaptureLost() { |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 base::TimeTicks::Now() - context_menu_->close_time(); | 1025 base::TimeTicks::Now() - context_menu_->close_time(); |
| 1025 if (delta.InMilliseconds() < views::kMinimumMsBetweenButtonClicks) | 1026 if (delta.InMilliseconds() < views::kMinimumMsBetweenButtonClicks) |
| 1026 return; | 1027 return; |
| 1027 } | 1028 } |
| 1028 drop_down_pressed_ = true; | 1029 drop_down_pressed_ = true; |
| 1029 SetState(NORMAL, PUSHED); | 1030 SetState(NORMAL, PUSHED); |
| 1030 // We are setting is_mouse_gesture to false when calling ShowContextMenu | 1031 // We are setting is_mouse_gesture to false when calling ShowContextMenu |
| 1031 // so that the positioning of the context menu will be similar to a | 1032 // so that the positioning of the context menu will be similar to a |
| 1032 // keyboard invocation. I.e. we want the menu to always be positioned | 1033 // keyboard invocation. I.e. we want the menu to always be positioned |
| 1033 // next to the drop down button instead of the next to the pointer. | 1034 // next to the drop down button instead of the next to the pointer. |
| 1034 ShowContextMenuImpl(event.location(), ui::MENU_SOURCE_KEYBOARD); | 1035 ShowContextMenuImpl(gfx::ToFlooredPoint(event.location()), |
| 1036 ui::MENU_SOURCE_KEYBOARD); |
| 1035 // Once called, it is possible that *this was deleted (e.g.: due to | 1037 // Once called, it is possible that *this was deleted (e.g.: due to |
| 1036 // invoking the 'Discard' action.) | 1038 // invoking the 'Discard' action.) |
| 1037 } else if (!IsShowingWarningDialog()) { | 1039 } else if (!IsShowingWarningDialog()) { |
| 1038 SetState(PUSHED, NORMAL); | 1040 SetState(PUSHED, NORMAL); |
| 1039 } | 1041 } |
| 1040 } | 1042 } |
| 1041 } | 1043 } |
| 1042 | 1044 |
| 1043 void DownloadItemView::HandleClickEvent(const ui::LocatedEvent& event, | 1045 void DownloadItemView::HandleClickEvent(const ui::LocatedEvent& event, |
| 1044 bool active_event) { | 1046 bool active_event) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 void DownloadItemView::AnimateStateTransition(State from, State to, | 1345 void DownloadItemView::AnimateStateTransition(State from, State to, |
| 1344 gfx::SlideAnimation* animation) { | 1346 gfx::SlideAnimation* animation) { |
| 1345 if (from == NORMAL && to == HOT) { | 1347 if (from == NORMAL && to == HOT) { |
| 1346 animation->Show(); | 1348 animation->Show(); |
| 1347 } else if (from == HOT && to == NORMAL) { | 1349 } else if (from == HOT && to == NORMAL) { |
| 1348 animation->Hide(); | 1350 animation->Hide(); |
| 1349 } else if (from != to) { | 1351 } else if (from != to) { |
| 1350 animation->Reset((to == HOT) ? 1.0 : 0.0); | 1352 animation->Reset((to == HOT) ? 1.0 : 0.0); |
| 1351 } | 1353 } |
| 1352 } | 1354 } |
| OLD | NEW |