| 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_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 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 28 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 29 #include "chrome/browser/download/download_item_model.h" | 29 #include "chrome/browser/download/download_item_model.h" |
| 30 #include "chrome/browser/download/download_stats.h" | 30 #include "chrome/browser/download/download_stats.h" |
| 31 #include "chrome/browser/download/drag_download_item.h" | 31 #include "chrome/browser/download/drag_download_item.h" |
| 32 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" | 32 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" |
| 33 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
| 34 #include "chrome/browser/safe_browsing/download_feedback_service.h" | 34 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
| 35 #include "chrome/browser/safe_browsing/download_protection_service.h" | 35 #include "chrome/browser/safe_browsing/download_protection_service.h" |
| 36 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 36 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 37 #include "chrome/browser/themes/theme_properties.h" | 37 #include "chrome/browser/themes/theme_properties.h" |
| 38 #include "chrome/browser/ui/views/bar_control_button.h" | |
| 39 #include "chrome/browser/ui/views/download/download_feedback_dialog_view.h" | 38 #include "chrome/browser/ui/views/download/download_feedback_dialog_view.h" |
| 40 #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" | 39 #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" |
| 41 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 40 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
| 42 #include "chrome/browser/ui/views/frame/browser_view.h" | 41 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 43 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
| 44 #include "chrome/grit/generated_resources.h" | 43 #include "chrome/grit/generated_resources.h" |
| 45 #include "components/prefs/pref_service.h" | 44 #include "components/prefs/pref_service.h" |
| 46 #include "content/public/browser/download_danger_type.h" | 45 #include "content/public/browser/download_danger_type.h" |
| 47 #include "third_party/icu/source/common/unicode/uchar.h" | 46 #include "third_party/icu/source/common/unicode/uchar.h" |
| 48 #include "ui/accessibility/ax_view_state.h" | 47 #include "ui/accessibility/ax_view_state.h" |
| 49 #include "ui/base/l10n/l10n_util.h" | 48 #include "ui/base/l10n/l10n_util.h" |
| 50 #include "ui/base/material_design/material_design_controller.h" | 49 #include "ui/base/material_design/material_design_controller.h" |
| 51 #include "ui/base/resource/resource_bundle.h" | 50 #include "ui/base/resource/resource_bundle.h" |
| 52 #include "ui/base/theme_provider.h" | 51 #include "ui/base/theme_provider.h" |
| 53 #include "ui/events/event.h" | 52 #include "ui/events/event.h" |
| 54 #include "ui/gfx/animation/slide_animation.h" | 53 #include "ui/gfx/animation/slide_animation.h" |
| 55 #include "ui/gfx/canvas.h" | 54 #include "ui/gfx/canvas.h" |
| 56 #include "ui/gfx/color_palette.h" | 55 #include "ui/gfx/color_palette.h" |
| 57 #include "ui/gfx/color_utils.h" | 56 #include "ui/gfx/color_utils.h" |
| 58 #include "ui/gfx/image/image.h" | 57 #include "ui/gfx/image/image.h" |
| 59 #include "ui/gfx/paint_vector_icon.h" | 58 #include "ui/gfx/paint_vector_icon.h" |
| 60 #include "ui/gfx/text_elider.h" | 59 #include "ui/gfx/text_elider.h" |
| 61 #include "ui/gfx/text_utils.h" | 60 #include "ui/gfx/text_utils.h" |
| 62 #include "ui/gfx/vector_icons_public.h" | 61 #include "ui/gfx/vector_icons_public.h" |
| 63 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 62 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 64 #include "ui/views/animation/ink_drop_highlight.h" | 63 #include "ui/views/animation/ink_drop_highlight.h" |
| 65 #include "ui/views/border.h" | 64 #include "ui/views/border.h" |
| 66 #include "ui/views/controls/button/image_button.h" | 65 #include "ui/views/controls/button/image_button.h" |
| 67 #include "ui/views/controls/button/md_text_button.h" | 66 #include "ui/views/controls/button/md_text_button.h" |
| 67 #include "ui/views/controls/button/vector_icon_button.h" |
| 68 #include "ui/views/controls/focusable_border.h" | 68 #include "ui/views/controls/focusable_border.h" |
| 69 #include "ui/views/controls/label.h" | 69 #include "ui/views/controls/label.h" |
| 70 #include "ui/views/mouse_constants.h" | 70 #include "ui/views/mouse_constants.h" |
| 71 #include "ui/views/widget/root_view.h" | 71 #include "ui/views/widget/root_view.h" |
| 72 #include "ui/views/widget/widget.h" | 72 #include "ui/views/widget/widget.h" |
| 73 | 73 |
| 74 using content::DownloadItem; | 74 using content::DownloadItem; |
| 75 using extensions::ExperienceSamplingEvent; | 75 using extensions::ExperienceSamplingEvent; |
| 76 | 76 |
| 77 namespace { | 77 namespace { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 SkColor color_; | 152 SkColor color_; |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(SeparatorBorder); | 154 DISALLOW_COPY_AND_ASSIGN(SeparatorBorder); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 } // namespace | 157 } // namespace |
| 158 | 158 |
| 159 // Allows the DownloadItemViewMd to control the InkDrop on the drop down button. | 159 // Allows the DownloadItemViewMd to control the InkDrop on the drop down button. |
| 160 class DownloadItemViewMd::DropDownButton : public BarControlButton { | 160 class DownloadItemViewMd::DropDownButton : public views::VectorIconButton { |
| 161 public: | 161 public: |
| 162 explicit DropDownButton(views::ButtonListener* listener) | 162 explicit DropDownButton(views::VectorIconButtonDelegate* delegate) |
| 163 : BarControlButton(listener) {} | 163 : views::VectorIconButton(delegate) {} |
| 164 ~DropDownButton() override {} | 164 ~DropDownButton() override {} |
| 165 | 165 |
| 166 // Promoted visibility to public. | 166 // Promoted visibility to public. |
| 167 void AnimateInkDrop(views::InkDropState state) { | 167 void AnimateInkDrop(views::InkDropState state) { |
| 168 // TODO(bruthig): Plumb in the proper Event. | 168 // TODO(bruthig): Plumb in the proper Event. |
| 169 BarControlButton::AnimateInkDrop(state, nullptr /* event */); | 169 views::VectorIconButton::AnimateInkDrop(state, nullptr /* event */); |
| 170 } | 170 } |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 DISALLOW_COPY_AND_ASSIGN(DropDownButton); | 173 DISALLOW_COPY_AND_ASSIGN(DropDownButton); |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 DownloadItemViewMd::DownloadItemViewMd(DownloadItem* download_item, | 176 DownloadItemViewMd::DownloadItemViewMd(DownloadItem* download_item, |
| 177 DownloadShelfView* parent) | 177 DownloadShelfView* parent) |
| 178 : shelf_(parent), | 178 : shelf_(parent), |
| 179 status_text_(l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING)), | 179 status_text_(l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING)), |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 } else { | 591 } else { |
| 592 PossiblySubmitDownloadToFeedbackService( | 592 PossiblySubmitDownloadToFeedbackService( |
| 593 shelf_->browser()->profile()->GetPrefs()->GetBoolean( | 593 shelf_->browser()->profile()->GetPrefs()->GetBoolean( |
| 594 prefs::kSafeBrowsingExtendedReportingEnabled)); | 594 prefs::kSafeBrowsingExtendedReportingEnabled)); |
| 595 } | 595 } |
| 596 return; | 596 return; |
| 597 } | 597 } |
| 598 download()->Remove(); | 598 download()->Remove(); |
| 599 } | 599 } |
| 600 | 600 |
| 601 SkColor DownloadItemViewMd::GetVectorIconBaseColor() const { |
| 602 return GetTextColor(); |
| 603 } |
| 604 |
| 601 void DownloadItemViewMd::AnimationProgressed(const gfx::Animation* animation) { | 605 void DownloadItemViewMd::AnimationProgressed(const gfx::Animation* animation) { |
| 602 // We don't care if what animation (body button/drop button/complete), | 606 // We don't care if what animation (body button/drop button/complete), |
| 603 // is calling back, as they all have to go through the same paint call. | 607 // is calling back, as they all have to go through the same paint call. |
| 604 SchedulePaint(); | 608 SchedulePaint(); |
| 605 } | 609 } |
| 606 | 610 |
| 607 void DownloadItemViewMd::OnPaint(gfx::Canvas* canvas) { | 611 void DownloadItemViewMd::OnPaint(gfx::Canvas* canvas) { |
| 608 // Make sure to draw |this| opaquely. Since the toolbar color can be partially | 612 // Make sure to draw |this| opaquely. Since the toolbar color can be partially |
| 609 // transparent, start with a black backdrop (which is the default initialized | 613 // transparent, start with a black backdrop (which is the default initialized |
| 610 // color for opaque canvases). | 614 // color for opaque canvases). |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 OpenDownload(); | 868 OpenDownload(); |
| 865 } | 869 } |
| 866 | 870 |
| 867 void DownloadItemViewMd::SetDropdownState(State new_state) { | 871 void DownloadItemViewMd::SetDropdownState(State new_state) { |
| 868 // Avoid extra SchedulePaint()s if the state is going to be the same and | 872 // Avoid extra SchedulePaint()s if the state is going to be the same and |
| 869 // |dropdown_button_| has already been initialized. | 873 // |dropdown_button_| has already been initialized. |
| 870 if (dropdown_state_ == new_state && | 874 if (dropdown_state_ == new_state && |
| 871 !dropdown_button_->GetImage(views::CustomButton::STATE_NORMAL).isNull()) | 875 !dropdown_button_->GetImage(views::CustomButton::STATE_NORMAL).isNull()) |
| 872 return; | 876 return; |
| 873 | 877 |
| 874 dropdown_button_->SetIcon( | 878 dropdown_button_->SetIcon(new_state == PUSHED ? gfx::VectorIconId::FIND_NEXT |
| 875 new_state == PUSHED ? gfx::VectorIconId::FIND_NEXT | 879 : gfx::VectorIconId::FIND_PREV); |
| 876 : gfx::VectorIconId::FIND_PREV, | |
| 877 base::Bind(&DownloadItemViewMd::GetTextColor, base::Unretained(this))); | |
| 878 if (new_state != dropdown_state_) { | 880 if (new_state != dropdown_state_) { |
| 879 dropdown_button_->AnimateInkDrop(new_state == PUSHED | 881 dropdown_button_->AnimateInkDrop(new_state == PUSHED |
| 880 ? views::InkDropState::ACTIVATED | 882 ? views::InkDropState::ACTIVATED |
| 881 : views::InkDropState::DEACTIVATED); | 883 : views::InkDropState::DEACTIVATED); |
| 882 } | 884 } |
| 883 dropdown_button_->OnThemeChanged(); | 885 dropdown_button_->OnThemeChanged(); |
| 884 dropdown_state_ = new_state; | 886 dropdown_state_ = new_state; |
| 885 SchedulePaint(); | 887 SchedulePaint(); |
| 886 } | 888 } |
| 887 | 889 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 SchedulePaint(); | 1123 SchedulePaint(); |
| 1122 } | 1124 } |
| 1123 | 1125 |
| 1124 SkColor DownloadItemViewMd::GetTextColor() const { | 1126 SkColor DownloadItemViewMd::GetTextColor() const { |
| 1125 return GetTextColorForThemeProvider(GetThemeProvider()); | 1127 return GetTextColorForThemeProvider(GetThemeProvider()); |
| 1126 } | 1128 } |
| 1127 | 1129 |
| 1128 SkColor DownloadItemViewMd::GetDimmedTextColor() const { | 1130 SkColor DownloadItemViewMd::GetDimmedTextColor() const { |
| 1129 return SkColorSetA(GetTextColor(), 0xC7); | 1131 return SkColorSetA(GetTextColor(), 0xC7); |
| 1130 } | 1132 } |
| OLD | NEW |