| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 return true; | 401 return true; |
| 402 | 402 |
| 403 if (!starting_drag_) { | 403 if (!starting_drag_) { |
| 404 starting_drag_ = true; | 404 starting_drag_ = true; |
| 405 drag_start_point_ = event.location(); | 405 drag_start_point_ = event.location(); |
| 406 } | 406 } |
| 407 if (dragging_) { | 407 if (dragging_) { |
| 408 if (download()->IsComplete()) { | 408 if (download()->IsComplete()) { |
| 409 IconManager* im = g_browser_process->icon_manager(); | 409 IconManager* im = g_browser_process->icon_manager(); |
| 410 gfx::Image* icon = im->LookupIconFromFilepath( | 410 gfx::Image* icon = im->LookupIconFromFilepath( |
| 411 download()->GetUserVerifiedFilePath(), IconLoader::SMALL); | 411 download()->GetTargetFilePath(), IconLoader::SMALL); |
| 412 if (icon) { | 412 if (icon) { |
| 413 views::Widget* widget = GetWidget(); | 413 views::Widget* widget = GetWidget(); |
| 414 download_util::DragDownload(download(), icon, | 414 download_util::DragDownload(download(), icon, |
| 415 widget ? widget->GetNativeView() : NULL); | 415 widget ? widget->GetNativeView() : NULL); |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 } else if (ExceededDragThreshold(event.location() - drag_start_point_)) { | 418 } else if (ExceededDragThreshold(event.location() - drag_start_point_)) { |
| 419 dragging_ = true; | 419 dragging_ = true; |
| 420 } | 420 } |
| 421 return true; | 421 return true; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 // Draw the file's name. | 768 // Draw the file's name. |
| 769 canvas->DrawStringInt(filename, font_, | 769 canvas->DrawStringInt(filename, font_, |
| 770 enabled() ? file_name_color | 770 enabled() ? file_name_color |
| 771 : kFileNameDisabledColor, | 771 : kFileNameDisabledColor, |
| 772 mirrored_x, y, kTextWidth, font_.GetHeight()); | 772 mirrored_x, y, kTextWidth, font_.GetHeight()); |
| 773 } | 773 } |
| 774 | 774 |
| 775 // Load the icon. | 775 // Load the icon. |
| 776 IconManager* im = g_browser_process->icon_manager(); | 776 IconManager* im = g_browser_process->icon_manager(); |
| 777 gfx::Image* image = im->LookupIconFromFilepath( | 777 gfx::Image* image = im->LookupIconFromFilepath( |
| 778 download()->GetUserVerifiedFilePath(),IconLoader::SMALL); | 778 download()->GetTargetFilePath(), IconLoader::SMALL); |
| 779 const gfx::ImageSkia* icon = NULL; | 779 const gfx::ImageSkia* icon = NULL; |
| 780 if (IsShowingWarningDialog()) | 780 if (IsShowingWarningDialog()) |
| 781 icon = warning_icon_; | 781 icon = warning_icon_; |
| 782 else if (image) | 782 else if (image) |
| 783 icon = image->ToImageSkia(); | 783 icon = image->ToImageSkia(); |
| 784 | 784 |
| 785 // We count on the fact that the icon manager will cache the icons and if one | 785 // We count on the fact that the icon manager will cache the icons and if one |
| 786 // is available, it will be cached here. We *don't* want to request the icon | 786 // is available, it will be cached here. We *don't* want to request the icon |
| 787 // to be loaded here, since this will also get called if the icon can't be | 787 // to be loaded here, since this will also get called if the icon can't be |
| 788 // loaded, in which case LookupIcon will always be NULL. The loading will be | 788 // loaded, in which case LookupIcon will always be NULL. The loading will be |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 // We're interested in how long it takes users to open downloads. If they | 836 // We're interested in how long it takes users to open downloads. If they |
| 837 // open downloads super quickly, we should be concerned about clickjacking. | 837 // open downloads super quickly, we should be concerned about clickjacking. |
| 838 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", | 838 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", |
| 839 base::Time::Now() - creation_time_); | 839 base::Time::Now() - creation_time_); |
| 840 download()->OpenDownload(); | 840 download()->OpenDownload(); |
| 841 UpdateAccessibleName(); | 841 UpdateAccessibleName(); |
| 842 } | 842 } |
| 843 | 843 |
| 844 void DownloadItemView::LoadIcon() { | 844 void DownloadItemView::LoadIcon() { |
| 845 IconManager* im = g_browser_process->icon_manager(); | 845 IconManager* im = g_browser_process->icon_manager(); |
| 846 last_download_item_path_ = download()->GetUserVerifiedFilePath(); | 846 last_download_item_path_ = download()->GetTargetFilePath(); |
| 847 im->LoadIcon(last_download_item_path_, | 847 im->LoadIcon(last_download_item_path_, |
| 848 IconLoader::SMALL, | 848 IconLoader::SMALL, |
| 849 base::Bind(&DownloadItemView::OnExtractIconComplete, | 849 base::Bind(&DownloadItemView::OnExtractIconComplete, |
| 850 base::Unretained(this)), | 850 base::Unretained(this)), |
| 851 &cancelable_task_tracker_); | 851 &cancelable_task_tracker_); |
| 852 } | 852 } |
| 853 | 853 |
| 854 void DownloadItemView::LoadIconIfItemPathChanged() { | 854 void DownloadItemView::LoadIconIfItemPathChanged() { |
| 855 base::FilePath current_download_path = download()->GetUserVerifiedFilePath(); | 855 base::FilePath current_download_path = download()->GetTargetFilePath(); |
| 856 if (last_download_item_path_ == current_download_path) | 856 if (last_download_item_path_ == current_download_path) |
| 857 return; | 857 return; |
| 858 | 858 |
| 859 LoadIcon(); | 859 LoadIcon(); |
| 860 } | 860 } |
| 861 | 861 |
| 862 void DownloadItemView::UpdateColorsFromTheme() { | 862 void DownloadItemView::UpdateColorsFromTheme() { |
| 863 if (dangerous_download_label_ && GetThemeProvider()) { | 863 if (dangerous_download_label_ && GetThemeProvider()) { |
| 864 dangerous_download_label_->SetEnabledColor( | 864 dangerous_download_label_->SetEnabledColor( |
| 865 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); | 865 GetThemeProvider()->GetColor(ThemeProperties::COLOR_BOOKMARK_TEXT)); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 void DownloadItemView::AnimateStateTransition(State from, State to, | 1212 void DownloadItemView::AnimateStateTransition(State from, State to, |
| 1213 ui::SlideAnimation* animation) { | 1213 ui::SlideAnimation* animation) { |
| 1214 if (from == NORMAL && to == HOT) { | 1214 if (from == NORMAL && to == HOT) { |
| 1215 animation->Show(); | 1215 animation->Show(); |
| 1216 } else if (from == HOT && to == NORMAL) { | 1216 } else if (from == HOT && to == NORMAL) { |
| 1217 animation->Hide(); | 1217 animation->Hide(); |
| 1218 } else if (from != to) { | 1218 } else if (from != to) { |
| 1219 animation->Reset((to == HOT) ? 1.0 : 0.0); | 1219 animation->Reset((to == HOT) ? 1.0 : 0.0); |
| 1220 } | 1220 } |
| 1221 } | 1221 } |
| OLD | NEW |