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

Side by Side Diff: chrome/browser/ui/views/download/download_item_view_md.cc

Issue 1672983002: Fix download danger prompt buttons/actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for tests Created 4 years, 10 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/ui/views/download/download_item_view_md.h ('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) 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/views/download/download_item_view_md.h" 5 #include "chrome/browser/ui/views/download/download_item_view_md.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 delete save_button_; 853 delete save_button_;
854 save_button_ = NULL; 854 save_button_ = NULL;
855 } 855 }
856 RemoveChildView(discard_button_); 856 RemoveChildView(discard_button_);
857 delete discard_button_; 857 delete discard_button_;
858 discard_button_ = NULL; 858 discard_button_ = NULL;
859 RemoveChildView(dangerous_download_label_); 859 RemoveChildView(dangerous_download_label_);
860 delete dangerous_download_label_; 860 delete dangerous_download_label_;
861 dangerous_download_label_ = NULL; 861 dangerous_download_label_ = NULL;
862 dangerous_download_label_sized_ = false; 862 dangerous_download_label_sized_ = false;
863 cached_button_size_.SetSize(0, 0);
864 863
865 // We need to load the icon now that the download has the real path. 864 // We need to load the icon now that the download has the real path.
866 LoadIcon(); 865 LoadIcon();
867 866
868 dropdown_button_->SetVisible(true); 867 dropdown_button_->SetVisible(true);
869 } 868 }
870 869
871 void DownloadItemViewMd::ShowWarningDialog() { 870 void DownloadItemViewMd::ShowWarningDialog() {
872 DCHECK(mode_ != DANGEROUS_MODE && mode_ != MALICIOUS_MODE); 871 DCHECK(mode_ != DANGEROUS_MODE && mode_ != MALICIOUS_MODE);
873 time_download_warning_shown_ = base::Time::Now(); 872 time_download_warning_shown_ = base::Time::Now();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: 936 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE:
938 return gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 937 return gfx::CreateVectorIcon(gfx::VectorIconId::WARNING,
939 kWarningIconSize, 938 kWarningIconSize,
940 gfx::kGoogleYellow700); 939 gfx::kGoogleYellow700);
941 } 940 }
942 return gfx::ImageSkia(); 941 return gfx::ImageSkia();
943 } 942 }
944 943
945 gfx::Size DownloadItemViewMd::GetButtonSize() const { 944 gfx::Size DownloadItemViewMd::GetButtonSize() const {
946 DCHECK(discard_button_ && (mode_ == MALICIOUS_MODE || save_button_)); 945 DCHECK(discard_button_ && (mode_ == MALICIOUS_MODE || save_button_));
947 gfx::Size size; 946 gfx::Size size = discard_button_->GetPreferredSize();
948
949 // We cache the size when successfully retrieved, not for performance reasons
950 // but because if this DownloadItemViewMd is being animated while the tab is
951 // not showing, the native buttons are not parented and their preferred size
952 // is 0, messing-up the layout.
953 if (cached_button_size_.width() != 0)
954 return cached_button_size_;
955
956 if (save_button_) 947 if (save_button_)
957 size = save_button_->GetMinimumSize(); 948 size.SetToMax(save_button_->GetPreferredSize());
958 gfx::Size discard_size = discard_button_->GetMinimumSize();
959
960 size.SetSize(std::max(size.width(), discard_size.width()),
961 std::max(size.height(), discard_size.height()));
962
963 if (size.width() != 0)
964 cached_button_size_ = size;
965
966 return size; 949 return size;
967 } 950 }
968 951
969 // This method computes the minimum width of the label for displaying its text 952 // This method computes the minimum width of the label for displaying its text
970 // on 2 lines. It just breaks the string in 2 lines on the spaces and keeps the 953 // on 2 lines. It just breaks the string in 2 lines on the spaces and keeps the
971 // configuration with minimum width. 954 // configuration with minimum width.
972 void DownloadItemViewMd::SizeLabelToMinWidth() { 955 void DownloadItemViewMd::SizeLabelToMinWidth() {
973 if (dangerous_download_label_sized_) 956 if (dangerous_download_label_sized_)
974 return; 957 return;
975 958
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 SchedulePaint(); 1060 SchedulePaint();
1078 } 1061 }
1079 1062
1080 SkColor DownloadItemViewMd::GetTextColor() { 1063 SkColor DownloadItemViewMd::GetTextColor() {
1081 return GetTextColorForThemeProvider(GetThemeProvider()); 1064 return GetTextColorForThemeProvider(GetThemeProvider());
1082 } 1065 }
1083 1066
1084 SkColor DownloadItemViewMd::GetDimmedTextColor() { 1067 SkColor DownloadItemViewMd::GetDimmedTextColor() {
1085 return SkColorSetA(GetTextColor(), 0xC7); 1068 return SkColorSetA(GetTextColor(), 0xC7);
1086 } 1069 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view_md.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698