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

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

Issue 2305933002: Update dialog close buttons to use vector icons and ripples. (Closed)
Patch Set: delegate Created 4 years, 3 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
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 17 matching lines...) Expand all
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/label.h" 68 #include "ui/views/controls/label.h"
69 #include "ui/views/mouse_constants.h" 69 #include "ui/views/mouse_constants.h"
70 #include "ui/views/widget/root_view.h" 70 #include "ui/views/widget/root_view.h"
71 #include "ui/views/widget/widget.h" 71 #include "ui/views/widget/widget.h"
72 72
73 using content::DownloadItem; 73 using content::DownloadItem;
74 using extensions::ExperienceSamplingEvent; 74 using extensions::ExperienceSamplingEvent;
75 75
76 namespace { 76 namespace {
77 77
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 private: 147 private:
148 SkColor color_; 148 SkColor color_;
149 149
150 DISALLOW_COPY_AND_ASSIGN(SeparatorBorder); 150 DISALLOW_COPY_AND_ASSIGN(SeparatorBorder);
151 }; 151 };
152 152
153 } // namespace 153 } // namespace
154 154
155 // Allows the DownloadItemViewMd to control the InkDrop on the drop down button. 155 // Allows the DownloadItemViewMd to control the InkDrop on the drop down button.
156 class DownloadItemViewMd::DropDownButton : public BarControlButton { 156 class DownloadItemViewMd::DropDownButton : public views::VectorIconButton {
157 public: 157 public:
158 explicit DropDownButton(views::ButtonListener* listener) 158 explicit DropDownButton(views::VectorIconButtonDelegate* delegate)
159 : BarControlButton(listener) {} 159 : views::VectorIconButton(delegate) {}
160 ~DropDownButton() override {} 160 ~DropDownButton() override {}
161 161
162 // Promoted visibility to public. 162 // Promoted visibility to public.
163 void AnimateInkDrop(views::InkDropState state) { 163 void AnimateInkDrop(views::InkDropState state) {
164 // TODO(bruthig): Plumb in the proper Event. 164 // TODO(bruthig): Plumb in the proper Event.
165 BarControlButton::AnimateInkDrop(state, nullptr /* event */); 165 views::VectorIconButton::AnimateInkDrop(state, nullptr /* event */);
166 } 166 }
167 167
168 private: 168 private:
169 DISALLOW_COPY_AND_ASSIGN(DropDownButton); 169 DISALLOW_COPY_AND_ASSIGN(DropDownButton);
170 }; 170 };
171 171
172 DownloadItemViewMd::DownloadItemViewMd(DownloadItem* download_item, 172 DownloadItemViewMd::DownloadItemViewMd(DownloadItem* download_item,
173 DownloadShelfView* parent) 173 DownloadShelfView* parent)
174 : shelf_(parent), 174 : shelf_(parent),
175 status_text_(l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING)), 175 status_text_(l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING)),
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 } else { 587 } else {
588 PossiblySubmitDownloadToFeedbackService( 588 PossiblySubmitDownloadToFeedbackService(
589 shelf_->browser()->profile()->GetPrefs()->GetBoolean( 589 shelf_->browser()->profile()->GetPrefs()->GetBoolean(
590 prefs::kSafeBrowsingExtendedReportingEnabled)); 590 prefs::kSafeBrowsingExtendedReportingEnabled));
591 } 591 }
592 return; 592 return;
593 } 593 }
594 download()->Remove(); 594 download()->Remove();
595 } 595 }
596 596
597 SkColor DownloadItemViewMd::GetVectorIconBaseColor() const {
598 return GetTextColor();
599 }
600
597 void DownloadItemViewMd::AnimationProgressed(const gfx::Animation* animation) { 601 void DownloadItemViewMd::AnimationProgressed(const gfx::Animation* animation) {
598 // We don't care if what animation (body button/drop button/complete), 602 // We don't care if what animation (body button/drop button/complete),
599 // is calling back, as they all have to go through the same paint call. 603 // is calling back, as they all have to go through the same paint call.
600 SchedulePaint(); 604 SchedulePaint();
601 } 605 }
602 606
603 void DownloadItemViewMd::OnPaint(gfx::Canvas* canvas) { 607 void DownloadItemViewMd::OnPaint(gfx::Canvas* canvas) {
604 // Make sure to draw |this| opaquely. Since the toolbar color can be partially 608 // Make sure to draw |this| opaquely. Since the toolbar color can be partially
605 // transparent, start with a black backdrop (which is the default initialized 609 // transparent, start with a black backdrop (which is the default initialized
606 // color for opaque canvases). 610 // color for opaque canvases).
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 OpenDownload(); 867 OpenDownload();
864 } 868 }
865 869
866 void DownloadItemViewMd::SetDropdownState(State new_state) { 870 void DownloadItemViewMd::SetDropdownState(State new_state) {
867 // Avoid extra SchedulePaint()s if the state is going to be the same and 871 // Avoid extra SchedulePaint()s if the state is going to be the same and
868 // |dropdown_button_| has already been initialized. 872 // |dropdown_button_| has already been initialized.
869 if (dropdown_state_ == new_state && 873 if (dropdown_state_ == new_state &&
870 !dropdown_button_->GetImage(views::CustomButton::STATE_NORMAL).isNull()) 874 !dropdown_button_->GetImage(views::CustomButton::STATE_NORMAL).isNull())
871 return; 875 return;
872 876
873 dropdown_button_->SetIcon( 877 dropdown_button_->SetIcon(new_state == PUSHED ? gfx::VectorIconId::FIND_NEXT
874 new_state == PUSHED ? gfx::VectorIconId::FIND_NEXT 878 : gfx::VectorIconId::FIND_PREV);
875 : gfx::VectorIconId::FIND_PREV,
876 base::Bind(&DownloadItemViewMd::GetTextColor, base::Unretained(this)));
877 if (new_state != dropdown_state_) { 879 if (new_state != dropdown_state_) {
878 dropdown_button_->AnimateInkDrop(new_state == PUSHED 880 dropdown_button_->AnimateInkDrop(new_state == PUSHED
879 ? views::InkDropState::ACTIVATED 881 ? views::InkDropState::ACTIVATED
880 : views::InkDropState::DEACTIVATED); 882 : views::InkDropState::DEACTIVATED);
881 } 883 }
882 dropdown_button_->OnThemeChanged(); 884 dropdown_button_->OnThemeChanged();
883 dropdown_state_ = new_state; 885 dropdown_state_ = new_state;
884 SchedulePaint(); 886 SchedulePaint();
885 } 887 }
886 888
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 SchedulePaint(); 1122 SchedulePaint();
1121 } 1123 }
1122 1124
1123 SkColor DownloadItemViewMd::GetTextColor() const { 1125 SkColor DownloadItemViewMd::GetTextColor() const {
1124 return GetTextColorForThemeProvider(GetThemeProvider()); 1126 return GetTextColorForThemeProvider(GetThemeProvider());
1125 } 1127 }
1126 1128
1127 SkColor DownloadItemViewMd::GetDimmedTextColor() const { 1129 SkColor DownloadItemViewMd::GetDimmedTextColor() const {
1128 return SkColorSetA(GetTextColor(), 0xC7); 1130 return SkColorSetA(GetTextColor(), 0xC7);
1129 } 1131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698