| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/main/browser_view_wrangler.h" | 5 #import "ios/chrome/browser/ui/main/browser_view_wrangler.h" |
| 6 | 6 |
| 7 #include "base/mac/objc_property_releaser.h" | 7 #include "base/mac/objc_release_properties.h" |
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #include "ios/chrome/browser/application_context.h" | 9 #include "ios/chrome/browser/application_context.h" |
| 10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 11 #import "ios/chrome/browser/browsing_data/browsing_data_removal_controller.h" | 11 #import "ios/chrome/browser/browsing_data/browsing_data_removal_controller.h" |
| 12 #include "ios/chrome/browser/browsing_data/ios_chrome_browsing_data_remover.h" | 12 #include "ios/chrome/browser/browsing_data/ios_chrome_browsing_data_remover.h" |
| 13 #include "ios/chrome/browser/crash_report/crash_report_helper.h" | 13 #include "ios/chrome/browser/crash_report/crash_report_helper.h" |
| 14 #import "ios/chrome/browser/device_sharing/device_sharing_manager.h" | 14 #import "ios/chrome/browser/device_sharing/device_sharing_manager.h" |
| 15 #import "ios/chrome/browser/physical_web/start_physical_web_discovery.h" | 15 #import "ios/chrome/browser/physical_web/start_physical_web_discovery.h" |
| 16 #import "ios/chrome/browser/sessions/session_service.h" | 16 #import "ios/chrome/browser/sessions/session_service.h" |
| 17 #import "ios/chrome/browser/sessions/session_window.h" | 17 #import "ios/chrome/browser/sessions/session_window.h" |
| 18 #import "ios/chrome/browser/tabs/tab.h" | 18 #import "ios/chrome/browser/tabs/tab.h" |
| 19 #import "ios/chrome/browser/tabs/tab_model.h" | 19 #import "ios/chrome/browser/tabs/tab_model.h" |
| 20 #import "ios/chrome/browser/tabs/tab_model_observer.h" | 20 #import "ios/chrome/browser/tabs/tab_model_observer.h" |
| 21 #import "ios/chrome/browser/ui/browser_view_controller.h" | 21 #import "ios/chrome/browser/ui/browser_view_controller.h" |
| 22 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" | 22 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" |
| 23 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 23 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 24 | 24 |
| 25 @interface BrowserViewWrangler ()<TabModelObserver> { | 25 @interface BrowserViewWrangler ()<TabModelObserver> { |
| 26 ios::ChromeBrowserState* _browserState; | 26 ios::ChromeBrowserState* _browserState; |
| 27 __unsafe_unretained id<TabModelObserver> _tabModelObserver; | 27 __unsafe_unretained id<TabModelObserver> _tabModelObserver; |
| 28 | |
| 29 base::mac::ObjCPropertyReleaser _propertyReleaser_BrowserViewWrangler; | |
| 30 } | 28 } |
| 31 | 29 |
| 32 // Responsible for maintaining all state related to sharing to other devices. | 30 // Responsible for maintaining all state related to sharing to other devices. |
| 33 // Redeclared readwrite from the readonly declaration in the Testing interface. | 31 // Redeclared readwrite from the readonly declaration in the Testing interface. |
| 34 @property(nonatomic, retain, readwrite) | 32 @property(nonatomic, retain, readwrite) |
| 35 DeviceSharingManager* deviceSharingManager; | 33 DeviceSharingManager* deviceSharingManager; |
| 36 | 34 |
| 37 // Creates a new autoreleased tab model for |browserState|; if |empty| is NO, | 35 // Creates a new autoreleased tab model for |browserState|; if |empty| is NO, |
| 38 // then any existing tabs that have been saved for |browserState| will be | 36 // then any existing tabs that have been saved for |browserState| will be |
| 39 // loaded; otherwise, the tab model will be created empty. | 37 // loaded; otherwise, the tab model will be created empty. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 59 @synthesize mainTabModel = _mainTabModel; | 57 @synthesize mainTabModel = _mainTabModel; |
| 60 @synthesize otrBVC = _otrBVC; | 58 @synthesize otrBVC = _otrBVC; |
| 61 @synthesize otrTabModel = _otrTabModel; | 59 @synthesize otrTabModel = _otrTabModel; |
| 62 @synthesize currentBVC = _currentBVC; | 60 @synthesize currentBVC = _currentBVC; |
| 63 // Private properies. | 61 // Private properies. |
| 64 @synthesize deviceSharingManager = _deviceSharingManager; | 62 @synthesize deviceSharingManager = _deviceSharingManager; |
| 65 | 63 |
| 66 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState | 64 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState |
| 67 tabModelObserver:(id<TabModelObserver>)tabModelObserver { | 65 tabModelObserver:(id<TabModelObserver>)tabModelObserver { |
| 68 if ((self = [super init])) { | 66 if ((self = [super init])) { |
| 69 _propertyReleaser_BrowserViewWrangler.Init(self, | |
| 70 [BrowserViewWrangler class]); | |
| 71 _browserState = browserState; | 67 _browserState = browserState; |
| 72 _tabModelObserver = tabModelObserver; | 68 _tabModelObserver = tabModelObserver; |
| 73 } | 69 } |
| 74 return self; | 70 return self; |
| 75 } | 71 } |
| 76 | 72 |
| 77 - (instancetype)init { | 73 - (instancetype)init { |
| 78 NOTREACHED(); | 74 NOTREACHED(); |
| 79 return nil; | 75 return nil; |
| 80 } | 76 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 | 88 |
| 93 // Stop Breakpad state monitoring of both tab models (if necessary). | 89 // Stop Breakpad state monitoring of both tab models (if necessary). |
| 94 ios_internal::breakpad::StopMonitoringTabStateForTabModel(_mainTabModel); | 90 ios_internal::breakpad::StopMonitoringTabStateForTabModel(_mainTabModel); |
| 95 ios_internal::breakpad::StopMonitoringTabStateForTabModel(_otrTabModel); | 91 ios_internal::breakpad::StopMonitoringTabStateForTabModel(_otrTabModel); |
| 96 | 92 |
| 97 // Normally other objects will take care of unhooking the tab models from | 93 // Normally other objects will take care of unhooking the tab models from |
| 98 // the browser state, but this code should ensure that it happens regardless. | 94 // the browser state, but this code should ensure that it happens regardless. |
| 99 [_mainTabModel browserStateDestroyed]; | 95 [_mainTabModel browserStateDestroyed]; |
| 100 [_otrTabModel browserStateDestroyed]; | 96 [_otrTabModel browserStateDestroyed]; |
| 101 | 97 |
| 98 base::mac::ReleaseProperties(self); |
| 102 [super dealloc]; | 99 [super dealloc]; |
| 103 } | 100 } |
| 104 | 101 |
| 105 #pragma mark - BrowserViewInformation property implementations | 102 #pragma mark - BrowserViewInformation property implementations |
| 106 | 103 |
| 107 - (BrowserViewController*)mainBVC { | 104 - (BrowserViewController*)mainBVC { |
| 108 if (!_mainBVC) { | 105 if (!_mainBVC) { |
| 109 // |_browserState| should always be set before trying to create | 106 // |_browserState| should always be set before trying to create |
| 110 // |_mainBVC|. | 107 // |_mainBVC|. |
| 111 DCHECK(_browserState); | 108 DCHECK(_browserState); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 tabModel:(TabModel*)tabModel { | 334 tabModel:(TabModel*)tabModel { |
| 338 base::scoped_nsobject<BrowserViewControllerDependencyFactory> factory( | 335 base::scoped_nsobject<BrowserViewControllerDependencyFactory> factory( |
| 339 [[BrowserViewControllerDependencyFactory alloc] | 336 [[BrowserViewControllerDependencyFactory alloc] |
| 340 initWithBrowserState:browserState]); | 337 initWithBrowserState:browserState]); |
| 341 return [[[BrowserViewController alloc] initWithTabModel:tabModel | 338 return [[[BrowserViewController alloc] initWithTabModel:tabModel |
| 342 browserState:browserState | 339 browserState:browserState |
| 343 dependencyFactory:factory] autorelease]; | 340 dependencyFactory:factory] autorelease]; |
| 344 } | 341 } |
| 345 | 342 |
| 346 @end | 343 @end |
| OLD | NEW |