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

Side by Side Diff: chrome/browser/views/download_item_view.cc

Issue 3029025: Download code cleanup: (Closed)
Patch Set: rebase'n'final Created 10 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
« no previous file with comments | « chrome/browser/renderer_host/download_resource_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/download_item_view.h" 5 #include "chrome/browser/views/download_item_view.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (download_->state() == DownloadItem::IN_PROGRESS) 426 if (download_->state() == DownloadItem::IN_PROGRESS)
427 download_->Cancel(true); 427 download_->Cancel(true);
428 download_->Remove(true); 428 download_->Remove(true);
429 // WARNING: we are deleted at this point. Don't access 'this'. 429 // WARNING: we are deleted at this point. Don't access 'this'.
430 } else if (sender == save_button_) { 430 } else if (sender == save_button_) {
431 // The user has confirmed a dangerous download. We'd record how quickly the 431 // The user has confirmed a dangerous download. We'd record how quickly the
432 // user did this to detect whether we're being clickjacked. 432 // user did this to detect whether we're being clickjacked.
433 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", 433 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download",
434 base::Time::Now() - creation_time_); 434 base::Time::Now() - creation_time_);
435 // This will change the state and notify us. 435 // This will change the state and notify us.
436 download_->manager()->DangerousDownloadValidated(download_); 436 download_->DangerousDownloadValidated();
437 } 437 }
438 } 438 }
439 439
440 // Load an icon for the file type we're downloading, and animate any in progress 440 // Load an icon for the file type we're downloading, and animate any in progress
441 // download state. 441 // download state.
442 void DownloadItemView::Paint(gfx::Canvas* canvas) { 442 void DownloadItemView::Paint(gfx::Canvas* canvas) {
443 BodyImageSet* body_image_set = NULL; 443 BodyImageSet* body_image_set = NULL;
444 switch (body_state_) { 444 switch (body_state_) {
445 case NORMAL: 445 case NORMAL:
446 case HOT: 446 case HOT:
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 // We don't care if what animation (body button/drop button/complete), 900 // We don't care if what animation (body button/drop button/complete),
901 // is calling back, as they all have to go through the same paint call. 901 // is calling back, as they all have to go through the same paint call.
902 SchedulePaint(); 902 SchedulePaint();
903 } 903 }
904 904
905 void DownloadItemView::OpenDownload() { 905 void DownloadItemView::OpenDownload() {
906 // We're interested in how long it takes users to open downloads. If they 906 // We're interested in how long it takes users to open downloads. If they
907 // open downloads super quickly, we should be concerned about clickjacking. 907 // open downloads super quickly, we should be concerned about clickjacking.
908 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", 908 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download",
909 base::Time::Now() - creation_time_); 909 base::Time::Now() - creation_time_);
910 if (download_->state() == DownloadItem::IN_PROGRESS) { 910 download_->OpenDownload();
911 download_->set_open_when_complete(!download_->open_when_complete());
912 } else if (download_->state() == DownloadItem::COMPLETE) {
913 download_util::OpenDownload(download_);
914 }
915 } 911 }
916 912
917 void DownloadItemView::OnExtractIconComplete(IconManager::Handle handle, 913 void DownloadItemView::OnExtractIconComplete(IconManager::Handle handle,
918 SkBitmap* icon_bitmap) { 914 SkBitmap* icon_bitmap) {
919 if (icon_bitmap) 915 if (icon_bitmap)
920 GetParent()->SchedulePaint(); 916 GetParent()->SchedulePaint();
921 } 917 }
922 918
923 void DownloadItemView::LoadIcon() { 919 void DownloadItemView::LoadIcon() {
924 IconManager* im = g_browser_process->icon_manager(); 920 IconManager* im = g_browser_process->icon_manager();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 void DownloadItemView::Reenable() { 1003 void DownloadItemView::Reenable() {
1008 disabled_while_opening_ = false; 1004 disabled_while_opening_ = false;
1009 SetEnabled(true); // Triggers a repaint. 1005 SetEnabled(true); // Triggers a repaint.
1010 } 1006 }
1011 1007
1012 bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) { 1008 bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) {
1013 if (x > drop_down_x_left_ && x < drop_down_x_right_) 1009 if (x > drop_down_x_left_ && x < drop_down_x_right_)
1014 return true; 1010 return true;
1015 return false; 1011 return false;
1016 } 1012 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/download_resource_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698