| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 dangerous_download_label_sized_(false), | 102 dangerous_download_label_sized_(false), |
| 103 disabled_while_opening_(false), | 103 disabled_while_opening_(false), |
| 104 creation_time_(base::Time::Now()), | 104 creation_time_(base::Time::Now()), |
| 105 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 105 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| 106 DCHECK(download_); | 106 DCHECK(download_); |
| 107 download_->AddObserver(this); | 107 download_->AddObserver(this); |
| 108 | 108 |
| 109 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 109 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 110 | 110 |
| 111 BodyImageSet normal_body_image_set = { | 111 BodyImageSet normal_body_image_set = { |
| 112 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_TOP), | 112 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_TOP), |
| 113 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE), | 113 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE), |
| 114 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM), | 114 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM), |
| 115 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP), | 115 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP), |
| 116 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_MIDDLE), | 116 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_MIDDLE), |
| 117 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM), | 117 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM), |
| 118 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_TOP), | 118 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_TOP), |
| 119 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_MIDDLE), | 119 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_MIDDLE), |
| 120 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM) | 120 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM) |
| 121 }; | 121 }; |
| 122 normal_body_image_set_ = normal_body_image_set; | 122 normal_body_image_set_ = normal_body_image_set; |
| 123 | 123 |
| 124 DropDownImageSet normal_drop_down_image_set = { | 124 DropDownImageSet normal_drop_down_image_set = { |
| 125 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_MENU_TOP), | 125 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_MENU_TOP), |
| 126 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_MENU_MIDDLE), | 126 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_MENU_MIDDLE), |
| 127 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_MENU_BOTTOM) | 127 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_MENU_BOTTOM) |
| 128 }; | 128 }; |
| 129 normal_drop_down_image_set_ = normal_drop_down_image_set; | 129 normal_drop_down_image_set_ = normal_drop_down_image_set; |
| 130 | 130 |
| 131 BodyImageSet hot_body_image_set = { | 131 BodyImageSet hot_body_image_set = { |
| 132 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_TOP_H), | 132 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_TOP_H), |
| 133 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE_H), | 133 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE_H), |
| 134 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM_H), | 134 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM_H), |
| 135 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP_H), | 135 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP_H), |
| 136 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_MIDDLE_H), | 136 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_MIDDLE_H), |
| 137 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM_H), | 137 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM_H), |
| 138 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_TOP_H), | 138 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_TOP_H), |
| 139 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_MIDDLE_H), | 139 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_MIDDLE_H), |
| 140 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_H) | 140 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_H) |
| 141 }; | 141 }; |
| 142 hot_body_image_set_ = hot_body_image_set; | 142 hot_body_image_set_ = hot_body_image_set; |
| 143 | 143 |
| 144 DropDownImageSet hot_drop_down_image_set = { | 144 DropDownImageSet hot_drop_down_image_set = { |
| 145 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_MENU_TOP_H), | 145 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_MENU_TOP_H), |
| 146 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_MENU_MIDDLE_H), | 146 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_MENU_MIDDLE_H), |
| 147 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_MENU_BOTTOM_H) | 147 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_MENU_BOTTOM_H) |
| 148 }; | 148 }; |
| 149 hot_drop_down_image_set_ = hot_drop_down_image_set; | 149 hot_drop_down_image_set_ = hot_drop_down_image_set; |
| 150 | 150 |
| 151 BodyImageSet pushed_body_image_set = { | 151 BodyImageSet pushed_body_image_set = { |
| 152 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_TOP_P), | 152 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_TOP_P), |
| 153 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE_P), | 153 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE_P), |
| 154 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM_P), | 154 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM_P), |
| 155 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP_P), | 155 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP_P), |
| 156 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_MIDDLE_P), | 156 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_MIDDLE_P), |
| 157 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM_P), | 157 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM_P), |
| 158 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_TOP_P), | 158 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_TOP_P), |
| 159 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_MIDDLE_P), | 159 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_MIDDLE_P), |
| 160 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_P) | 160 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_P) |
| 161 }; | 161 }; |
| 162 pushed_body_image_set_ = pushed_body_image_set; | 162 pushed_body_image_set_ = pushed_body_image_set; |
| 163 | 163 |
| 164 DropDownImageSet pushed_drop_down_image_set = { | 164 DropDownImageSet pushed_drop_down_image_set = { |
| 165 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_MENU_TOP_P), | 165 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_MENU_TOP_P), |
| 166 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_MENU_MIDDLE_P), | 166 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_MENU_MIDDLE_P), |
| 167 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_MENU_BOTTOM_P) | 167 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_MENU_BOTTOM_P) |
| 168 }; | 168 }; |
| 169 pushed_drop_down_image_set_ = pushed_drop_down_image_set; | 169 pushed_drop_down_image_set_ = pushed_drop_down_image_set; |
| 170 | 170 |
| 171 BodyImageSet dangerous_mode_body_image_set = { | 171 BodyImageSet dangerous_mode_body_image_set = { |
| 172 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_TOP), | 172 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_TOP), |
| 173 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE), | 173 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE), |
| 174 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM), | 174 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM), |
| 175 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP), | 175 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP), |
| 176 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_MIDDLE), | 176 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_MIDDLE), |
| 177 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM), | 177 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_CENTER_BOTTOM), |
| 178 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_TOP_NO_DD), | 178 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_TOP_NO_DD), |
| 179 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_MIDDLE_NO_DD), | 179 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_MIDDLE_NO_DD), |
| 180 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_NO_DD) | 180 rb.GetImageSkiaNamed(IDR_DOWNLOAD_BUTTON_RIGHT_BOTTOM_NO_DD) |
| 181 }; | 181 }; |
| 182 dangerous_mode_body_image_set_ = dangerous_mode_body_image_set; | 182 dangerous_mode_body_image_set_ = dangerous_mode_body_image_set; |
| 183 | 183 |
| 184 malicious_mode_body_image_set_ = normal_body_image_set; | 184 malicious_mode_body_image_set_ = normal_body_image_set; |
| 185 | 185 |
| 186 LoadIcon(); | 186 LoadIcon(); |
| 187 | 187 |
| 188 font_ = rb.GetFont(ui::ResourceBundle::BaseFont); | 188 font_ = rb.GetFont(ui::ResourceBundle::BaseFont); |
| 189 box_height_ = std::max<int>(2 * kVerticalPadding + font_.GetHeight() + | 189 box_height_ = std::max<int>(2 * kVerticalPadding + font_.GetHeight() + |
| 190 kVerticalTextPadding + font_.GetHeight(), | 190 kVerticalTextPadding + font_.GetHeight(), |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 canvas->Save(); | 731 canvas->Save(); |
| 732 if (base::i18n::IsRTL()) { | 732 if (base::i18n::IsRTL()) { |
| 733 // Since we do not have the mirrored images for | 733 // Since we do not have the mirrored images for |
| 734 // (hot_)body_image_set->top_left, (hot_)body_image_set->left, | 734 // (hot_)body_image_set->top_left, (hot_)body_image_set->left, |
| 735 // (hot_)body_image_set->bottom_left, and drop_down_image_set, | 735 // (hot_)body_image_set->bottom_left, and drop_down_image_set, |
| 736 // for RTL UI, we flip the canvas to draw those images mirrored. | 736 // for RTL UI, we flip the canvas to draw those images mirrored. |
| 737 // Consequently, we do not need to mirror the x-axis of those images. | 737 // Consequently, we do not need to mirror the x-axis of those images. |
| 738 canvas->Translate(gfx::Point(width(), 0)); | 738 canvas->Translate(gfx::Point(width(), 0)); |
| 739 canvas->Scale(-1, 1); | 739 canvas->Scale(-1, 1); |
| 740 } | 740 } |
| 741 PaintBitmaps(canvas, | 741 PaintImages(canvas, |
| 742 body_image_set->top_left, body_image_set->left, | 742 body_image_set->top_left, body_image_set->left, |
| 743 body_image_set->bottom_left, | 743 body_image_set->bottom_left, |
| 744 x, box_y_, box_height_, body_image_set->top_left->width()); | 744 x, box_y_, box_height_, body_image_set->top_left->width()); |
| 745 x += body_image_set->top_left->width(); | 745 x += body_image_set->top_left->width(); |
| 746 PaintBitmaps(canvas, | 746 PaintImages(canvas, |
| 747 body_image_set->top, body_image_set->center, | 747 body_image_set->top, body_image_set->center, |
| 748 body_image_set->bottom, | 748 body_image_set->bottom, |
| 749 x, box_y_, box_height_, center_width); | 749 x, box_y_, box_height_, center_width); |
| 750 x += center_width; | 750 x += center_width; |
| 751 PaintBitmaps(canvas, | 751 PaintImages(canvas, |
| 752 body_image_set->top_right, body_image_set->right, | 752 body_image_set->top_right, body_image_set->right, |
| 753 body_image_set->bottom_right, | 753 body_image_set->bottom_right, |
| 754 x, box_y_, box_height_, body_image_set->top_right->width()); | 754 x, box_y_, box_height_, body_image_set->top_right->width()); |
| 755 | 755 |
| 756 // Overlay our body hot state. Warning dialogs don't display body a hot state. | 756 // Overlay our body hot state. Warning dialogs don't display body a hot state. |
| 757 if (!IsShowingWarningDialog() && | 757 if (!IsShowingWarningDialog() && |
| 758 body_hover_animation_->GetCurrentValue() > 0) { | 758 body_hover_animation_->GetCurrentValue() > 0) { |
| 759 canvas->SaveLayerAlpha( | 759 canvas->SaveLayerAlpha( |
| 760 static_cast<int>(body_hover_animation_->GetCurrentValue() * 255)); | 760 static_cast<int>(body_hover_animation_->GetCurrentValue() * 255)); |
| 761 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 761 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
| 762 | 762 |
| 763 int x = kLeftPadding; | 763 int x = kLeftPadding; |
| 764 PaintBitmaps(canvas, | 764 PaintImages(canvas, |
| 765 hot_body_image_set_.top_left, hot_body_image_set_.left, | 765 hot_body_image_set_.top_left, hot_body_image_set_.left, |
| 766 hot_body_image_set_.bottom_left, | 766 hot_body_image_set_.bottom_left, |
| 767 x, box_y_, box_height_, hot_body_image_set_.top_left->width()); | 767 x, box_y_, box_height_, hot_body_image_set_.top_left->width()); |
| 768 x += body_image_set->top_left->width(); | 768 x += body_image_set->top_left->width(); |
| 769 PaintBitmaps(canvas, | 769 PaintImages(canvas, |
| 770 hot_body_image_set_.top, hot_body_image_set_.center, | 770 hot_body_image_set_.top, hot_body_image_set_.center, |
| 771 hot_body_image_set_.bottom, | 771 hot_body_image_set_.bottom, |
| 772 x, box_y_, box_height_, center_width); | 772 x, box_y_, box_height_, center_width); |
| 773 x += center_width; | 773 x += center_width; |
| 774 PaintBitmaps(canvas, | 774 PaintImages(canvas, |
| 775 hot_body_image_set_.top_right, hot_body_image_set_.right, | 775 hot_body_image_set_.top_right, hot_body_image_set_.right, |
| 776 hot_body_image_set_.bottom_right, | 776 hot_body_image_set_.bottom_right, |
| 777 x, box_y_, box_height_, | 777 x, box_y_, box_height_, |
| 778 hot_body_image_set_.top_right->width()); | 778 hot_body_image_set_.top_right->width()); |
| 779 canvas->Restore(); | 779 canvas->Restore(); |
| 780 } | 780 } |
| 781 | 781 |
| 782 x += body_image_set->top_right->width(); | 782 x += body_image_set->top_right->width(); |
| 783 | 783 |
| 784 // Paint the drop-down. | 784 // Paint the drop-down. |
| 785 if (drop_down_image_set) { | 785 if (drop_down_image_set) { |
| 786 PaintBitmaps(canvas, | 786 PaintImages(canvas, |
| 787 drop_down_image_set->top, drop_down_image_set->center, | 787 drop_down_image_set->top, drop_down_image_set->center, |
| 788 drop_down_image_set->bottom, | 788 drop_down_image_set->bottom, |
| 789 x, box_y_, box_height_, drop_down_image_set->top->width()); | 789 x, box_y_, box_height_, drop_down_image_set->top->width()); |
| 790 | 790 |
| 791 // Overlay our drop-down hot state. | 791 // Overlay our drop-down hot state. |
| 792 if (drop_hover_animation_->GetCurrentValue() > 0) { | 792 if (drop_hover_animation_->GetCurrentValue() > 0) { |
| 793 canvas->SaveLayerAlpha( | 793 canvas->SaveLayerAlpha( |
| 794 static_cast<int>(drop_hover_animation_->GetCurrentValue() * 255)); | 794 static_cast<int>(drop_hover_animation_->GetCurrentValue() * 255)); |
| 795 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 795 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
| 796 | 796 |
| 797 PaintBitmaps(canvas, | 797 PaintImages(canvas, |
| 798 drop_down_image_set->top, drop_down_image_set->center, | 798 drop_down_image_set->top, drop_down_image_set->center, |
| 799 drop_down_image_set->bottom, | 799 drop_down_image_set->bottom, |
| 800 x, box_y_, box_height_, drop_down_image_set->top->width()); | 800 x, box_y_, box_height_, drop_down_image_set->top->width()); |
| 801 | 801 |
| 802 canvas->Restore(); | 802 canvas->Restore(); |
| 803 } | 803 } |
| 804 } | 804 } |
| 805 | 805 |
| 806 // Restore the canvas to avoid file name etc. text are drawn flipped. | 806 // Restore the canvas to avoid file name etc. text are drawn flipped. |
| 807 // Consequently, the x-axis of following canvas->DrawXXX() method should be | 807 // Consequently, the x-axis of following canvas->DrawXXX() method should be |
| 808 // mirrored so the text and images are down in the right positions. | 808 // mirrored so the text and images are down in the right positions. |
| 809 canvas->Restore(); | 809 canvas->Restore(); |
| 810 | 810 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 canvas->DrawStringInt(filename, font_, | 842 canvas->DrawStringInt(filename, font_, |
| 843 enabled() ? file_name_color | 843 enabled() ? file_name_color |
| 844 : kFileNameDisabledColor, | 844 : kFileNameDisabledColor, |
| 845 mirrored_x, y, kTextWidth, font_.GetHeight()); | 845 mirrored_x, y, kTextWidth, font_.GetHeight()); |
| 846 } | 846 } |
| 847 | 847 |
| 848 // Load the icon. | 848 // Load the icon. |
| 849 IconManager* im = g_browser_process->icon_manager(); | 849 IconManager* im = g_browser_process->icon_manager(); |
| 850 gfx::Image* image = im->LookupIcon(download_->GetUserVerifiedFilePath(), | 850 gfx::Image* image = im->LookupIcon(download_->GetUserVerifiedFilePath(), |
| 851 IconLoader::SMALL); | 851 IconLoader::SMALL); |
| 852 const SkBitmap* icon = NULL; | 852 const gfx::ImageSkia* icon = NULL; |
| 853 if (IsShowingWarningDialog()) | 853 if (IsShowingWarningDialog()) |
| 854 icon = warning_icon_; | 854 icon = warning_icon_; |
| 855 else if (image) | 855 else if (image) |
| 856 icon = image->ToSkBitmap(); | 856 icon = image->ToImageSkia(); |
| 857 | 857 |
| 858 // We count on the fact that the icon manager will cache the icons and if one | 858 // We count on the fact that the icon manager will cache the icons and if one |
| 859 // is available, it will be cached here. We *don't* want to request the icon | 859 // is available, it will be cached here. We *don't* want to request the icon |
| 860 // to be loaded here, since this will also get called if the icon can't be | 860 // to be loaded here, since this will also get called if the icon can't be |
| 861 // loaded, in which case LookupIcon will always be NULL. The loading will be | 861 // loaded, in which case LookupIcon will always be NULL. The loading will be |
| 862 // triggered only when we think the status might change. | 862 // triggered only when we think the status might change. |
| 863 if (icon) { | 863 if (icon) { |
| 864 if (!IsShowingWarningDialog()) { | 864 if (!IsShowingWarningDialog()) { |
| 865 if (download_->IsInProgress()) { | 865 if (download_->IsInProgress()) { |
| 866 download_util::PaintDownloadProgress(canvas, this, 0, 0, | 866 download_util::PaintDownloadProgress(canvas, this, 0, 0, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 void DownloadItemView::LoadIconIfItemPathChanged() { | 926 void DownloadItemView::LoadIconIfItemPathChanged() { |
| 927 FilePath current_download_path = download_->GetUserVerifiedFilePath(); | 927 FilePath current_download_path = download_->GetUserVerifiedFilePath(); |
| 928 if (last_download_item_path_ == current_download_path) | 928 if (last_download_item_path_ == current_download_path) |
| 929 return; | 929 return; |
| 930 | 930 |
| 931 LoadIcon(); | 931 LoadIcon(); |
| 932 } | 932 } |
| 933 | 933 |
| 934 // Load an icon for the file type we're downloading, and animate any in progress | 934 // Load an icon for the file type we're downloading, and animate any in progress |
| 935 // download state. | 935 // download state. |
| 936 void DownloadItemView::PaintBitmaps(gfx::Canvas* canvas, | 936 void DownloadItemView::PaintImages(gfx::Canvas* canvas, |
| 937 const SkBitmap* top_bitmap, | 937 const gfx::ImageSkia* top_image, |
| 938 const SkBitmap* center_bitmap, | 938 const gfx::ImageSkia* center_image, |
| 939 const SkBitmap* bottom_bitmap, | 939 const gfx::ImageSkia* bottom_image, |
| 940 int x, int y, int height, int width) { | 940 int x, int y, int height, int width) { |
| 941 int middle_height = height - top_bitmap->height() - bottom_bitmap->height(); | 941 int middle_height = height - top_image->height() - bottom_image->height(); |
| 942 // Draw the top. | 942 // Draw the top. |
| 943 canvas->DrawBitmapInt(*top_bitmap, | 943 canvas->DrawBitmapInt(*top_image, |
| 944 0, 0, top_bitmap->width(), top_bitmap->height(), | 944 0, 0, top_image->width(), top_image->height(), |
| 945 x, y, width, top_bitmap->height(), false); | 945 x, y, width, top_image->height(), false); |
| 946 y += top_bitmap->height(); | 946 y += top_image->height(); |
| 947 // Draw the center. | 947 // Draw the center. |
| 948 canvas->DrawBitmapInt(*center_bitmap, | 948 canvas->DrawBitmapInt(*center_image, |
| 949 0, 0, center_bitmap->width(), center_bitmap->height(), | 949 0, 0, center_image->width(), center_image->height(), |
| 950 x, y, width, middle_height, false); | 950 x, y, width, middle_height, false); |
| 951 y += middle_height; | 951 y += middle_height; |
| 952 // Draw the bottom. | 952 // Draw the bottom. |
| 953 canvas->DrawBitmapInt(*bottom_bitmap, | 953 canvas->DrawBitmapInt(*bottom_image, |
| 954 0, 0, bottom_bitmap->width(), bottom_bitmap->height(), | 954 0, 0, bottom_image->width(), bottom_image->height(), |
| 955 x, y, width, bottom_bitmap->height(), false); | 955 x, y, width, bottom_image->height(), false); |
| 956 } | 956 } |
| 957 | 957 |
| 958 void DownloadItemView::SetState(State body_state, State drop_down_state) { | 958 void DownloadItemView::SetState(State body_state, State drop_down_state) { |
| 959 // If we are showing a warning dialog, we don't change body state. | 959 // If we are showing a warning dialog, we don't change body state. |
| 960 if (IsShowingWarningDialog()) { | 960 if (IsShowingWarningDialog()) { |
| 961 body_state = NORMAL; | 961 body_state = NORMAL; |
| 962 | 962 |
| 963 // Current body_state_ should always be NORMAL for warning dialogs. | 963 // Current body_state_ should always be NORMAL for warning dialogs. |
| 964 DCHECK(body_state_ == NORMAL); | 964 DCHECK(body_state_ == NORMAL); |
| 965 // We shouldn't be calling SetState if we are in DANGEROUS_MODE. | 965 // We shouldn't be calling SetState if we are in DANGEROUS_MODE. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 } | 1026 } |
| 1027 discard_button_ = new views::NativeTextButton( | 1027 discard_button_ = new views::NativeTextButton( |
| 1028 this, l10n_util::GetStringUTF16(IDS_DISCARD_DOWNLOAD)); | 1028 this, l10n_util::GetStringUTF16(IDS_DISCARD_DOWNLOAD)); |
| 1029 discard_button_->set_ignore_minimum_size(true); | 1029 discard_button_->set_ignore_minimum_size(true); |
| 1030 AddChildView(discard_button_); | 1030 AddChildView(discard_button_); |
| 1031 | 1031 |
| 1032 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1032 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 1033 // The dangerous download label text and icon are different under | 1033 // The dangerous download label text and icon are different under |
| 1034 // different cases. | 1034 // different cases. |
| 1035 if (mode_ == MALICIOUS_MODE) { | 1035 if (mode_ == MALICIOUS_MODE) { |
| 1036 warning_icon_ = rb.GetBitmapNamed(IDR_SAFEBROWSING_WARNING); | 1036 warning_icon_ = rb.GetImageSkiaNamed(IDR_SAFEBROWSING_WARNING); |
| 1037 } else { | 1037 } else { |
| 1038 // The download file has dangerous file type (e.g.: an executable). | 1038 // The download file has dangerous file type (e.g.: an executable). |
| 1039 warning_icon_ = rb.GetBitmapNamed(IDR_WARNING); | 1039 warning_icon_ = rb.GetImageSkiaNamed(IDR_WARNING); |
| 1040 } | 1040 } |
| 1041 string16 dangerous_label = model_->GetWarningText(font_, kTextWidth); | 1041 string16 dangerous_label = model_->GetWarningText(font_, kTextWidth); |
| 1042 dangerous_download_label_ = new views::Label(dangerous_label); | 1042 dangerous_download_label_ = new views::Label(dangerous_label); |
| 1043 dangerous_download_label_->SetMultiLine(true); | 1043 dangerous_download_label_->SetMultiLine(true); |
| 1044 dangerous_download_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 1044 dangerous_download_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 1045 dangerous_download_label_->SetAutoColorReadabilityEnabled(false); | 1045 dangerous_download_label_->SetAutoColorReadabilityEnabled(false); |
| 1046 AddChildView(dangerous_download_label_); | 1046 AddChildView(dangerous_download_label_); |
| 1047 SizeLabelToMinWidth(); | 1047 SizeLabelToMinWidth(); |
| 1048 UpdateDropDownButtonPosition(); | 1048 UpdateDropDownButtonPosition(); |
| 1049 TooltipTextChanged(); | 1049 TooltipTextChanged(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 // Drop down button is glued to the left of the download shelf. | 1180 // Drop down button is glued to the left of the download shelf. |
| 1181 drop_down_x_left_ = 0; | 1181 drop_down_x_left_ = 0; |
| 1182 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); | 1182 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); |
| 1183 } else { | 1183 } else { |
| 1184 // Drop down button is glued to the right of the download shelf. | 1184 // Drop down button is glued to the right of the download shelf. |
| 1185 drop_down_x_left_ = | 1185 drop_down_x_left_ = |
| 1186 size.width() - normal_drop_down_image_set_.top->width(); | 1186 size.width() - normal_drop_down_image_set_.top->width(); |
| 1187 drop_down_x_right_ = size.width(); | 1187 drop_down_x_right_ = size.width(); |
| 1188 } | 1188 } |
| 1189 } | 1189 } |
| OLD | NEW |