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