Chromium Code Reviews| Index: ios/chrome/browser/tabs/tab_model.mm |
| diff --git a/ios/chrome/browser/tabs/tab_model.mm b/ios/chrome/browser/tabs/tab_model.mm |
| index 193dd1f2225c928b458b6e721b8a817aa3b2a4f4..d6b6abb0dd47217e6383256764b3a44cb84cd1b7 100644 |
| --- a/ios/chrome/browser/tabs/tab_model.mm |
| +++ b/ios/chrome/browser/tabs/tab_model.mm |
| @@ -593,9 +593,18 @@ - (NSSet*)currentlyReferencedExternalFiles { |
| return referencedFiles; |
| // Check the currently open tabs for external files. |
| for (Tab* tab in self) { |
| - if (UrlIsExternalFileReference(tab.url)) { |
| - NSString* fileName = base::SysUTF8ToNSString(tab.url.ExtractFileName()); |
| - [referencedFiles addObject:fileName]; |
| + const GURL& lastCommittedURL = tab.lastCommittedURL; |
| + if (UrlIsExternalFileReference(lastCommittedURL)) { |
| + [referencedFiles addObject:base::SysUTF8ToNSString( |
| + lastCommittedURL.ExtractFileName())]; |
| + } |
| + web::NavigationItem* pendingItem = |
| + tab.webState->GetNavigationManager()->GetPendingItem(); |
| + const GURL& pendingURL = |
| + pendingItem ? pendingItem->GetURL() : GURL::EmptyGURL(); |
| + if (UrlIsExternalFileReference(pendingURL)) { |
|
Eugene But (OOO till 7-30)
2017/06/01 18:32:09
nit: How about |if (pendingItem && UrlIsExternalFi
kkhorimoto
2017/06/01 19:42:29
Done.
|
| + [referencedFiles |
| + addObject:base::SysUTF8ToNSString(pendingURL.ExtractFileName())]; |
| } |
| } |
| // Do the same for the recently closed tabs. |
| @@ -748,7 +757,9 @@ - (BOOL)restoreSessionWindow:(SessionWindowIOS*)window |
| BOOL closedNTPTab = NO; |
| if (oldCount == 1) { |
| Tab* tab = [self tabAtIndex:0]; |
| - if (tab.url == GURL(kChromeUINewTabURL)) { |
| + BOOL hasPendingLoad = |
| + tab.webState->GetNavigationManager()->GetPendingItem() != nullptr; |
| + if (!hasPendingLoad && tab.lastCommittedURL == GURL(kChromeUINewTabURL)) { |
| [self closeTab:tab]; |
| closedNTPTab = YES; |
| oldCount = 0; |