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" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/i18n/break_iterator.h" | 13 #include "base/i18n/break_iterator.h" |
14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/sys_string_conversions.h" | 18 #include "base/strings/sys_string_conversions.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 21 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
22 #include "chrome/browser/download/download_item_model.h" | 22 #include "chrome/browser/download/download_item_model.h" |
23 #include "chrome/browser/download/download_util.h" | 23 #include "chrome/browser/download/drag_download_item.h" |
24 #include "chrome/browser/safe_browsing/download_feedback_service.h" | 24 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
25 #include "chrome/browser/safe_browsing/download_protection_service.h" | 25 #include "chrome/browser/safe_browsing/download_protection_service.h" |
26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
27 #include "chrome/browser/themes/theme_properties.h" | 27 #include "chrome/browser/themes/theme_properties.h" |
28 #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" | 28 #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" |
29 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 29 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
30 #include "content/public/browser/download_danger_type.h" | 30 #include "content/public/browser/download_danger_type.h" |
31 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
32 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
33 #include "third_party/icu/source/common/unicode/uchar.h" | 33 #include "third_party/icu/source/common/unicode/uchar.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 starting_drag_ = true; | 409 starting_drag_ = true; |
410 drag_start_point_ = event.location(); | 410 drag_start_point_ = event.location(); |
411 } | 411 } |
412 if (dragging_) { | 412 if (dragging_) { |
413 if (download()->GetState() == DownloadItem::COMPLETE) { | 413 if (download()->GetState() == DownloadItem::COMPLETE) { |
414 IconManager* im = g_browser_process->icon_manager(); | 414 IconManager* im = g_browser_process->icon_manager(); |
415 gfx::Image* icon = im->LookupIconFromFilepath( | 415 gfx::Image* icon = im->LookupIconFromFilepath( |
416 download()->GetTargetFilePath(), IconLoader::SMALL); | 416 download()->GetTargetFilePath(), IconLoader::SMALL); |
417 if (icon) { | 417 if (icon) { |
418 views::Widget* widget = GetWidget(); | 418 views::Widget* widget = GetWidget(); |
419 download_util::DragDownload(download(), icon, | 419 DragDownloadItem( |
420 widget ? widget->GetNativeView() : NULL); | 420 download(), icon, widget ? widget->GetNativeView() : NULL); |
421 } | 421 } |
422 } | 422 } |
423 } else if (ExceededDragThreshold(event.location() - drag_start_point_)) { | 423 } else if (ExceededDragThreshold(event.location() - drag_start_point_)) { |
424 dragging_ = true; | 424 dragging_ = true; |
425 } | 425 } |
426 return true; | 426 return true; |
427 } | 427 } |
428 | 428 |
429 void DownloadItemView::OnMouseReleased(const ui::MouseEvent& event) { | 429 void DownloadItemView::OnMouseReleased(const ui::MouseEvent& event) { |
430 HandleClickEvent(event, event.IsOnlyLeftMouseButton()); | 430 HandleClickEvent(event, event.IsOnlyLeftMouseButton()); |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 void DownloadItemView::AnimateStateTransition(State from, State to, | 1265 void DownloadItemView::AnimateStateTransition(State from, State to, |
1266 ui::SlideAnimation* animation) { | 1266 ui::SlideAnimation* animation) { |
1267 if (from == NORMAL && to == HOT) { | 1267 if (from == NORMAL && to == HOT) { |
1268 animation->Show(); | 1268 animation->Show(); |
1269 } else if (from == HOT && to == NORMAL) { | 1269 } else if (from == HOT && to == NORMAL) { |
1270 animation->Hide(); | 1270 animation->Hide(); |
1271 } else if (from != to) { | 1271 } else if (from != to) { |
1272 animation->Reset((to == HOT) ? 1.0 : 0.0); | 1272 animation->Reset((to == HOT) ? 1.0 : 0.0); |
1273 } | 1273 } |
1274 } | 1274 } |
OLD | NEW |