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/gtk/download/download_item_gtk.h" | 5 #include "chrome/browser/ui/gtk/download/download_item_gtk.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (download->GetUserVerifiedFilePath() != icon_filepath_) { | 319 if (download->GetUserVerifiedFilePath() != icon_filepath_) { |
320 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous | 320 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous |
321 // downloads. When the download is confirmed, the file is renamed on | 321 // downloads. When the download is confirmed, the file is renamed on |
322 // another thread, so reload the icon if the download filename changes. | 322 // another thread, so reload the icon if the download filename changes. |
323 LoadIcon(); | 323 LoadIcon(); |
324 | 324 |
325 UpdateTooltip(); | 325 UpdateTooltip(); |
326 } | 326 } |
327 | 327 |
328 switch (download->GetState()) { | 328 switch (download->GetState()) { |
| 329 case DownloadItem::REMOVING: |
| 330 parent_shelf_->RemoveDownloadItem(this); // This will delete us! |
| 331 return; |
329 case DownloadItem::CANCELLED: | 332 case DownloadItem::CANCELLED: |
330 StopDownloadProgress(); | 333 StopDownloadProgress(); |
331 gtk_widget_queue_draw(progress_area_.get()); | 334 gtk_widget_queue_draw(progress_area_.get()); |
332 break; | 335 break; |
333 case DownloadItem::INTERRUPTED: | 336 case DownloadItem::INTERRUPTED: |
334 StopDownloadProgress(); | 337 StopDownloadProgress(); |
335 UpdateTooltip(); | 338 UpdateTooltip(); |
336 | 339 |
337 complete_animation_.Show(); | 340 complete_animation_.Show(); |
338 break; | 341 break; |
(...skipping 23 matching lines...) Expand all Loading... |
362 StopDownloadProgress() : StartDownloadProgress(); | 365 StopDownloadProgress() : StartDownloadProgress(); |
363 break; | 366 break; |
364 default: | 367 default: |
365 NOTREACHED(); | 368 NOTREACHED(); |
366 } | 369 } |
367 | 370 |
368 status_text_ = UTF16ToUTF8(download_model_->GetStatusText()); | 371 status_text_ = UTF16ToUTF8(download_model_->GetStatusText()); |
369 UpdateStatusLabel(status_text_); | 372 UpdateStatusLabel(status_text_); |
370 } | 373 } |
371 | 374 |
372 void DownloadItemGtk::OnDownloadDestroyed(DownloadItem* download) { | |
373 parent_shelf_->RemoveDownloadItem(this); | |
374 // This will delete us! | |
375 } | |
376 | |
377 void DownloadItemGtk::AnimationProgressed(const ui::Animation* animation) { | 375 void DownloadItemGtk::AnimationProgressed(const ui::Animation* animation) { |
378 if (animation == &complete_animation_) { | 376 if (animation == &complete_animation_) { |
379 gtk_widget_queue_draw(progress_area_.get()); | 377 gtk_widget_queue_draw(progress_area_.get()); |
380 } else { | 378 } else { |
381 DCHECK(animation == new_item_animation_.get()); | 379 DCHECK(animation == new_item_animation_.get()); |
382 if (download_model_->IsDangerous()) { | 380 if (download_model_->IsDangerous()) { |
383 int progress = static_cast<int>((dangerous_hbox_full_width_ - | 381 int progress = static_cast<int>((dangerous_hbox_full_width_ - |
384 dangerous_hbox_start_width_) * | 382 dangerous_hbox_start_width_) * |
385 animation->GetCurrentValue()); | 383 animation->GetCurrentValue()); |
386 int showing_width = dangerous_hbox_start_width_ + progress; | 384 int showing_width = dangerous_hbox_start_width_ + progress; |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 get_download()->DangerousDownloadValidated(); | 920 get_download()->DangerousDownloadValidated(); |
923 } | 921 } |
924 | 922 |
925 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { | 923 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { |
926 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 924 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
927 base::Time::Now() - creation_time_); | 925 base::Time::Now() - creation_time_); |
928 if (get_download()->IsPartialDownload()) | 926 if (get_download()->IsPartialDownload()) |
929 get_download()->Cancel(true); | 927 get_download()->Cancel(true); |
930 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); | 928 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); |
931 } | 929 } |
OLD | NEW |