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