| 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.h" | 5 #include "chrome/browser/ui/views/download/download_item_view.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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 model_(download_item), | 166 model_(download_item), |
| 167 save_button_(nullptr), | 167 save_button_(nullptr), |
| 168 discard_button_(nullptr), | 168 discard_button_(nullptr), |
| 169 dropdown_button_(views::CreateVectorImageButton(this)), | 169 dropdown_button_(views::CreateVectorImageButton(this)), |
| 170 dangerous_download_label_(nullptr), | 170 dangerous_download_label_(nullptr), |
| 171 dangerous_download_label_sized_(false), | 171 dangerous_download_label_sized_(false), |
| 172 disabled_while_opening_(false), | 172 disabled_while_opening_(false), |
| 173 creation_time_(base::Time::Now()), | 173 creation_time_(base::Time::Now()), |
| 174 time_download_warning_shown_(base::Time()), | 174 time_download_warning_shown_(base::Time()), |
| 175 weak_ptr_factory_(this) { | 175 weak_ptr_factory_(this) { |
| 176 SetInkDropMode(InkDropMode::ON); | 176 SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
| 177 DCHECK(download()); | 177 DCHECK(download()); |
| 178 download()->AddObserver(this); | 178 download()->AddObserver(this); |
| 179 set_context_menu_controller(this); | 179 set_context_menu_controller(this); |
| 180 | 180 |
| 181 dropdown_button_->SetBorder( | 181 dropdown_button_->SetBorder( |
| 182 views::CreateEmptyBorder(gfx::Insets(kDropdownBorderWidth))); | 182 views::CreateEmptyBorder(gfx::Insets(kDropdownBorderWidth))); |
| 183 AddChildView(dropdown_button_); | 183 AddChildView(dropdown_button_); |
| 184 | 184 |
| 185 LoadIcon(); | 185 LoadIcon(); |
| 186 | 186 |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 // We're about to show the menu from a mouse press. By showing from the | 830 // We're about to show the menu from a mouse press. By showing from the |
| 831 // mouse press event we block RootView in mouse dispatching. This also | 831 // mouse press event we block RootView in mouse dispatching. This also |
| 832 // appears to cause RootView to get a mouse pressed BEFORE the mouse | 832 // appears to cause RootView to get a mouse pressed BEFORE the mouse |
| 833 // release is seen, which means RootView sends us another mouse press no | 833 // release is seen, which means RootView sends us another mouse press no |
| 834 // matter where the user pressed. To force RootView to recalculate the | 834 // matter where the user pressed. To force RootView to recalculate the |
| 835 // mouse target during the mouse press we explicitly set the mouse handler | 835 // mouse target during the mouse press we explicitly set the mouse handler |
| 836 // to null. | 836 // to null. |
| 837 static_cast<views::internal::RootView*>(GetWidget()->GetRootView()) | 837 static_cast<views::internal::RootView*>(GetWidget()->GetRootView()) |
| 838 ->SetMouseHandler(nullptr); | 838 ->SetMouseHandler(nullptr); |
| 839 | 839 |
| 840 AnimateInkDrop(views::InkDropState::HIDDEN, nullptr); |
| 841 |
| 840 if (!context_menu_.get()) | 842 if (!context_menu_.get()) |
| 841 context_menu_.reset(new DownloadShelfContextMenuView(this)); | 843 context_menu_.reset(new DownloadShelfContextMenuView(this)); |
| 842 context_menu_->Run(GetWidget()->GetTopLevelWidget(), rect, source_type, | 844 context_menu_->Run(GetWidget()->GetTopLevelWidget(), rect, source_type, |
| 843 base::Bind(&DownloadItemView::ReleaseDropdown, | 845 base::Bind(&DownloadItemView::ReleaseDropdown, |
| 844 weak_ptr_factory_.GetWeakPtr())); | 846 weak_ptr_factory_.GetWeakPtr())); |
| 845 } | 847 } |
| 846 | 848 |
| 847 void DownloadItemView::HandlePressEvent(const ui::LocatedEvent& event, | 849 void DownloadItemView::HandlePressEvent(const ui::LocatedEvent& event, |
| 848 bool active_event) { | 850 bool active_event) { |
| 849 // The event should not activate us in dangerous/malicious mode. | 851 // The event should not activate us in dangerous/malicious mode. |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 SchedulePaint(); | 1123 SchedulePaint(); |
| 1122 } | 1124 } |
| 1123 | 1125 |
| 1124 SkColor DownloadItemView::GetTextColor() const { | 1126 SkColor DownloadItemView::GetTextColor() const { |
| 1125 return GetTextColorForThemeProvider(GetThemeProvider()); | 1127 return GetTextColorForThemeProvider(GetThemeProvider()); |
| 1126 } | 1128 } |
| 1127 | 1129 |
| 1128 SkColor DownloadItemView::GetDimmedTextColor() const { | 1130 SkColor DownloadItemView::GetDimmedTextColor() const { |
| 1129 return SkColorSetA(GetTextColor(), 0xC7); | 1131 return SkColorSetA(GetTextColor(), 0xC7); |
| 1130 } | 1132 } |
| OLD | NEW |