| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 ShowWarningDialog(); | 210 ShowWarningDialog(); |
| 211 | 211 |
| 212 UpdateAccessibleName(); | 212 UpdateAccessibleName(); |
| 213 set_accessibility_focusable(true); | 213 set_accessibility_focusable(true); |
| 214 | 214 |
| 215 // Set up our animation. | 215 // Set up our animation. |
| 216 StartDownloadProgress(); | 216 StartDownloadProgress(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 DownloadItemView::~DownloadItemView() { | 219 DownloadItemView::~DownloadItemView() { |
| 220 icon_consumer_.CancelAllRequests(); | |
| 221 StopDownloadProgress(); | 220 StopDownloadProgress(); |
| 222 download_->RemoveObserver(this); | 221 download_->RemoveObserver(this); |
| 223 } | 222 } |
| 224 | 223 |
| 225 // Progress animation handlers. | 224 // Progress animation handlers. |
| 226 | 225 |
| 227 void DownloadItemView::UpdateDownloadProgress() { | 226 void DownloadItemView::UpdateDownloadProgress() { |
| 228 progress_angle_ = (progress_angle_ + | 227 progress_angle_ = (progress_angle_ + |
| 229 download_util::kUnknownIncrementDegrees) % | 228 download_util::kUnknownIncrementDegrees) % |
| 230 download_util::kMaxDegrees; | 229 download_util::kMaxDegrees; |
| 231 SchedulePaint(); | 230 SchedulePaint(); |
| 232 } | 231 } |
| 233 | 232 |
| 234 void DownloadItemView::StartDownloadProgress() { | 233 void DownloadItemView::StartDownloadProgress() { |
| 235 if (progress_timer_.IsRunning()) | 234 if (progress_timer_.IsRunning()) |
| 236 return; | 235 return; |
| 237 progress_timer_.Start(FROM_HERE, | 236 progress_timer_.Start(FROM_HERE, |
| 238 base::TimeDelta::FromMilliseconds(download_util::kProgressRateMs), this, | 237 base::TimeDelta::FromMilliseconds(download_util::kProgressRateMs), this, |
| 239 &DownloadItemView::UpdateDownloadProgress); | 238 &DownloadItemView::UpdateDownloadProgress); |
| 240 } | 239 } |
| 241 | 240 |
| 242 void DownloadItemView::StopDownloadProgress() { | 241 void DownloadItemView::StopDownloadProgress() { |
| 243 progress_timer_.Stop(); | 242 progress_timer_.Stop(); |
| 244 } | 243 } |
| 245 | 244 |
| 246 void DownloadItemView::OnExtractIconComplete(IconManager::Handle handle, | 245 void DownloadItemView::OnExtractIconComplete(gfx::Image* icon_bitmap) { |
| 247 gfx::Image* icon_bitmap) { | |
| 248 if (icon_bitmap) | 246 if (icon_bitmap) |
| 249 parent()->SchedulePaint(); | 247 parent()->SchedulePaint(); |
| 250 } | 248 } |
| 251 | 249 |
| 252 // DownloadObserver interface. | 250 // DownloadObserver interface. |
| 253 | 251 |
| 254 // Update the progress graphic on the icon and our text status label | 252 // Update the progress graphic on the icon and our text status label |
| 255 // to reflect our current bytes downloaded, time remaining. | 253 // to reflect our current bytes downloaded, time remaining. |
| 256 void DownloadItemView::OnDownloadUpdated(DownloadItem* download) { | 254 void DownloadItemView::OnDownloadUpdated(DownloadItem* download) { |
| 257 DCHECK_EQ(download_, download); | 255 DCHECK_EQ(download_, download); |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", | 847 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", |
| 850 base::Time::Now() - creation_time_); | 848 base::Time::Now() - creation_time_); |
| 851 download_->OpenDownload(); | 849 download_->OpenDownload(); |
| 852 UpdateAccessibleName(); | 850 UpdateAccessibleName(); |
| 853 } | 851 } |
| 854 | 852 |
| 855 void DownloadItemView::LoadIcon() { | 853 void DownloadItemView::LoadIcon() { |
| 856 IconManager* im = g_browser_process->icon_manager(); | 854 IconManager* im = g_browser_process->icon_manager(); |
| 857 last_download_item_path_ = download_->GetUserVerifiedFilePath(); | 855 last_download_item_path_ = download_->GetUserVerifiedFilePath(); |
| 858 im->LoadIcon(last_download_item_path_, | 856 im->LoadIcon(last_download_item_path_, |
| 859 IconLoader::SMALL, &icon_consumer_, | 857 IconLoader::SMALL, |
| 860 base::Bind(&DownloadItemView::OnExtractIconComplete, | 858 base::Bind(&DownloadItemView::OnExtractIconComplete, |
| 861 base::Unretained(this))); | 859 base::Unretained(this)), |
| 860 &cancelable_task_tracker_); |
| 862 } | 861 } |
| 863 | 862 |
| 864 void DownloadItemView::LoadIconIfItemPathChanged() { | 863 void DownloadItemView::LoadIconIfItemPathChanged() { |
| 865 FilePath current_download_path = download_->GetUserVerifiedFilePath(); | 864 FilePath current_download_path = download_->GetUserVerifiedFilePath(); |
| 866 if (last_download_item_path_ == current_download_path) | 865 if (last_download_item_path_ == current_download_path) |
| 867 return; | 866 return; |
| 868 | 867 |
| 869 LoadIcon(); | 868 LoadIcon(); |
| 870 } | 869 } |
| 871 | 870 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 void DownloadItemView::AnimateStateTransition(State from, State to, | 1224 void DownloadItemView::AnimateStateTransition(State from, State to, |
| 1226 ui::SlideAnimation* animation) { | 1225 ui::SlideAnimation* animation) { |
| 1227 if (from == NORMAL && to == HOT) { | 1226 if (from == NORMAL && to == HOT) { |
| 1228 animation->Show(); | 1227 animation->Show(); |
| 1229 } else if (from == HOT && to == NORMAL) { | 1228 } else if (from == HOT && to == NORMAL) { |
| 1230 animation->Hide(); | 1229 animation->Hide(); |
| 1231 } else if (from != to) { | 1230 } else if (from != to) { |
| 1232 animation->Reset((to == HOT) ? 1.0 : 0.0); | 1231 animation->Reset((to == HOT) ? 1.0 : 0.0); |
| 1233 } | 1232 } |
| 1234 } | 1233 } |
| OLD | NEW |