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

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: check pending URLs 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 | no next file » | 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 web::NavigationItem* pendingItem =
598 tab.webState->GetNavigationManager()->GetPendingItem();
599 const GURL& pendingURL =
600 pendingItem ? pendingItem->GetURL() : GURL::EmptyGURL();
601 if (UrlIsExternalFileReference(lastCommittedURL) ||
602 UrlIsExternalFileReference(pendingURL)) {
603 NSString* fileName = base::SysUTF8ToNSString(URL.ExtractFileName());
Eugene But (OOO till 7-30) 2017/05/31 22:43:11 Does it compile? I can't fine |URL| variable.
kkhorimoto 2017/06/01 17:55:33 Whoop, I think I accidentally reverted or somethin
598 [referencedFiles addObject:fileName]; 604 [referencedFiles addObject:fileName];
599 } 605 }
600 } 606 }
601 // Do the same for the recently closed tabs. 607 // Do the same for the recently closed tabs.
602 sessions::TabRestoreService* restoreService = 608 sessions::TabRestoreService* restoreService =
603 IOSChromeTabRestoreServiceFactory::GetForBrowserState(_browserState); 609 IOSChromeTabRestoreServiceFactory::GetForBrowserState(_browserState);
604 DCHECK(restoreService); 610 DCHECK(restoreService);
605 for (const auto& entry : restoreService->entries()) { 611 for (const auto& entry : restoreService->entries()) {
606 sessions::TabRestoreService::Tab* tab = 612 sessions::TabRestoreService::Tab* tab =
607 static_cast<sessions::TabRestoreService::Tab*>(entry.get()); 613 static_cast<sessions::TabRestoreService::Tab*>(entry.get());
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 // Restore the CertificatePolicyCache (note that webState is invalid after 747 // Restore the CertificatePolicyCache (note that webState is invalid after
742 // passing it via move semantic to -initWithWebState:model:). 748 // passing it via move semantic to -initWithWebState:model:).
743 UpdateCertificatePolicyCacheFromWebState(policyCache, [tab webState]); 749 UpdateCertificatePolicyCacheFromWebState(policyCache, [tab webState]);
744 [restoredTabs addObject:tab]; 750 [restoredTabs addObject:tab];
745 } 751 }
746 752
747 // If there was only one tab and it was the new tab page, clobber it. 753 // If there was only one tab and it was the new tab page, clobber it.
748 BOOL closedNTPTab = NO; 754 BOOL closedNTPTab = NO;
749 if (oldCount == 1) { 755 if (oldCount == 1) {
750 Tab* tab = [self tabAtIndex:0]; 756 Tab* tab = [self tabAtIndex:0];
751 if (tab.url == GURL(kChromeUINewTabURL)) { 757 BOOL hasPendingLoad =
758 tab.webState->GetNavigationManager()->GetPendingItem() != nullptr;
759 if (!hasPendingLoad && tab.lastCommittedURL == GURL(kChromeUINewTabURL)) {
752 [self closeTab:tab]; 760 [self closeTab:tab];
753 closedNTPTab = YES; 761 closedNTPTab = YES;
754 oldCount = 0; 762 oldCount = 0;
755 } 763 }
756 } 764 }
757 if (_tabUsageRecorder) 765 if (_tabUsageRecorder)
758 _tabUsageRecorder->InitialRestoredTabs(self.currentTab, restoredTabs); 766 _tabUsageRecorder->InitialRestoredTabs(self.currentTab, restoredTabs);
759 return closedNTPTab; 767 return closedNTPTab;
760 } 768 }
761 769
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 } 805 }
798 806
799 // Called when UIApplicationWillEnterForegroundNotification is received. 807 // Called when UIApplicationWillEnterForegroundNotification is received.
800 - (void)applicationWillEnterForeground:(NSNotification*)notify { 808 - (void)applicationWillEnterForeground:(NSNotification*)notify {
801 if (_tabUsageRecorder) { 809 if (_tabUsageRecorder) {
802 _tabUsageRecorder->AppWillEnterForeground(); 810 _tabUsageRecorder->AppWillEnterForeground();
803 } 811 }
804 } 812 }
805 813
806 @end 814 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698