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 <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 } | 1027 } |
1028 // Post a task to release the button. When we call the Run method on the menu | 1028 // Post a task to release the button. When we call the Run method on the menu |
1029 // below, it runs an inner message loop that might cause us to be deleted. | 1029 // below, it runs an inner message loop that might cause us to be deleted. |
1030 // Posting a task with a WeakPtr lets us safely handle the button release. | 1030 // Posting a task with a WeakPtr lets us safely handle the button release. |
1031 base::MessageLoop::current()->PostNonNestableTask( | 1031 base::MessageLoop::current()->PostNonNestableTask( |
1032 FROM_HERE, | 1032 FROM_HERE, |
1033 base::Bind(&DownloadItemView::ReleaseDropDown, | 1033 base::Bind(&DownloadItemView::ReleaseDropDown, |
1034 weak_ptr_factory_.GetWeakPtr())); | 1034 weak_ptr_factory_.GetWeakPtr())); |
1035 views::View::ConvertPointToScreen(this, &point); | 1035 views::View::ConvertPointToScreen(this, &point); |
1036 | 1036 |
1037 if (!context_menu_.get()) { | 1037 if (!context_menu_.get()) |
1038 context_menu_.reset( | 1038 context_menu_.reset(new DownloadShelfContextMenuView(download())); |
1039 new DownloadShelfContextMenuView(download(), shelf_->GetNavigator())); | 1039 |
1040 } | |
1041 context_menu_->Run(GetWidget()->GetTopLevelWidget(), | 1040 context_menu_->Run(GetWidget()->GetTopLevelWidget(), |
1042 gfx::Rect(point, size), source_type); | 1041 gfx::Rect(point, size), source_type); |
1043 // We could be deleted now. | 1042 // We could be deleted now. |
1044 } | 1043 } |
1045 | 1044 |
1046 void DownloadItemView::HandlePressEvent(const ui::LocatedEvent& event, | 1045 void DownloadItemView::HandlePressEvent(const ui::LocatedEvent& event, |
1047 bool active_event) { | 1046 bool active_event) { |
1048 // The event should not activate us in dangerous mode. | 1047 // The event should not activate us in dangerous mode. |
1049 if (mode_ == DANGEROUS_MODE) | 1048 if (mode_ == DANGEROUS_MODE) |
1050 return; | 1049 return; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 void DownloadItemView::AnimateStateTransition(State from, State to, | 1396 void DownloadItemView::AnimateStateTransition(State from, State to, |
1398 gfx::SlideAnimation* animation) { | 1397 gfx::SlideAnimation* animation) { |
1399 if (from == NORMAL && to == HOT) { | 1398 if (from == NORMAL && to == HOT) { |
1400 animation->Show(); | 1399 animation->Show(); |
1401 } else if (from == HOT && to == NORMAL) { | 1400 } else if (from == HOT && to == NORMAL) { |
1402 animation->Hide(); | 1401 animation->Hide(); |
1403 } else if (from != to) { | 1402 } else if (from != to) { |
1404 animation->Reset((to == HOT) ? 1.0 : 0.0); | 1403 animation->Reset((to == HOT) ? 1.0 : 0.0); |
1405 } | 1404 } |
1406 } | 1405 } |
OLD | NEW |