Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: ios/chrome/browser/tabs/tab_model.mm

Issue 2823623002: Remove usage of Tab's |url| property from TabModel. (Closed)
Patch Set: test + formatting fixes Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/tabs/tab_model_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (pendingItem && UrlIsExternalFileReference(pendingItem->GetURL())) {
604 [referencedFiles addObject:base::SysUTF8ToNSString(
605 pendingItem->GetURL().ExtractFileName())];
599 } 606 }
600 } 607 }
601 // Do the same for the recently closed tabs. 608 // Do the same for the recently closed tabs.
602 sessions::TabRestoreService* restoreService = 609 sessions::TabRestoreService* restoreService =
603 IOSChromeTabRestoreServiceFactory::GetForBrowserState(_browserState); 610 IOSChromeTabRestoreServiceFactory::GetForBrowserState(_browserState);
604 DCHECK(restoreService); 611 DCHECK(restoreService);
605 for (const auto& entry : restoreService->entries()) { 612 for (const auto& entry : restoreService->entries()) {
606 sessions::TabRestoreService::Tab* tab = 613 sessions::TabRestoreService::Tab* tab =
607 static_cast<sessions::TabRestoreService::Tab*>(entry.get()); 614 static_cast<sessions::TabRestoreService::Tab*>(entry.get());
608 int navigationIndex = tab->current_navigation_index; 615 int navigationIndex = tab->current_navigation_index;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 // Restore the CertificatePolicyCache (note that webState is invalid after 748 // Restore the CertificatePolicyCache (note that webState is invalid after
742 // passing it via move semantic to -initWithWebState:model:). 749 // passing it via move semantic to -initWithWebState:model:).
743 UpdateCertificatePolicyCacheFromWebState(policyCache, [tab webState]); 750 UpdateCertificatePolicyCacheFromWebState(policyCache, [tab webState]);
744 [restoredTabs addObject:tab]; 751 [restoredTabs addObject:tab];
745 } 752 }
746 753
747 // If there was only one tab and it was the new tab page, clobber it. 754 // If there was only one tab and it was the new tab page, clobber it.
748 BOOL closedNTPTab = NO; 755 BOOL closedNTPTab = NO;
749 if (oldCount == 1) { 756 if (oldCount == 1) {
750 Tab* tab = [self tabAtIndex:0]; 757 Tab* tab = [self tabAtIndex:0];
751 if (tab.url == GURL(kChromeUINewTabURL)) { 758 BOOL hasPendingLoad =
759 tab.webState->GetNavigationManager()->GetPendingItem() != nullptr;
760 if (!hasPendingLoad && tab.lastCommittedURL == GURL(kChromeUINewTabURL)) {
752 [self closeTab:tab]; 761 [self closeTab:tab];
753 closedNTPTab = YES; 762 closedNTPTab = YES;
754 oldCount = 0; 763 oldCount = 0;
755 } 764 }
756 } 765 }
757 if (_tabUsageRecorder) 766 if (_tabUsageRecorder)
758 _tabUsageRecorder->InitialRestoredTabs(self.currentTab, restoredTabs); 767 _tabUsageRecorder->InitialRestoredTabs(self.currentTab, restoredTabs);
759 return closedNTPTab; 768 return closedNTPTab;
760 } 769 }
761 770
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 } 806 }
798 807
799 // Called when UIApplicationWillEnterForegroundNotification is received. 808 // Called when UIApplicationWillEnterForegroundNotification is received.
800 - (void)applicationWillEnterForeground:(NSNotification*)notify { 809 - (void)applicationWillEnterForeground:(NSNotification*)notify {
801 if (_tabUsageRecorder) { 810 if (_tabUsageRecorder) {
802 _tabUsageRecorder->AppWillEnterForeground(); 811 _tabUsageRecorder->AppWillEnterForeground();
803 } 812 }
804 } 813 }
805 814
806 @end 815 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/tabs/tab_model_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698