OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 void Browser::ShowFirstRunBubble() { | 1297 void Browser::ShowFirstRunBubble() { |
1298 window()->GetLocationBar()->ShowFirstRunBubble(); | 1298 window()->GetLocationBar()->ShowFirstRunBubble(); |
1299 } | 1299 } |
1300 | 1300 |
1301 void Browser::ShowDownload(content::DownloadItem* download) { | 1301 void Browser::ShowDownload(content::DownloadItem* download) { |
1302 if (!window()) | 1302 if (!window()) |
1303 return; | 1303 return; |
1304 | 1304 |
1305 // If the download occurs in a new tab, and it's not a save page | 1305 // If the download occurs in a new tab, and it's not a save page |
1306 // download (started before initial navigation completed) close it. | 1306 // download (started before initial navigation completed) close it. |
| 1307 // Avoid calling CloseContents if the tab is not in this browser's tab strip |
| 1308 // model; this can happen if the download was initiated by something internal |
| 1309 // to Chrome, such as by the app list. |
1307 WebContents* source = download->GetWebContents(); | 1310 WebContents* source = download->GetWebContents(); |
1308 if (source && source->GetController().IsInitialNavigation() && | 1311 if (source && source->GetController().IsInitialNavigation() && |
1309 tab_strip_model_->count() > 1 && !download->IsSavePackageDownload()) { | 1312 tab_strip_model_->count() > 1 && |
| 1313 tab_strip_model_->GetIndexOfWebContents(source) != |
| 1314 TabStripModel::kNoTab && |
| 1315 !download->IsSavePackageDownload()) { |
1310 CloseContents(source); | 1316 CloseContents(source); |
1311 } | 1317 } |
1312 | 1318 |
1313 // Some (app downloads) are not supposed to appear on the shelf. | 1319 // Some (app downloads) are not supposed to appear on the shelf. |
1314 if (!DownloadItemModel(download).ShouldShowInShelf()) | 1320 if (!DownloadItemModel(download).ShouldShowInShelf()) |
1315 return; | 1321 return; |
1316 | 1322 |
1317 // GetDownloadShelf creates the download shelf if it was not yet created. | 1323 // GetDownloadShelf creates the download shelf if it was not yet created. |
1318 DownloadShelf* shelf = window()->GetDownloadShelf(); | 1324 DownloadShelf* shelf = window()->GetDownloadShelf(); |
1319 shelf->AddDownload(download); | 1325 shelf->AddDownload(download); |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2495 if (contents && !allow_js_access) { | 2501 if (contents && !allow_js_access) { |
2496 contents->web_contents()->GetController().LoadURL( | 2502 contents->web_contents()->GetController().LoadURL( |
2497 target_url, | 2503 target_url, |
2498 content::Referrer(), | 2504 content::Referrer(), |
2499 ui::PAGE_TRANSITION_LINK, | 2505 ui::PAGE_TRANSITION_LINK, |
2500 std::string()); // No extra headers. | 2506 std::string()); // No extra headers. |
2501 } | 2507 } |
2502 | 2508 |
2503 return contents != NULL; | 2509 return contents != NULL; |
2504 } | 2510 } |
OLD | NEW |