Chromium Code Reviews| 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 #import "ios/chrome/browser/tabs/tab_model.h" | 5 #import "ios/chrome/browser/tabs/tab_model.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 if (_tabUsageRecorder) | 586 if (_tabUsageRecorder) |
| 587 _tabUsageRecorder->RecordPrimaryTabModelChange(primary, self.currentTab); | 587 _tabUsageRecorder->RecordPrimaryTabModelChange(primary, self.currentTab); |
| 588 } | 588 } |
| 589 | 589 |
| 590 - (NSSet*)currentlyReferencedExternalFiles { | 590 - (NSSet*)currentlyReferencedExternalFiles { |
| 591 NSMutableSet* referencedFiles = [NSMutableSet set]; | 591 NSMutableSet* referencedFiles = [NSMutableSet set]; |
| 592 if (!_browserState) | 592 if (!_browserState) |
| 593 return referencedFiles; | 593 return referencedFiles; |
| 594 // Check the currently open tabs for external files. | 594 // Check the currently open tabs for external files. |
| 595 for (Tab* tab in self) { | 595 for (Tab* tab in self) { |
| 596 if (UrlIsExternalFileReference(tab.url)) { | 596 const GURL& lastCommittedURL = tab.lastCommittedURL; |
| 597 NSString* fileName = base::SysUTF8ToNSString(tab.url.ExtractFileName()); | 597 if (UrlIsExternalFileReference(lastCommittedURL)) { |
| 598 [referencedFiles addObject:fileName]; | 598 [referencedFiles addObject:base::SysUTF8ToNSString( |
| 599 lastCommittedURL.ExtractFileName())]; | |
| 600 } | |
| 601 web::NavigationItem* pendingItem = | |
| 602 tab.webState->GetNavigationManager()->GetPendingItem(); | |
| 603 const GURL& pendingURL = | |
| 604 pendingItem ? pendingItem->GetURL() : GURL::EmptyGURL(); | |
| 605 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.
| |
| 606 [referencedFiles | |
| 607 addObject:base::SysUTF8ToNSString(pendingURL.ExtractFileName())]; | |
| 599 } | 608 } |
| 600 } | 609 } |
| 601 // Do the same for the recently closed tabs. | 610 // Do the same for the recently closed tabs. |
| 602 sessions::TabRestoreService* restoreService = | 611 sessions::TabRestoreService* restoreService = |
| 603 IOSChromeTabRestoreServiceFactory::GetForBrowserState(_browserState); | 612 IOSChromeTabRestoreServiceFactory::GetForBrowserState(_browserState); |
| 604 DCHECK(restoreService); | 613 DCHECK(restoreService); |
| 605 for (const auto& entry : restoreService->entries()) { | 614 for (const auto& entry : restoreService->entries()) { |
| 606 sessions::TabRestoreService::Tab* tab = | 615 sessions::TabRestoreService::Tab* tab = |
| 607 static_cast<sessions::TabRestoreService::Tab*>(entry.get()); | 616 static_cast<sessions::TabRestoreService::Tab*>(entry.get()); |
| 608 int navigationIndex = tab->current_navigation_index; | 617 int navigationIndex = tab->current_navigation_index; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 // Restore the CertificatePolicyCache (note that webState is invalid after | 750 // Restore the CertificatePolicyCache (note that webState is invalid after |
| 742 // passing it via move semantic to -initWithWebState:model:). | 751 // passing it via move semantic to -initWithWebState:model:). |
| 743 UpdateCertificatePolicyCacheFromWebState(policyCache, [tab webState]); | 752 UpdateCertificatePolicyCacheFromWebState(policyCache, [tab webState]); |
| 744 [restoredTabs addObject:tab]; | 753 [restoredTabs addObject:tab]; |
| 745 } | 754 } |
| 746 | 755 |
| 747 // If there was only one tab and it was the new tab page, clobber it. | 756 // If there was only one tab and it was the new tab page, clobber it. |
| 748 BOOL closedNTPTab = NO; | 757 BOOL closedNTPTab = NO; |
| 749 if (oldCount == 1) { | 758 if (oldCount == 1) { |
| 750 Tab* tab = [self tabAtIndex:0]; | 759 Tab* tab = [self tabAtIndex:0]; |
| 751 if (tab.url == GURL(kChromeUINewTabURL)) { | 760 BOOL hasPendingLoad = |
| 761 tab.webState->GetNavigationManager()->GetPendingItem() != nullptr; | |
| 762 if (!hasPendingLoad && tab.lastCommittedURL == GURL(kChromeUINewTabURL)) { | |
| 752 [self closeTab:tab]; | 763 [self closeTab:tab]; |
| 753 closedNTPTab = YES; | 764 closedNTPTab = YES; |
| 754 oldCount = 0; | 765 oldCount = 0; |
| 755 } | 766 } |
| 756 } | 767 } |
| 757 if (_tabUsageRecorder) | 768 if (_tabUsageRecorder) |
| 758 _tabUsageRecorder->InitialRestoredTabs(self.currentTab, restoredTabs); | 769 _tabUsageRecorder->InitialRestoredTabs(self.currentTab, restoredTabs); |
| 759 return closedNTPTab; | 770 return closedNTPTab; |
| 760 } | 771 } |
| 761 | 772 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 797 } | 808 } |
| 798 | 809 |
| 799 // Called when UIApplicationWillEnterForegroundNotification is received. | 810 // Called when UIApplicationWillEnterForegroundNotification is received. |
| 800 - (void)applicationWillEnterForeground:(NSNotification*)notify { | 811 - (void)applicationWillEnterForeground:(NSNotification*)notify { |
| 801 if (_tabUsageRecorder) { | 812 if (_tabUsageRecorder) { |
| 802 _tabUsageRecorder->AppWillEnterForeground(); | 813 _tabUsageRecorder->AppWillEnterForeground(); |
| 803 } | 814 } |
| 804 } | 815 } |
| 805 | 816 |
| 806 @end | 817 @end |
| OLD | NEW |