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/views/download/download_item_view.h" | 5 #include "chrome/browser/ui/views/download/download_item_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "ui/base/accessibility/accessible_view_state.h" | 31 #include "ui/base/accessibility/accessible_view_state.h" |
32 #include "ui/base/animation/slide_animation.h" | 32 #include "ui/base/animation/slide_animation.h" |
33 #include "ui/base/events/event.h" | 33 #include "ui/base/events/event.h" |
34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/base/text/text_elider.h" | 36 #include "ui/base/text/text_elider.h" |
37 #include "ui/base/theme_provider.h" | 37 #include "ui/base/theme_provider.h" |
38 #include "ui/gfx/canvas.h" | 38 #include "ui/gfx/canvas.h" |
39 #include "ui/gfx/color_utils.h" | 39 #include "ui/gfx/color_utils.h" |
40 #include "ui/gfx/image/image.h" | 40 #include "ui/gfx/image/image.h" |
41 #include "ui/views/controls/button/text_button.h" | 41 #include "ui/views/controls/button/label_button.h" |
42 #include "ui/views/controls/label.h" | 42 #include "ui/views/controls/label.h" |
43 #include "ui/views/widget/root_view.h" | 43 #include "ui/views/widget/root_view.h" |
44 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
45 | 45 |
46 // TODO(paulg): These may need to be adjusted when download progress | 46 // TODO(paulg): These may need to be adjusted when download progress |
47 // animation is added, and also possibly to take into account | 47 // animation is added, and also possibly to take into account |
48 // different screen resolutions. | 48 // different screen resolutions. |
49 static const int kTextWidth = 140; // Pixels | 49 static const int kTextWidth = 140; // Pixels |
50 static const int kDangerousTextWidth = 200; // Pixels | 50 static const int kDangerousTextWidth = 200; // Pixels |
51 static const int kHorizontalTextPadding = 2; // Pixels | 51 static const int kHorizontalTextPadding = 2; // Pixels |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1037 TooltipTextChanged(); | 1037 TooltipTextChanged(); |
1038 } | 1038 } |
1039 | 1039 |
1040 void DownloadItemView::ShowWarningDialog() { | 1040 void DownloadItemView::ShowWarningDialog() { |
1041 DCHECK(mode_ != DANGEROUS_MODE && mode_ != MALICIOUS_MODE); | 1041 DCHECK(mode_ != DANGEROUS_MODE && mode_ != MALICIOUS_MODE); |
1042 mode_ = ((model_.IsMalicious()) ? MALICIOUS_MODE : DANGEROUS_MODE); | 1042 mode_ = ((model_.IsMalicious()) ? MALICIOUS_MODE : DANGEROUS_MODE); |
1043 | 1043 |
1044 body_state_ = NORMAL; | 1044 body_state_ = NORMAL; |
1045 drop_down_state_ = NORMAL; | 1045 drop_down_state_ = NORMAL; |
1046 if (mode_ == DANGEROUS_MODE) { | 1046 if (mode_ == DANGEROUS_MODE) { |
1047 save_button_ = new views::NativeTextButton( | 1047 save_button_ = new views::LabelButton( |
1048 this, model_.GetWarningConfirmButtonText()); | 1048 this, model_.GetWarningConfirmButtonText()); |
1049 save_button_->set_ignore_minimum_size(true); | 1049 save_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
1050 save_button_->set_min_size(gfx::Size()); | |
msw
2013/04/04 02:31:03
Interestingly, TextButton::set_ignore_minimum_size
tfarina
2013/04/04 22:36:52
Done.
| |
1050 AddChildView(save_button_); | 1051 AddChildView(save_button_); |
1051 } | 1052 } |
1052 discard_button_ = new views::NativeTextButton( | 1053 discard_button_ = new views::LabelButton( |
1053 this, l10n_util::GetStringUTF16(IDS_DISCARD_DOWNLOAD)); | 1054 this, l10n_util::GetStringUTF16(IDS_DISCARD_DOWNLOAD)); |
1054 discard_button_->set_ignore_minimum_size(true); | 1055 discard_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
1056 discard_button_->set_min_size(gfx::Size()); | |
msw
2013/04/04 02:31:03
Remove set_min_size as per my earlier comment.
tfarina
2013/04/04 22:36:52
Done.
| |
1055 AddChildView(discard_button_); | 1057 AddChildView(discard_button_); |
1056 | 1058 |
1057 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1059 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
1058 // The dangerous download label text and icon are different under | 1060 // The dangerous download label text and icon are different under |
1059 // different cases. | 1061 // different cases. |
1060 if (mode_ == MALICIOUS_MODE) { | 1062 if (mode_ == MALICIOUS_MODE) { |
1061 warning_icon_ = rb.GetImageSkiaNamed(IDR_SAFEBROWSING_WARNING); | 1063 warning_icon_ = rb.GetImageSkiaNamed(IDR_SAFEBROWSING_WARNING); |
1062 } else { | 1064 } else { |
1063 // The download file has dangerous file type (e.g.: an executable). | 1065 // The download file has dangerous file type (e.g.: an executable). |
1064 warning_icon_ = rb.GetImageSkiaNamed(IDR_WARNING); | 1066 warning_icon_ = rb.GetImageSkiaNamed(IDR_WARNING); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1216 void DownloadItemView::AnimateStateTransition(State from, State to, | 1218 void DownloadItemView::AnimateStateTransition(State from, State to, |
1217 ui::SlideAnimation* animation) { | 1219 ui::SlideAnimation* animation) { |
1218 if (from == NORMAL && to == HOT) { | 1220 if (from == NORMAL && to == HOT) { |
1219 animation->Show(); | 1221 animation->Show(); |
1220 } else if (from == HOT && to == NORMAL) { | 1222 } else if (from == HOT && to == NORMAL) { |
1221 animation->Hide(); | 1223 animation->Hide(); |
1222 } else if (from != to) { | 1224 } else if (from != to) { |
1223 animation->Reset((to == HOT) ? 1.0 : 0.0); | 1225 animation->Reset((to == HOT) ? 1.0 : 0.0); |
1224 } | 1226 } |
1225 } | 1227 } |
OLD | NEW |