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

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

Issue 9968090: Added download error descriptions to tooltips for Mac & Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed tooltip to using the short error status string. Created 8 years, 8 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 switch (download->GetState()) { 328 switch (download->GetState()) {
329 case DownloadItem::REMOVING: 329 case DownloadItem::REMOVING:
330 parent_shelf_->RemoveDownloadItem(this); // This will delete us! 330 parent_shelf_->RemoveDownloadItem(this); // This will delete us!
331 return; 331 return;
332 case DownloadItem::CANCELLED: 332 case DownloadItem::CANCELLED:
333 StopDownloadProgress(); 333 StopDownloadProgress();
334 gtk_widget_queue_draw(progress_area_.get()); 334 gtk_widget_queue_draw(progress_area_.get());
335 break; 335 break;
336 case DownloadItem::INTERRUPTED: 336 case DownloadItem::INTERRUPTED:
337 StopDownloadProgress(); 337 StopDownloadProgress();
338 UpdateTooltip();
338 339
339 complete_animation_.Show(); 340 complete_animation_.Show();
340 break; 341 break;
341 case DownloadItem::COMPLETE: 342 case DownloadItem::COMPLETE:
342 // GetAutoOpened() may change after the download's initial transition to 343 // GetAutoOpened() may change after the download's initial transition to
343 // COMPLETE, so we check it before the idemopotency shield below. 344 // COMPLETE, so we check it before the idemopotency shield below.
344 if (download->GetAutoOpened()) { 345 if (download->GetAutoOpened()) {
345 parent_shelf_->RemoveDownloadItem(this); // This will delete us! 346 parent_shelf_->RemoveDownloadItem(this); // This will delete us!
346 return; 347 return;
347 } 348 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 IconLoader::SMALL, &icon_consumer_, 470 IconLoader::SMALL, &icon_consumer_,
470 base::Bind(&DownloadItemGtk::OnLoadSmallIconComplete, 471 base::Bind(&DownloadItemGtk::OnLoadSmallIconComplete,
471 base::Unretained(this))); 472 base::Unretained(this)));
472 im->LoadIcon(icon_filepath_, 473 im->LoadIcon(icon_filepath_,
473 IconLoader::LARGE, &icon_consumer_, 474 IconLoader::LARGE, &icon_consumer_,
474 base::Bind(&DownloadItemGtk::OnLoadLargeIconComplete, 475 base::Bind(&DownloadItemGtk::OnLoadLargeIconComplete,
475 base::Unretained(this))); 476 base::Unretained(this)));
476 } 477 }
477 478
478 void DownloadItemGtk::UpdateTooltip() { 479 void DownloadItemGtk::UpdateTooltip() {
479 string16 elided_filename = ui::ElideFilename( 480 string16 tooltip_text = ui::ElideFilename(
480 get_download()->GetFileNameToReportUser(), 481 get_download()->GetFileNameToReportUser(), gfx::Font(), kTooltipMaxWidth);
481 gfx::Font(), kTooltipMaxWidth); 482
482 gtk_widget_set_tooltip_text(body_.get(), 483 if (get_download()->GetState() == content::DownloadItem::INTERRUPTED) {
483 UTF16ToUTF8(elided_filename).c_str()); 484 content::DownloadInterruptReason reason = get_download()->GetLastReason();
485 DCHECK(reason != 0);
486
487 // Add the status on another line.
488 tooltip_text += ASCIIToUTF16("\n");
489 tooltip_text += DownloadItemModel::InterruptReasonStatusMessage(reason);
490 }
491
492 gtk_widget_set_tooltip_text(body_.get(), UTF16ToUTF8(tooltip_text).c_str());
484 } 493 }
485 494
486 void DownloadItemGtk::UpdateNameLabel() { 495 void DownloadItemGtk::UpdateNameLabel() {
487 // TODO(estade): This is at best an educated guess, since we don't actually 496 // TODO(estade): This is at best an educated guess, since we don't actually
488 // use gfx::Font() to draw the text. This is why we need to add so 497 // use gfx::Font() to draw the text. This is why we need to add so
489 // much padding when we set the size request. We need to either use gfx::Font 498 // much padding when we set the size request. We need to either use gfx::Font
490 // or somehow extend TextElider. 499 // or somehow extend TextElider.
491 gfx::Font font = gfx::Font(); 500 gfx::Font font = gfx::Font();
492 string16 filename; 501 string16 filename;
493 if (!disabled_while_opening_) { 502 if (!disabled_while_opening_) {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 get_download()->DangerousDownloadValidated(); 927 get_download()->DangerousDownloadValidated();
919 } 928 }
920 929
921 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { 930 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) {
922 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", 931 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download",
923 base::Time::Now() - creation_time_); 932 base::Time::Now() - creation_time_);
924 if (get_download()->IsPartialDownload()) 933 if (get_download()->IsPartialDownload())
925 get_download()->Cancel(true); 934 get_download()->Cancel(true);
926 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); 935 get_download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
927 } 936 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698