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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 gfx::Image* icon_bitmap) { | 247 gfx::Image* icon_bitmap) { |
248 if (icon_bitmap) | 248 if (icon_bitmap) |
249 parent()->SchedulePaint(); | 249 parent()->SchedulePaint(); |
250 } | 250 } |
251 | 251 |
252 // DownloadObserver interface. | 252 // DownloadObserver interface. |
253 | 253 |
254 // Update the progress graphic on the icon and our text status label | 254 // Update the progress graphic on the icon and our text status label |
255 // to reflect our current bytes downloaded, time remaining. | 255 // to reflect our current bytes downloaded, time remaining. |
256 void DownloadItemView::OnDownloadUpdated(DownloadItem* download) { | 256 void DownloadItemView::OnDownloadUpdated(DownloadItem* download) { |
257 DCHECK(download == download_); | 257 DCHECK_EQ(download_, download); |
258 | 258 |
259 if (IsShowingWarningDialog() && !model_->IsDangerous()) { | 259 if (IsShowingWarningDialog() && !model_->IsDangerous()) { |
260 // We have been approved. | 260 // We have been approved. |
261 ClearWarningDialog(); | 261 ClearWarningDialog(); |
262 } else if (!IsShowingWarningDialog() && model_->IsDangerous()) { | 262 } else if (!IsShowingWarningDialog() && model_->IsDangerous()) { |
263 ShowWarningDialog(); | 263 ShowWarningDialog(); |
264 // Force the shelf to layout again as our size has changed. | 264 // Force the shelf to layout again as our size has changed. |
265 parent_->Layout(); | 265 parent_->Layout(); |
266 SchedulePaint(); | 266 SchedulePaint(); |
267 } else { | 267 } else { |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 0, 0, bottom_image->width(), bottom_image->height(), | 985 0, 0, bottom_image->width(), bottom_image->height(), |
986 x, y, width, bottom_image->height(), false); | 986 x, y, width, bottom_image->height(), false); |
987 } | 987 } |
988 | 988 |
989 void DownloadItemView::SetState(State new_body_state, State new_drop_state) { | 989 void DownloadItemView::SetState(State new_body_state, State new_drop_state) { |
990 // If we are showing a warning dialog, we don't change body state. | 990 // If we are showing a warning dialog, we don't change body state. |
991 if (IsShowingWarningDialog()) { | 991 if (IsShowingWarningDialog()) { |
992 new_body_state = NORMAL; | 992 new_body_state = NORMAL; |
993 | 993 |
994 // Current body_state_ should always be NORMAL for warning dialogs. | 994 // Current body_state_ should always be NORMAL for warning dialogs. |
995 DCHECK(body_state_ == NORMAL); | 995 DCHECK_EQ(NORMAL, body_state_); |
996 // We shouldn't be calling SetState if we are in DANGEROUS_MODE. | 996 // We shouldn't be calling SetState if we are in DANGEROUS_MODE. |
997 DCHECK(mode_ != DANGEROUS_MODE); | 997 DCHECK_NE(DANGEROUS_MODE, mode_); |
998 } | 998 } |
999 // Avoid extra SchedulePaint()s if the state is going to be the same. | 999 // Avoid extra SchedulePaint()s if the state is going to be the same. |
1000 if (body_state_ == new_body_state && drop_down_state_ == new_drop_state) | 1000 if (body_state_ == new_body_state && drop_down_state_ == new_drop_state) |
1001 return; | 1001 return; |
1002 | 1002 |
1003 AnimateStateTransition(body_state_, new_body_state, | 1003 AnimateStateTransition(body_state_, new_body_state, |
1004 body_hover_animation_.get()); | 1004 body_hover_animation_.get()); |
1005 AnimateStateTransition(drop_down_state_, new_drop_state, | 1005 AnimateStateTransition(drop_down_state_, new_drop_state, |
1006 drop_hover_animation_.get()); | 1006 drop_hover_animation_.get()); |
1007 body_state_ = new_body_state; | 1007 body_state_ = new_body_state; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 void DownloadItemView::AnimateStateTransition(State from, State to, | 1226 void DownloadItemView::AnimateStateTransition(State from, State to, |
1227 ui::SlideAnimation* animation) { | 1227 ui::SlideAnimation* animation) { |
1228 if (from == NORMAL && to == HOT) { | 1228 if (from == NORMAL && to == HOT) { |
1229 animation->Show(); | 1229 animation->Show(); |
1230 } else if (from == HOT && to == NORMAL) { | 1230 } else if (from == HOT && to == NORMAL) { |
1231 animation->Hide(); | 1231 animation->Hide(); |
1232 } else if (from != to) { | 1232 } else if (from != to) { |
1233 animation->Reset((to == HOT) ? 1.0 : 0.0); | 1233 animation->Reset((to == HOT) ? 1.0 : 0.0); |
1234 } | 1234 } |
1235 } | 1235 } |
OLD | NEW |