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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); | 290 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); |
291 complete_animation_->SetTweenType(ui::Tween::LINEAR); | 291 complete_animation_->SetTweenType(ui::Tween::LINEAR); |
292 complete_animation_->Show(); | 292 complete_animation_->Show(); |
293 SchedulePaint(); | 293 SchedulePaint(); |
294 LoadIcon(); | 294 LoadIcon(); |
295 break; | 295 break; |
296 case DownloadItem::CANCELLED: | 296 case DownloadItem::CANCELLED: |
297 StopDownloadProgress(); | 297 StopDownloadProgress(); |
298 LoadIcon(); | 298 LoadIcon(); |
299 break; | 299 break; |
300 case DownloadItem::REMOVING: | |
301 parent_->RemoveDownloadView(this); // This will delete us! | |
302 return; | |
303 default: | 300 default: |
304 NOTREACHED(); | 301 NOTREACHED(); |
305 } | 302 } |
306 status_text_ = status_text; | 303 status_text_ = status_text; |
307 } | 304 } |
308 | 305 |
309 string16 new_tip = model_->GetTooltipText(font_, kTooltipMaxWidth); | 306 string16 new_tip = model_->GetTooltipText(font_, kTooltipMaxWidth); |
310 if (new_tip != tooltip_text_) { | 307 if (new_tip != tooltip_text_) { |
311 tooltip_text_ = new_tip; | 308 tooltip_text_ = new_tip; |
312 TooltipTextChanged(); | 309 TooltipTextChanged(); |
313 } | 310 } |
314 | 311 |
315 UpdateAccessibleName(); | 312 UpdateAccessibleName(); |
316 | 313 |
317 // We use the parent's (DownloadShelfView's) SchedulePaint, since there | 314 // We use the parent's (DownloadShelfView's) SchedulePaint, since there |
318 // are spaces between each DownloadItemView that the parent is responsible | 315 // are spaces between each DownloadItemView that the parent is responsible |
319 // for painting. | 316 // for painting. |
320 parent()->SchedulePaint(); | 317 parent()->SchedulePaint(); |
321 } | 318 } |
322 | 319 |
| 320 void DownloadItemView::OnDownloadDestroyed(DownloadItem* download) { |
| 321 parent_->RemoveDownloadView(this); // This will delete us! |
| 322 } |
| 323 |
323 void DownloadItemView::OnDownloadOpened(DownloadItem* download) { | 324 void DownloadItemView::OnDownloadOpened(DownloadItem* download) { |
324 disabled_while_opening_ = true; | 325 disabled_while_opening_ = true; |
325 SetEnabled(false); | 326 SetEnabled(false); |
326 MessageLoop::current()->PostDelayedTask( | 327 MessageLoop::current()->PostDelayedTask( |
327 FROM_HERE, | 328 FROM_HERE, |
328 base::Bind(&DownloadItemView::Reenable, | 329 base::Bind(&DownloadItemView::Reenable, |
329 weak_ptr_factory_.GetWeakPtr()), | 330 weak_ptr_factory_.GetWeakPtr()), |
330 base::TimeDelta::FromMilliseconds(kDisabledOnOpenDuration)); | 331 base::TimeDelta::FromMilliseconds(kDisabledOnOpenDuration)); |
331 | 332 |
332 // Notify our parent. | 333 // Notify our parent. |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 // Drop down button is glued to the left of the download shelf. | 1216 // Drop down button is glued to the left of the download shelf. |
1216 drop_down_x_left_ = 0; | 1217 drop_down_x_left_ = 0; |
1217 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); | 1218 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); |
1218 } else { | 1219 } else { |
1219 // Drop down button is glued to the right of the download shelf. | 1220 // Drop down button is glued to the right of the download shelf. |
1220 drop_down_x_left_ = | 1221 drop_down_x_left_ = |
1221 size.width() - normal_drop_down_image_set_.top->width(); | 1222 size.width() - normal_drop_down_image_set_.top->width(); |
1222 drop_down_x_right_ = size.width(); | 1223 drop_down_x_right_ = size.width(); |
1223 } | 1224 } |
1224 } | 1225 } |
OLD | NEW |