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

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

Issue 2042073002: Centered flood fill style ink drop ripples on mouse/touch points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Polished for review. Created 4 years, 6 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 BarControlButton {
157 public: 157 public:
158 explicit DropDownButton(views::ButtonListener* listener) 158 explicit DropDownButton(views::ButtonListener* listener)
159 : BarControlButton(listener) {} 159 : BarControlButton(listener) {}
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 BarControlButton::AnimateInkDrop(state); 164 // TODO(bruthig): Plumb in the proper Event.
165 BarControlButton::AnimateInkDrop(state, nullptr /* event */);
165 } 166 }
166 167
167 private: 168 private:
168 DISALLOW_COPY_AND_ASSIGN(DropDownButton); 169 DISALLOW_COPY_AND_ASSIGN(DropDownButton);
169 }; 170 };
170 171
171 DownloadItemViewMd::DownloadItemViewMd(DownloadItem* download_item, 172 DownloadItemViewMd::DownloadItemViewMd(DownloadItem* download_item,
172 DownloadShelfView* parent) 173 DownloadShelfView* parent)
173 : shelf_(parent), 174 : shelf_(parent),
174 status_text_(l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING)), 175 status_text_(l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING)),
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 403
403 // Handle drag (file copy) operations. 404 // Handle drag (file copy) operations.
404 bool DownloadItemViewMd::OnMouseDragged(const ui::MouseEvent& event) { 405 bool DownloadItemViewMd::OnMouseDragged(const ui::MouseEvent& event) {
405 // Mouse should not activate us in dangerous mode. 406 // Mouse should not activate us in dangerous mode.
406 if (IsShowingWarningDialog()) 407 if (IsShowingWarningDialog())
407 return true; 408 return true;
408 409
409 if (!starting_drag_) { 410 if (!starting_drag_) {
410 starting_drag_ = true; 411 starting_drag_ = true;
411 drag_start_point_ = event.location(); 412 drag_start_point_ = event.location();
412 AnimateInkDrop(views::InkDropState::HIDDEN); 413 AnimateInkDrop(views::InkDropState::HIDDEN, &event);
413 } 414 }
414 if (dragging_) { 415 if (dragging_) {
415 if (download()->GetState() == DownloadItem::COMPLETE) { 416 if (download()->GetState() == DownloadItem::COMPLETE) {
416 IconManager* im = g_browser_process->icon_manager(); 417 IconManager* im = g_browser_process->icon_manager();
417 gfx::Image* icon = im->LookupIconFromFilepath( 418 gfx::Image* icon = im->LookupIconFromFilepath(
418 download()->GetTargetFilePath(), IconLoader::SMALL); 419 download()->GetTargetFilePath(), IconLoader::SMALL);
419 views::Widget* widget = GetWidget(); 420 views::Widget* widget = GetWidget();
420 DragDownloadItem(download(), icon, 421 DragDownloadItem(download(), icon,
421 widget ? widget->GetNativeView() : NULL); 422 widget ? widget->GetNativeView() : NULL);
422 } 423 }
(...skipping 20 matching lines...) Expand all
443 } 444 }
444 445
445 bool DownloadItemViewMd::OnKeyPressed(const ui::KeyEvent& event) { 446 bool DownloadItemViewMd::OnKeyPressed(const ui::KeyEvent& event) {
446 // Key press should not activate us in dangerous mode. 447 // Key press should not activate us in dangerous mode.
447 if (IsShowingWarningDialog()) 448 if (IsShowingWarningDialog())
448 return true; 449 return true;
449 450
450 if (event.key_code() == ui::VKEY_SPACE || 451 if (event.key_code() == ui::VKEY_SPACE ||
451 event.key_code() == ui::VKEY_RETURN) { 452 event.key_code() == ui::VKEY_RETURN) {
452 // OpenDownload may delete this, so don't add any code after this line. 453 // OpenDownload may delete this, so don't add any code after this line.
453 OpenDownload(); 454 OpenDownload(event);
454 return true; 455 return true;
455 } 456 }
456 return false; 457 return false;
457 } 458 }
458 459
459 bool DownloadItemViewMd::GetTooltipText(const gfx::Point& p, 460 bool DownloadItemViewMd::GetTooltipText(const gfx::Point& p,
460 base::string16* tooltip) const { 461 base::string16* tooltip) const {
461 if (IsShowingWarningDialog()) { 462 if (IsShowingWarningDialog()) {
462 tooltip->clear(); 463 tooltip->clear();
463 return false; 464 return false;
(...skipping 21 matching lines...) Expand all
485 void DownloadItemViewMd::AddInkDropLayer(ui::Layer* ink_drop_layer) { 486 void DownloadItemViewMd::AddInkDropLayer(ui::Layer* ink_drop_layer) {
486 InkDropHostView::AddInkDropLayer(ink_drop_layer); 487 InkDropHostView::AddInkDropLayer(ink_drop_layer);
487 // The layer that's added to host the ink drop layer must mask to bounds 488 // The layer that's added to host the ink drop layer must mask to bounds
488 // so the hover effect is clipped while animating open. 489 // so the hover effect is clipped while animating open.
489 layer()->SetMasksToBounds(true); 490 layer()->SetMasksToBounds(true);
490 } 491 }
491 492
492 std::unique_ptr<views::InkDropRipple> DownloadItemViewMd::CreateInkDropRipple() 493 std::unique_ptr<views::InkDropRipple> DownloadItemViewMd::CreateInkDropRipple()
493 const { 494 const {
494 return base::WrapUnique(new views::FloodFillInkDropRipple( 495 return base::WrapUnique(new views::FloodFillInkDropRipple(
495 GetLocalBounds(), GetLocalBounds().CenterPoint(), 496 GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(),
496 color_utils::DeriveDefaultIconColor(GetTextColor()))); 497 color_utils::DeriveDefaultIconColor(GetTextColor())));
497 } 498 }
498 499
499 std::unique_ptr<views::InkDropHighlight> 500 std::unique_ptr<views::InkDropHighlight>
500 DownloadItemViewMd::CreateInkDropHighlight() const { 501 DownloadItemViewMd::CreateInkDropHighlight() const {
501 if (IsShowingWarningDialog()) 502 if (IsShowingWarningDialog())
502 return nullptr; 503 return nullptr;
503 504
504 gfx::Size size = GetPreferredSize(); 505 gfx::Size size = GetPreferredSize();
505 return base::WrapUnique(new views::InkDropHighlight( 506 return base::WrapUnique(new views::InkDropHighlight(
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 // We render differently when focused. 741 // We render differently when focused.
741 SchedulePaint(); 742 SchedulePaint();
742 } 743 }
743 744
744 void DownloadItemViewMd::OnBlur() { 745 void DownloadItemViewMd::OnBlur() {
745 View::OnBlur(); 746 View::OnBlur();
746 // We render differently when focused. 747 // We render differently when focused.
747 SchedulePaint(); 748 SchedulePaint();
748 } 749 }
749 750
750 void DownloadItemViewMd::OpenDownload() { 751 void DownloadItemViewMd::OpenDownload(const ui::Event& event) {
751 DCHECK(!IsShowingWarningDialog()); 752 DCHECK(!IsShowingWarningDialog());
752 // We're interested in how long it takes users to open downloads. If they 753 // We're interested in how long it takes users to open downloads. If they
753 // open downloads super quickly, we should be concerned about clickjacking. 754 // open downloads super quickly, we should be concerned about clickjacking.
754 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", 755 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download",
755 base::Time::Now() - creation_time_); 756 base::Time::Now() - creation_time_);
756 757
757 UpdateAccessibleName(); 758 UpdateAccessibleName();
758 AnimateInkDrop(views::InkDropState::ACTION_TRIGGERED); 759 AnimateInkDrop(views::InkDropState::ACTION_TRIGGERED, &event);
Evan Stade 2016/06/14 21:13:24 I'd just as soon move this out to the two OpenDown
bruthig 2016/06/14 21:57:01 Done.
759 760
760 // Calling download()->OpenDownload may delete this, so this must be 761 // Calling download()->OpenDownload may delete this, so this must be
761 // the last thing we do. 762 // the last thing we do.
762 download()->OpenDownload(); 763 download()->OpenDownload();
763 } 764 }
764 765
765 bool DownloadItemViewMd::SubmitDownloadToFeedbackService() { 766 bool DownloadItemViewMd::SubmitDownloadToFeedbackService() {
766 #if defined(FULL_SAFE_BROWSING) 767 #if defined(FULL_SAFE_BROWSING)
767 safe_browsing::SafeBrowsingService* sb_service = 768 safe_browsing::SafeBrowsingService* sb_service =
768 g_browser_process->safe_browsing_service(); 769 g_browser_process->safe_browsing_service();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 return; 849 return;
849 850
850 // Stop any completion animation. 851 // Stop any completion animation.
851 if (complete_animation_.get() && complete_animation_->is_animating()) 852 if (complete_animation_.get() && complete_animation_->is_animating())
852 complete_animation_->End(); 853 complete_animation_->End();
853 854
854 // Don't show the ripple for right clicks. 855 // Don't show the ripple for right clicks.
855 if (!active_event) 856 if (!active_event)
856 return; 857 return;
857 858
858 AnimateInkDrop(views::InkDropState::ACTION_PENDING); 859 AnimateInkDrop(views::InkDropState::ACTION_PENDING, &event);
859 } 860 }
860 861
861 void DownloadItemViewMd::HandleClickEvent(const ui::LocatedEvent& event, 862 void DownloadItemViewMd::HandleClickEvent(const ui::LocatedEvent& event,
862 bool active_event) { 863 bool active_event) {
863 // Mouse should not activate us in dangerous mode. 864 // Mouse should not activate us in dangerous mode.
864 if (mode_ == DANGEROUS_MODE) 865 if (mode_ == DANGEROUS_MODE)
865 return; 866 return;
866 867
867 if (!active_event || IsShowingWarningDialog()) 868 if (!active_event || IsShowingWarningDialog())
868 return; 869 return;
869 870
870 // OpenDownload may delete this, so don't add any code after this line. 871 // OpenDownload may delete this, so don't add any code after this line.
871 OpenDownload(); 872 OpenDownload(event);
872 } 873 }
873 874
874 void DownloadItemViewMd::SetDropdownState(State new_state) { 875 void DownloadItemViewMd::SetDropdownState(State new_state) {
875 // Avoid extra SchedulePaint()s if the state is going to be the same and 876 // Avoid extra SchedulePaint()s if the state is going to be the same and
876 // |dropdown_button_| has already been initialized. 877 // |dropdown_button_| has already been initialized.
877 if (dropdown_state_ == new_state && 878 if (dropdown_state_ == new_state &&
878 !dropdown_button_->GetImage(views::CustomButton::STATE_NORMAL).isNull()) 879 !dropdown_button_->GetImage(views::CustomButton::STATE_NORMAL).isNull())
879 return; 880 return;
880 881
881 dropdown_button_->SetIcon( 882 dropdown_button_->SetIcon(
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 SchedulePaint(); 1131 SchedulePaint();
1131 } 1132 }
1132 1133
1133 SkColor DownloadItemViewMd::GetTextColor() const { 1134 SkColor DownloadItemViewMd::GetTextColor() const {
1134 return GetTextColorForThemeProvider(GetThemeProvider()); 1135 return GetTextColorForThemeProvider(GetThemeProvider());
1135 } 1136 }
1136 1137
1137 SkColor DownloadItemViewMd::GetDimmedTextColor() const { 1138 SkColor DownloadItemViewMd::GetDimmedTextColor() const {
1138 return SkColorSetA(GetTextColor(), 0xC7); 1139 return SkColorSetA(GetTextColor(), 0xC7);
1139 } 1140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698