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

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

Issue 11441006: Convert IconManager to use new CancelableTaskTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and fix mac compiling Created 8 years 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 complete_animation_.SetTweenType(ui::Tween::LINEAR); 277 complete_animation_.SetTweenType(ui::Tween::LINEAR);
278 complete_animation_.SetSlideDuration(kCompleteAnimationDurationMs); 278 complete_animation_.SetSlideDuration(kCompleteAnimationDurationMs);
279 } 279 }
280 280
281 DownloadItemGtk::~DownloadItemGtk() { 281 DownloadItemGtk::~DownloadItemGtk() {
282 // First close the menu and then destroy the GtkWidgets. Bug#97724 282 // First close the menu and then destroy the GtkWidgets. Bug#97724
283 if (menu_.get()) 283 if (menu_.get())
284 menu_.reset(); 284 menu_.reset();
285 285
286 icon_consumer_.CancelAllRequests();
287 StopDownloadProgress(); 286 StopDownloadProgress();
288 get_download()->RemoveObserver(this); 287 get_download()->RemoveObserver(this);
289 288
290 // We may free some shelf space for showing more download items. 289 // We may free some shelf space for showing more download items.
291 parent_shelf_->MaybeShowMoreDownloadItems(); 290 parent_shelf_->MaybeShowMoreDownloadItems();
292 291
293 hbox_.Destroy(); 292 hbox_.Destroy();
294 progress_area_.Destroy(); 293 progress_area_.Destroy();
295 body_.Destroy(); 294 body_.Destroy();
296 dangerous_hbox_.Destroy(); 295 dangerous_hbox_.Destroy();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 base::TimeDelta::FromMilliseconds(download_util::kProgressRateMs), this, 444 base::TimeDelta::FromMilliseconds(download_util::kProgressRateMs), this,
446 &DownloadItemGtk::UpdateDownloadProgress); 445 &DownloadItemGtk::UpdateDownloadProgress);
447 } 446 }
448 447
449 void DownloadItemGtk::StopDownloadProgress() { 448 void DownloadItemGtk::StopDownloadProgress() {
450 progress_timer_.Stop(); 449 progress_timer_.Stop();
451 } 450 }
452 451
453 // Icon loading functions. 452 // Icon loading functions.
454 453
455 void DownloadItemGtk::OnLoadSmallIconComplete(IconManager::Handle handle, 454 void DownloadItemGtk::OnLoadSmallIconComplete(gfx::Image* image) {
456 gfx::Image* image) {
457 icon_small_ = image; 455 icon_small_ = image;
458 gtk_widget_queue_draw(progress_area_.get()); 456 gtk_widget_queue_draw(progress_area_.get());
459 } 457 }
460 458
461 void DownloadItemGtk::OnLoadLargeIconComplete(IconManager::Handle handle, 459 void DownloadItemGtk::OnLoadLargeIconComplete(gfx::Image* image) {
462 gfx::Image* image) {
463 icon_large_ = image; 460 icon_large_ = image;
464 DownloadItemDrag::SetSource(body_.get(), get_download(), icon_large_); 461 DownloadItemDrag::SetSource(body_.get(), get_download(), icon_large_);
465 } 462 }
466 463
467 void DownloadItemGtk::LoadIcon() { 464 void DownloadItemGtk::LoadIcon() {
468 icon_consumer_.CancelAllRequests(); 465 cancelable_task_tracker_.TryCancelAll();
469 IconManager* im = g_browser_process->icon_manager(); 466 IconManager* im = g_browser_process->icon_manager();
470 icon_filepath_ = get_download()->GetUserVerifiedFilePath(); 467 icon_filepath_ = get_download()->GetUserVerifiedFilePath();
471 im->LoadIcon(icon_filepath_, 468 im->LoadIcon(icon_filepath_,
472 IconLoader::SMALL, &icon_consumer_, 469 IconLoader::SMALL,
473 base::Bind(&DownloadItemGtk::OnLoadSmallIconComplete, 470 base::Bind(&DownloadItemGtk::OnLoadSmallIconComplete,
474 base::Unretained(this))); 471 base::Unretained(this)),
472 &cancelable_task_tracker_);
475 im->LoadIcon(icon_filepath_, 473 im->LoadIcon(icon_filepath_,
476 IconLoader::LARGE, &icon_consumer_, 474 IconLoader::LARGE,
477 base::Bind(&DownloadItemGtk::OnLoadLargeIconComplete, 475 base::Bind(&DownloadItemGtk::OnLoadLargeIconComplete,
478 base::Unretained(this))); 476 base::Unretained(this)),
477 &cancelable_task_tracker_);
479 } 478 }
480 479
481 void DownloadItemGtk::UpdateTooltip() { 480 void DownloadItemGtk::UpdateTooltip() {
482 string16 tooltip_text = 481 string16 tooltip_text =
483 download_model_->GetTooltipText(gfx::Font(), kTooltipMaxWidth); 482 download_model_->GetTooltipText(gfx::Font(), kTooltipMaxWidth);
484 gtk_widget_set_tooltip_text(body_.get(), UTF16ToUTF8(tooltip_text).c_str()); 483 gtk_widget_set_tooltip_text(body_.get(), UTF16ToUTF8(tooltip_text).c_str());
485 } 484 }
486 485
487 void DownloadItemGtk::UpdateNameLabel() { 486 void DownloadItemGtk::UpdateNameLabel() {
488 // TODO(estade): This is at best an educated guess, since we don't actually 487 // TODO(estade): This is at best an educated guess, since we don't actually
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 get_download()->DangerousDownloadValidated(); 921 get_download()->DangerousDownloadValidated();
923 } 922 }
924 923
925 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { 924 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) {
926 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", 925 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
927 base::Time::Now() - creation_time_); 926 base::Time::Now() - creation_time_);
928 if (get_download()->IsPartialDownload()) 927 if (get_download()->IsPartialDownload())
929 get_download()->Cancel(true); 928 get_download()->Cancel(true);
930 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); 929 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
931 } 930 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/download/download_item_gtk.h ('k') | chrome/browser/ui/views/download/download_item_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698