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