| 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/download/download_shelf.h" | 5 #include "chrome/browser/download/download_shelf.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 DownloadShelf::~DownloadShelf() { | 38 DownloadShelf::~DownloadShelf() { |
| 39 } | 39 } |
| 40 | 40 |
| 41 void DownloadShelf::AddDownload(DownloadItem* download) { | 41 void DownloadShelf::AddDownload(DownloadItem* download) { |
| 42 DCHECK(download); | 42 DCHECK(download); |
| 43 if (DownloadItemModel(download).ShouldRemoveFromShelfWhenComplete()) { | 43 if (DownloadItemModel(download).ShouldRemoveFromShelfWhenComplete()) { |
| 44 // If we are going to remove the download from the shelf upon completion, | 44 // If we are going to remove the download from the shelf upon completion, |
| 45 // wait a few seconds to see if it completes quickly. If it's a small | 45 // wait a few seconds to see if it completes quickly. If it's a small |
| 46 // download, then the user won't have time to interact with it. | 46 // download, then the user won't have time to interact with it. |
| 47 MessageLoop::current()->PostDelayedTask( | 47 base::MessageLoop::current()->PostDelayedTask( |
| 48 FROM_HERE, | 48 FROM_HERE, |
| 49 base::Bind(&DownloadShelf::ShowDownloadById, | 49 base::Bind(&DownloadShelf::ShowDownloadById, |
| 50 weak_ptr_factory_.GetWeakPtr(), | 50 weak_ptr_factory_.GetWeakPtr(), |
| 51 download->GetId()), | 51 download->GetId()), |
| 52 GetTransientDownloadShowDelay()); | 52 GetTransientDownloadShowDelay()); |
| 53 } else { | 53 } else { |
| 54 ShowDownload(download); | 54 ShowDownload(download); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 content::DownloadManager* download_manager = GetDownloadManager(); | 135 content::DownloadManager* download_manager = GetDownloadManager(); |
| 136 if (!download_manager) | 136 if (!download_manager) |
| 137 return; | 137 return; |
| 138 | 138 |
| 139 DownloadItem* download = download_manager->GetDownload(download_id); | 139 DownloadItem* download = download_manager->GetDownload(download_id); |
| 140 if (!download) | 140 if (!download) |
| 141 return; | 141 return; |
| 142 | 142 |
| 143 ShowDownload(download); | 143 ShowDownload(download); |
| 144 } | 144 } |
| OLD | NEW |