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

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: Renamed LocatedEvent::AsLocatedIfLocatedEvent() as FromIfValid(). 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 19 matching lines...) Expand all
442 } 443 }
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) {
453 AnimateInkDrop(views::InkDropState::ACTION_TRIGGERED, nullptr /* &event */);
452 // OpenDownload may delete this, so don't add any code after this line. 454 // OpenDownload may delete this, so don't add any code after this line.
453 OpenDownload(); 455 OpenDownload();
454 return true; 456 return true;
455 } 457 }
456 return false; 458 return false;
457 } 459 }
458 460
459 bool DownloadItemViewMd::GetTooltipText(const gfx::Point& p, 461 bool DownloadItemViewMd::GetTooltipText(const gfx::Point& p,
460 base::string16* tooltip) const { 462 base::string16* tooltip) const {
461 if (IsShowingWarningDialog()) { 463 if (IsShowingWarningDialog()) {
(...skipping 23 matching lines...) Expand all
485 void DownloadItemViewMd::AddInkDropLayer(ui::Layer* ink_drop_layer) { 487 void DownloadItemViewMd::AddInkDropLayer(ui::Layer* ink_drop_layer) {
486 InkDropHostView::AddInkDropLayer(ink_drop_layer); 488 InkDropHostView::AddInkDropLayer(ink_drop_layer);
487 // The layer that's added to host the ink drop layer must mask to bounds 489 // 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. 490 // so the hover effect is clipped while animating open.
489 layer()->SetMasksToBounds(true); 491 layer()->SetMasksToBounds(true);
490 } 492 }
491 493
492 std::unique_ptr<views::InkDropRipple> DownloadItemViewMd::CreateInkDropRipple() 494 std::unique_ptr<views::InkDropRipple> DownloadItemViewMd::CreateInkDropRipple()
493 const { 495 const {
494 return base::WrapUnique(new views::FloodFillInkDropRipple( 496 return base::WrapUnique(new views::FloodFillInkDropRipple(
495 GetLocalBounds(), GetLocalBounds().CenterPoint(), 497 GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(),
496 color_utils::DeriveDefaultIconColor(GetTextColor()))); 498 color_utils::DeriveDefaultIconColor(GetTextColor())));
497 } 499 }
498 500
499 std::unique_ptr<views::InkDropHighlight> 501 std::unique_ptr<views::InkDropHighlight>
500 DownloadItemViewMd::CreateInkDropHighlight() const { 502 DownloadItemViewMd::CreateInkDropHighlight() const {
501 if (IsShowingWarningDialog()) 503 if (IsShowingWarningDialog())
502 return nullptr; 504 return nullptr;
503 505
504 gfx::Size size = GetPreferredSize(); 506 gfx::Size size = GetPreferredSize();
505 return base::WrapUnique(new views::InkDropHighlight( 507 return base::WrapUnique(new views::InkDropHighlight(
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 } 750 }
749 751
750 void DownloadItemViewMd::OpenDownload() { 752 void DownloadItemViewMd::OpenDownload() {
751 DCHECK(!IsShowingWarningDialog()); 753 DCHECK(!IsShowingWarningDialog());
752 // We're interested in how long it takes users to open downloads. If they 754 // 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. 755 // open downloads super quickly, we should be concerned about clickjacking.
754 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", 756 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download",
755 base::Time::Now() - creation_time_); 757 base::Time::Now() - creation_time_);
756 758
757 UpdateAccessibleName(); 759 UpdateAccessibleName();
758 AnimateInkDrop(views::InkDropState::ACTION_TRIGGERED);
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
871 AnimateInkDrop(views::InkDropState::ACTION_TRIGGERED, &event);
872
870 // OpenDownload may delete this, so don't add any code after this line. 873 // OpenDownload may delete this, so don't add any code after this line.
871 OpenDownload(); 874 OpenDownload();
872 } 875 }
873 876
874 void DownloadItemViewMd::SetDropdownState(State new_state) { 877 void DownloadItemViewMd::SetDropdownState(State new_state) {
875 // Avoid extra SchedulePaint()s if the state is going to be the same and 878 // Avoid extra SchedulePaint()s if the state is going to be the same and
876 // |dropdown_button_| has already been initialized. 879 // |dropdown_button_| has already been initialized.
877 if (dropdown_state_ == new_state && 880 if (dropdown_state_ == new_state &&
878 !dropdown_button_->GetImage(views::CustomButton::STATE_NORMAL).isNull()) 881 !dropdown_button_->GetImage(views::CustomButton::STATE_NORMAL).isNull())
879 return; 882 return;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 SchedulePaint(); 1133 SchedulePaint();
1131 } 1134 }
1132 1135
1133 SkColor DownloadItemViewMd::GetTextColor() const { 1136 SkColor DownloadItemViewMd::GetTextColor() const {
1134 return GetTextColorForThemeProvider(GetThemeProvider()); 1137 return GetTextColorForThemeProvider(GetThemeProvider());
1135 } 1138 }
1136 1139
1137 SkColor DownloadItemViewMd::GetDimmedTextColor() const { 1140 SkColor DownloadItemViewMd::GetDimmedTextColor() const {
1138 return SkColorSetA(GetTextColor(), 0xC7); 1141 return SkColorSetA(GetTextColor(), 0xC7);
1139 } 1142 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc ('k') | chrome/browser/ui/views/location_bar/bubble_icon_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698