| 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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 weak_ptr_factory_.GetWeakPtr())); | 838 weak_ptr_factory_.GetWeakPtr())); |
| 839 | 839 |
| 840 if (!context_menu_.get()) | 840 if (!context_menu_.get()) |
| 841 context_menu_.reset(new DownloadShelfContextMenuView(download())); | 841 context_menu_.reset(new DownloadShelfContextMenuView(download())); |
| 842 context_menu_->Run(GetWidget()->GetTopLevelWidget(), rect, source_type); | 842 context_menu_->Run(GetWidget()->GetTopLevelWidget(), rect, source_type); |
| 843 // We could be deleted now. | 843 // We could be deleted now. |
| 844 } | 844 } |
| 845 | 845 |
| 846 void DownloadItemViewMd::HandlePressEvent(const ui::LocatedEvent& event, | 846 void DownloadItemViewMd::HandlePressEvent(const ui::LocatedEvent& event, |
| 847 bool active_event) { | 847 bool active_event) { |
| 848 // The event should not activate us in dangerous mode. | 848 // The event should not activate us in dangerous/malicious mode. |
| 849 if (mode_ == DANGEROUS_MODE) | 849 if (IsShowingWarningDialog()) |
| 850 return; | 850 return; |
| 851 | 851 |
| 852 // Stop any completion animation. | 852 // Stop any completion animation. |
| 853 if (complete_animation_.get() && complete_animation_->is_animating()) | 853 if (complete_animation_.get() && complete_animation_->is_animating()) |
| 854 complete_animation_->End(); | 854 complete_animation_->End(); |
| 855 | 855 |
| 856 // Don't show the ripple for right clicks. | 856 // Don't show the ripple for right clicks. |
| 857 if (!active_event) | 857 if (!active_event) |
| 858 return; | 858 return; |
| 859 | 859 |
| 860 AnimateInkDrop(views::InkDropState::ACTION_PENDING, &event); | 860 AnimateInkDrop(views::InkDropState::ACTION_PENDING, &event); |
| 861 } | 861 } |
| 862 | 862 |
| 863 void DownloadItemViewMd::HandleClickEvent(const ui::LocatedEvent& event, | 863 void DownloadItemViewMd::HandleClickEvent(const ui::LocatedEvent& event, |
| 864 bool active_event) { | 864 bool active_event) { |
| 865 // Mouse should not activate us in dangerous mode. | 865 // The event should not activate us in dangerous/malicious mode. |
| 866 if (mode_ == DANGEROUS_MODE) | |
| 867 return; | |
| 868 | |
| 869 if (!active_event || IsShowingWarningDialog()) | 866 if (!active_event || IsShowingWarningDialog()) |
| 870 return; | 867 return; |
| 871 | 868 |
| 872 AnimateInkDrop(views::InkDropState::ACTION_TRIGGERED, &event); | 869 AnimateInkDrop(views::InkDropState::ACTION_TRIGGERED, &event); |
| 873 | 870 |
| 874 // 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. |
| 875 OpenDownload(); | 872 OpenDownload(); |
| 876 } | 873 } |
| 877 | 874 |
| 878 void DownloadItemViewMd::SetDropdownState(State new_state) { | 875 void DownloadItemViewMd::SetDropdownState(State new_state) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 906 LoadIcon(); | 903 LoadIcon(); |
| 907 | 904 |
| 908 // Force the shelf to layout again as our size has changed. | 905 // Force the shelf to layout again as our size has changed. |
| 909 shelf_->Layout(); | 906 shelf_->Layout(); |
| 910 shelf_->SchedulePaint(); | 907 shelf_->SchedulePaint(); |
| 911 } | 908 } |
| 912 | 909 |
| 913 void DownloadItemViewMd::ClearWarningDialog() { | 910 void DownloadItemViewMd::ClearWarningDialog() { |
| 914 DCHECK(download()->GetDangerType() == | 911 DCHECK(download()->GetDangerType() == |
| 915 content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED); | 912 content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED); |
| 916 DCHECK(mode_ == DANGEROUS_MODE || mode_ == MALICIOUS_MODE); | 913 DCHECK(IsShowingWarningDialog()); |
| 917 | 914 |
| 918 mode_ = NORMAL_MODE; | 915 mode_ = NORMAL_MODE; |
| 919 dropdown_state_ = NORMAL; | 916 dropdown_state_ = NORMAL; |
| 920 | 917 |
| 921 // ExperienceSampling: User proceeded through the warning. | 918 // ExperienceSampling: User proceeded through the warning. |
| 922 if (sampling_event_.get()) { | 919 if (sampling_event_.get()) { |
| 923 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); | 920 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); |
| 924 sampling_event_.reset(NULL); | 921 sampling_event_.reset(NULL); |
| 925 } | 922 } |
| 926 // Remove the views used by the warning dialog. | 923 // Remove the views used by the warning dialog. |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 SchedulePaint(); | 1131 SchedulePaint(); |
| 1135 } | 1132 } |
| 1136 | 1133 |
| 1137 SkColor DownloadItemViewMd::GetTextColor() const { | 1134 SkColor DownloadItemViewMd::GetTextColor() const { |
| 1138 return GetTextColorForThemeProvider(GetThemeProvider()); | 1135 return GetTextColorForThemeProvider(GetThemeProvider()); |
| 1139 } | 1136 } |
| 1140 | 1137 |
| 1141 SkColor DownloadItemViewMd::GetDimmedTextColor() const { | 1138 SkColor DownloadItemViewMd::GetDimmedTextColor() const { |
| 1142 return SkColorSetA(GetTextColor(), 0xC7); | 1139 return SkColorSetA(GetTextColor(), 0xC7); |
| 1143 } | 1140 } |
| OLD | NEW |