| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 gtk_widget_set_no_show_all(menu_button_, FALSE); | 312 gtk_widget_set_no_show_all(menu_button_, FALSE); |
| 313 gtk_widget_show_all(hbox_.get()); | 313 gtk_widget_show_all(hbox_.get()); |
| 314 gtk_widget_destroy(dangerous_prompt_); | 314 gtk_widget_destroy(dangerous_prompt_); |
| 315 gtk_widget_set_size_request(body_.get(), kBodyWidth, -1); | 315 gtk_widget_set_size_request(body_.get(), kBodyWidth, -1); |
| 316 dangerous_prompt_ = NULL; | 316 dangerous_prompt_ = NULL; |
| 317 | 317 |
| 318 // We may free some shelf space for showing more download items. | 318 // We may free some shelf space for showing more download items. |
| 319 parent_shelf_->MaybeShowMoreDownloadItems(); | 319 parent_shelf_->MaybeShowMoreDownloadItems(); |
| 320 } | 320 } |
| 321 | 321 |
| 322 if (download()->GetUserVerifiedFilePath() != icon_filepath_) { | 322 if (download()->GetTargetFilePath() != icon_filepath_) { |
| 323 // Turns out the file path is "Unconfirmed %d.crdownload" for dangerous | |
| 324 // downloads. When the download is confirmed, the file is renamed on | |
| 325 // another thread, so reload the icon if the download filename changes. | |
| 326 LoadIcon(); | 323 LoadIcon(); |
| 327 | |
| 328 UpdateTooltip(); | 324 UpdateTooltip(); |
| 329 } | 325 } |
| 330 | 326 |
| 331 switch (download()->GetState()) { | 327 switch (download()->GetState()) { |
| 332 case DownloadItem::CANCELLED: | 328 case DownloadItem::CANCELLED: |
| 333 StopDownloadProgress(); | 329 StopDownloadProgress(); |
| 334 gtk_widget_queue_draw(progress_area_.get()); | 330 gtk_widget_queue_draw(progress_area_.get()); |
| 335 break; | 331 break; |
| 336 case DownloadItem::INTERRUPTED: | 332 case DownloadItem::INTERRUPTED: |
| 337 StopDownloadProgress(); | 333 StopDownloadProgress(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 icon_large_ = image; | 458 icon_large_ = image; |
| 463 if (download()->IsComplete()) | 459 if (download()->IsComplete()) |
| 464 DownloadItemDrag::SetSource(body_.get(), download(), icon_large_); | 460 DownloadItemDrag::SetSource(body_.get(), download(), icon_large_); |
| 465 // Else, the download will be made draggable once an OnDownloadUpdated() | 461 // Else, the download will be made draggable once an OnDownloadUpdated() |
| 466 // notification is received with download->IsComplete(). | 462 // notification is received with download->IsComplete(). |
| 467 } | 463 } |
| 468 | 464 |
| 469 void DownloadItemGtk::LoadIcon() { | 465 void DownloadItemGtk::LoadIcon() { |
| 470 cancelable_task_tracker_.TryCancelAll(); | 466 cancelable_task_tracker_.TryCancelAll(); |
| 471 IconManager* im = g_browser_process->icon_manager(); | 467 IconManager* im = g_browser_process->icon_manager(); |
| 472 icon_filepath_ = download()->GetUserVerifiedFilePath(); | 468 icon_filepath_ = download()->GetTargetFilePath(); |
| 473 im->LoadIcon(icon_filepath_, | 469 im->LoadIcon(icon_filepath_, |
| 474 IconLoader::SMALL, | 470 IconLoader::SMALL, |
| 475 base::Bind(&DownloadItemGtk::OnLoadSmallIconComplete, | 471 base::Bind(&DownloadItemGtk::OnLoadSmallIconComplete, |
| 476 base::Unretained(this)), | 472 base::Unretained(this)), |
| 477 &cancelable_task_tracker_); | 473 &cancelable_task_tracker_); |
| 478 im->LoadIcon(icon_filepath_, | 474 im->LoadIcon(icon_filepath_, |
| 479 IconLoader::LARGE, | 475 IconLoader::LARGE, |
| 480 base::Bind(&DownloadItemGtk::OnLoadLargeIconComplete, | 476 base::Bind(&DownloadItemGtk::OnLoadLargeIconComplete, |
| 481 base::Unretained(this)), | 477 base::Unretained(this)), |
| 482 &cancelable_task_tracker_); | 478 &cancelable_task_tracker_); |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 download()->DangerousDownloadValidated(); | 921 download()->DangerousDownloadValidated(); |
| 926 } | 922 } |
| 927 | 923 |
| 928 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { | 924 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button) { |
| 929 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 925 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
| 930 base::Time::Now() - creation_time_); | 926 base::Time::Now() - creation_time_); |
| 931 if (download()->IsPartialDownload()) | 927 if (download()->IsPartialDownload()) |
| 932 download()->Cancel(true); | 928 download()->Cancel(true); |
| 933 download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); | 929 download()->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); |
| 934 } | 930 } |
| OLD | NEW |