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 <list> | 7 #include <list> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 23 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
24 #include "ios/chrome/browser/chrome_url_constants.h" | 24 #include "ios/chrome/browser/chrome_url_constants.h" |
25 #import "ios/chrome/browser/chrome_url_util.h" | 25 #import "ios/chrome/browser/chrome_url_util.h" |
26 #import "ios/chrome/browser/metrics/tab_usage_recorder.h" | 26 #import "ios/chrome/browser/metrics/tab_usage_recorder.h" |
27 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" | 27 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" |
28 #import "ios/chrome/browser/sessions/session_service.h" | 28 #import "ios/chrome/browser/sessions/session_service.h" |
29 #import "ios/chrome/browser/sessions/session_window.h" | 29 #import "ios/chrome/browser/sessions/session_window.h" |
30 #import "ios/chrome/browser/snapshots/snapshot_cache.h" | 30 #import "ios/chrome/browser/snapshots/snapshot_cache.h" |
31 #include "ios/chrome/browser/tab_parenting_global_observer.h" | 31 #include "ios/chrome/browser/tab_parenting_global_observer.h" |
32 #import "ios/chrome/browser/tabs/tab.h" | 32 #import "ios/chrome/browser/tabs/tab.h" |
| 33 #import "ios/chrome/browser/tabs/tab_model_list.h" |
33 #import "ios/chrome/browser/tabs/tab_model_observer.h" | 34 #import "ios/chrome/browser/tabs/tab_model_observer.h" |
34 #import "ios/chrome/browser/tabs/tab_model_order_controller.h" | 35 #import "ios/chrome/browser/tabs/tab_model_order_controller.h" |
35 #import "ios/chrome/browser/tabs/tab_model_synced_window_delegate.h" | 36 #import "ios/chrome/browser/tabs/tab_model_synced_window_delegate.h" |
36 #import "ios/chrome/browser/xcallback_parameters.h" | 37 #import "ios/chrome/browser/xcallback_parameters.h" |
37 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" | 38 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" |
38 #import "ios/web/navigation/crw_session_controller.h" | 39 #import "ios/web/navigation/crw_session_controller.h" |
39 #include "ios/web/public/browser_state.h" | 40 #include "ios/web/public/browser_state.h" |
40 #include "ios/web/public/certificate_policy_cache.h" | 41 #include "ios/web/public/certificate_policy_cache.h" |
41 #include "ios/web/public/navigation_item.h" | 42 #include "ios/web/public/navigation_item.h" |
42 #import "ios/web/public/navigation_manager.h" | 43 #import "ios/web/public/navigation_manager.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // Register for background notification. | 293 // Register for background notification. |
293 [defaultCenter addObserver:self | 294 [defaultCenter addObserver:self |
294 selector:@selector(applicationDidEnterBackground:) | 295 selector:@selector(applicationDidEnterBackground:) |
295 name:UIApplicationDidEnterBackgroundNotification | 296 name:UIApplicationDidEnterBackgroundNotification |
296 object:nil]; | 297 object:nil]; |
297 // Register for foregrounding notification. | 298 // Register for foregrounding notification. |
298 [defaultCenter addObserver:self | 299 [defaultCenter addObserver:self |
299 selector:@selector(applicationWillEnterForeground:) | 300 selector:@selector(applicationWillEnterForeground:) |
300 name:UIApplicationWillEnterForegroundNotification | 301 name:UIApplicationWillEnterForegroundNotification |
301 object:nil]; | 302 object:nil]; |
| 303 |
| 304 // Associate with ios::ChromeBrowserState. |
| 305 RegisterTabModelWithChromeBrowserState(_browserState, self); |
302 } | 306 } |
303 return self; | 307 return self; |
304 } | 308 } |
305 | 309 |
306 - (instancetype)init { | 310 - (instancetype)init { |
307 NOTREACHED(); | 311 NOTREACHED(); |
308 return nil; | 312 return nil; |
309 } | 313 } |
310 | 314 |
311 - (BOOL)restoreSessionWindow:(SessionWindowIOS*)window { | 315 - (BOOL)restoreSessionWindow:(SessionWindowIOS*)window { |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 NSString* fileName = base::SysUTF8ToNSString(URL.ExtractFileName()); | 729 NSString* fileName = base::SysUTF8ToNSString(URL.ExtractFileName()); |
726 [referencedFiles addObject:fileName]; | 730 [referencedFiles addObject:fileName]; |
727 } | 731 } |
728 } | 732 } |
729 return referencedFiles; | 733 return referencedFiles; |
730 } | 734 } |
731 | 735 |
732 // NOTE: This can be called multiple times, so must be robust against that. | 736 // NOTE: This can be called multiple times, so must be robust against that. |
733 - (void)browserStateDestroyed { | 737 - (void)browserStateDestroyed { |
734 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 738 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 739 if (_browserState) { |
| 740 UnregisterTabModelFromChromeBrowserState(_browserState, self); |
| 741 } |
735 _browserState = nullptr; | 742 _browserState = nullptr; |
736 } | 743 } |
737 | 744 |
738 // Called when a tab is closing, but before its CRWWebController is destroyed. | 745 // Called when a tab is closing, but before its CRWWebController is destroyed. |
739 // Equivalent to DetachTabContentsAt() in Chrome's TabStripModel. | 746 // Equivalent to DetachTabContentsAt() in Chrome's TabStripModel. |
740 - (void)didCloseTab:(Tab*)closedTab { | 747 - (void)didCloseTab:(Tab*)closedTab { |
741 NSUInteger closedTabIndex = [_tabs indexOfObject:closedTab]; | 748 NSUInteger closedTabIndex = [_tabs indexOfObject:closedTab]; |
742 DCHECK(closedTab); | 749 DCHECK(closedTab); |
743 DCHECK(closedTabIndex != NSNotFound); | 750 DCHECK(closedTabIndex != NSNotFound); |
744 // Let the sessions::TabRestoreService know about that new tab. | 751 // Let the sessions::TabRestoreService know about that new tab. |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 web::NavigationManager::WebLoadParams params(URL); | 1065 web::NavigationManager::WebLoadParams params(URL); |
1059 params.referrer = referrer; | 1066 params.referrer = referrer; |
1060 params.transition_type = ui::PAGE_TRANSITION_TYPED; | 1067 params.transition_type = ui::PAGE_TRANSITION_TYPED; |
1061 [[tab webController] loadWithParams:params]; | 1068 [[tab webController] loadWithParams:params]; |
1062 [tab webController].webUsageEnabled = webUsageEnabled_; | 1069 [tab webController].webUsageEnabled = webUsageEnabled_; |
1063 [self insertTab:tab atIndex:index]; | 1070 [self insertTab:tab atIndex:index]; |
1064 return tab; | 1071 return tab; |
1065 } | 1072 } |
1066 | 1073 |
1067 @end | 1074 @end |
OLD | NEW |