| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_ui_controller.h" | 5 #include "chrome/browser/download/download_ui_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 void DownloadShelfUIControllerDelegate::OnNewDownloadReady( | 82 void DownloadShelfUIControllerDelegate::OnNewDownloadReady( |
| 83 content::DownloadItem* item) { | 83 content::DownloadItem* item) { |
| 84 content::WebContents* web_contents = item->GetWebContents(); | 84 content::WebContents* web_contents = item->GetWebContents(); |
| 85 Browser* browser = | 85 Browser* browser = |
| 86 web_contents ? chrome::FindBrowserWithWebContents(web_contents) : NULL; | 86 web_contents ? chrome::FindBrowserWithWebContents(web_contents) : NULL; |
| 87 | 87 |
| 88 // As a last resort, use the last active browser for this profile. Not ideal, | 88 // As a last resort, use the last active browser for this profile. Not ideal, |
| 89 // but better than not showing the download at all. | 89 // but better than not showing the download at all. |
| 90 if (browser == NULL) { | 90 if (browser == nullptr) |
| 91 browser = chrome::FindLastActiveWithProfile(profile_, | 91 browser = chrome::FindLastActiveWithProfile(profile_); |
| 92 chrome::GetActiveDesktop()); | |
| 93 } | |
| 94 | 92 |
| 95 if (browser && browser->window() && | 93 if (browser && browser->window() && |
| 96 DownloadItemModel(item).ShouldShowInShelf()) { | 94 DownloadItemModel(item).ShouldShowInShelf()) { |
| 97 // GetDownloadShelf creates the download shelf if it was not yet created. | 95 // GetDownloadShelf creates the download shelf if it was not yet created. |
| 98 browser->window()->GetDownloadShelf()->AddDownload(item); | 96 browser->window()->GetDownloadShelf()->AddDownload(item); |
| 99 } | 97 } |
| 100 } | 98 } |
| 101 | 99 |
| 102 #endif // !OS_ANDROID | 100 #endif // !OS_ANDROID |
| 103 | 101 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 168 } |
| 171 } | 169 } |
| 172 #endif | 170 #endif |
| 173 | 171 |
| 174 if (item->GetState() == content::DownloadItem::CANCELLED) | 172 if (item->GetState() == content::DownloadItem::CANCELLED) |
| 175 return; | 173 return; |
| 176 | 174 |
| 177 DownloadItemModel(item).SetWasUINotified(true); | 175 DownloadItemModel(item).SetWasUINotified(true); |
| 178 delegate_->OnNewDownloadReady(item); | 176 delegate_->OnNewDownloadReady(item); |
| 179 } | 177 } |
| OLD | NEW |