Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/ui/gtk/download/download_item_gtk.cc

Issue 10665049: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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;
332 case DownloadItem::CANCELLED: 329 case DownloadItem::CANCELLED:
333 StopDownloadProgress(); 330 StopDownloadProgress();
334 gtk_widget_queue_draw(progress_area_.get()); 331 gtk_widget_queue_draw(progress_area_.get());
335 break; 332 break;
336 case DownloadItem::INTERRUPTED: 333 case DownloadItem::INTERRUPTED:
337 StopDownloadProgress(); 334 StopDownloadProgress();
338 UpdateTooltip(); 335 UpdateTooltip();
339 336
340 complete_animation_.Show(); 337 complete_animation_.Show();
341 break; 338 break;
(...skipping 23 matching lines...) Expand all
365 StopDownloadProgress() : StartDownloadProgress(); 362 StopDownloadProgress() : StartDownloadProgress();
366 break; 363 break;
367 default: 364 default:
368 NOTREACHED(); 365 NOTREACHED();
369 } 366 }
370 367
371 status_text_ = UTF16ToUTF8(download_model_->GetStatusText()); 368 status_text_ = UTF16ToUTF8(download_model_->GetStatusText());
372 UpdateStatusLabel(status_text_); 369 UpdateStatusLabel(status_text_);
373 } 370 }
374 371
372 void DownloadItemGtk::OnDownloadDestroyed(DownloadItem* download) {
373 parent_shelf_->RemoveDownloadItem(this);
374 // This will delete us!
375 }
376
375 void DownloadItemGtk::AnimationProgressed(const ui::Animation* animation) { 377 void DownloadItemGtk::AnimationProgressed(const ui::Animation* animation) {
376 if (animation == &complete_animation_) { 378 if (animation == &complete_animation_) {
377 gtk_widget_queue_draw(progress_area_.get()); 379 gtk_widget_queue_draw(progress_area_.get());
378 } else { 380 } else {
379 DCHECK(animation == new_item_animation_.get()); 381 DCHECK(animation == new_item_animation_.get());
380 if (download_model_->IsDangerous()) { 382 if (download_model_->IsDangerous()) {
381 int progress = static_cast<int>((dangerous_hbox_full_width_ - 383 int progress = static_cast<int>((dangerous_hbox_full_width_ -
382 dangerous_hbox_start_width_) * 384 dangerous_hbox_start_width_) *
383 animation->GetCurrentValue()); 385 animation->GetCurrentValue());
384 int showing_width = dangerous_hbox_start_width_ + progress; 386 int showing_width = dangerous_hbox_start_width_ + progress;
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 get_download()->DangerousDownloadValidated(); 922 get_download()->DangerousDownloadValidated();
921 } 923 }
922 924
923 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { 925 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) {
924 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", 926 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
925 base::Time::Now() - creation_time_); 927 base::Time::Now() - creation_time_);
926 if (get_download()->IsPartialDownload()) 928 if (get_download()->IsPartialDownload())
927 get_download()->Cancel(true); 929 get_download()->Cancel(true);
928 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); 930 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
929 } 931 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698