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

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

Issue 2807063006: [ios] Reduce access to private //ios/web API. (Closed)
Patch Set: Call -recordStateInHistory in CRWWebController -wasHidden.' Created 3 years, 8 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
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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 for (Tab* tab in self) { 685 for (Tab* tab in self) {
686 if ([tab.webController isViewAlive]) 686 if ([tab.webController isViewAlive])
687 count++; 687 count++;
688 } 688 }
689 return count; 689 return count;
690 } 690 }
691 691
692 #pragma mark - Private methods 692 #pragma mark - Private methods
693 693
694 - (SessionIOS*)sessionForSaving { 694 - (SessionIOS*)sessionForSaving {
695 // Background tabs will already have their state preserved, but not the
696 // fg tab. Do it now.
697 [self.currentTab recordStateInHistory];
698
699 // Build the array of sessions. Copy the session objects as the saving will 695 // Build the array of sessions. Copy the session objects as the saving will
700 // be done on a separate thread. 696 // be done on a separate thread.
701 // TODO(crbug.com/661986): This could get expensive especially since this 697 // TODO(crbug.com/661986): This could get expensive especially since this
702 // window may never be saved (if another call comes in before the delay). 698 // window may never be saved (if another call comes in before the delay).
703 return [[SessionIOS alloc] 699 return [[SessionIOS alloc]
704 initWithWindows:@[ SerializeWebStateList(_webStateList.get()) ]]; 700 initWithWindows:@[ SerializeWebStateList(_webStateList.get()) ]];
705 } 701 }
706 702
707 - (void)postNotificationName:(NSString*)notificationName withTab:(Tab*)tab { 703 - (void)postNotificationName:(NSString*)notificationName withTab:(Tab*)tab {
708 // A scoped_nsobject is used rather than an NSDictionary with static 704 // A scoped_nsobject is used rather than an NSDictionary with static
(...skipping 11 matching lines...) Expand all
720 persistState:(BOOL)persistState { 716 persistState:(BOOL)persistState {
721 DCHECK(_browserState); 717 DCHECK(_browserState);
722 DCHECK(window); 718 DCHECK(window);
723 719
724 if (!window.sessions.count) 720 if (!window.sessions.count)
725 return NO; 721 return NO;
726 722
727 int oldCount = _webStateList->count(); 723 int oldCount = _webStateList->count();
728 DCHECK_GE(oldCount, 0); 724 DCHECK_GE(oldCount, 0);
729 725
730 if (persistState && self.currentTab)
731 [self.currentTab recordStateInHistory];
732
733 web::WebState::CreateParams createParams(_browserState); 726 web::WebState::CreateParams createParams(_browserState);
734 DeserializeWebStateList( 727 DeserializeWebStateList(
735 _webStateList.get(), window, 728 _webStateList.get(), window,
736 base::BindRepeating(&web::WebState::CreateWithStorageSession, 729 base::BindRepeating(&web::WebState::CreateWithStorageSession,
737 createParams)); 730 createParams));
738 731
739 DCHECK_GT(_webStateList->count(), oldCount); 732 DCHECK_GT(_webStateList->count(), oldCount);
740 int restoredCount = _webStateList->count() - oldCount; 733 int restoredCount = _webStateList->count() - oldCount;
741 DCHECK_EQ(window.sessions.count, static_cast<NSUInteger>(restoredCount)); 734 DCHECK_EQ(window.sessions.count, static_cast<NSUInteger>(restoredCount));
742 735
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 } 805 }
813 806
814 // Called when UIApplicationWillEnterForegroundNotification is received. 807 // Called when UIApplicationWillEnterForegroundNotification is received.
815 - (void)applicationWillEnterForeground:(NSNotification*)notify { 808 - (void)applicationWillEnterForeground:(NSNotification*)notify {
816 if (_tabUsageRecorder) { 809 if (_tabUsageRecorder) {
817 _tabUsageRecorder->AppWillEnterForeground(); 810 _tabUsageRecorder->AppWillEnterForeground();
818 } 811 }
819 } 812 }
820 813
821 @end 814 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab.mm ('k') | ios/chrome/browser/tabs/tab_model_selected_tab_observer.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698