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

Side by Side Diff: ios/chrome/browser/ui/main/browser_view_wrangler.mm

Issue 2810743002: [ios] Refactor SessionServiceIOS to remove dependency on BrowserState. (Closed)
Patch Set: Fix a typo in SessionServiceIOS initializer's comment. 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
« no previous file with comments | « ios/chrome/browser/test/perf_test_with_bvc_ios.mm ('k') | 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 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_property_releaser.h"
8 #import "base/mac/scoped_nsobject.h" 8 #import "base/mac/scoped_nsobject.h"
9 #include "base/strings/sys_string_conversions.h"
9 #include "ios/chrome/browser/application_context.h" 10 #include "ios/chrome/browser/application_context.h"
10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 11 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
11 #import "ios/chrome/browser/browsing_data/browsing_data_removal_controller.h" 12 #import "ios/chrome/browser/browsing_data/browsing_data_removal_controller.h"
12 #include "ios/chrome/browser/browsing_data/ios_chrome_browsing_data_remover.h" 13 #include "ios/chrome/browser/browsing_data/ios_chrome_browsing_data_remover.h"
13 #include "ios/chrome/browser/crash_report/crash_report_helper.h" 14 #include "ios/chrome/browser/crash_report/crash_report_helper.h"
14 #import "ios/chrome/browser/device_sharing/device_sharing_manager.h" 15 #import "ios/chrome/browser/device_sharing/device_sharing_manager.h"
15 #import "ios/chrome/browser/physical_web/start_physical_web_discovery.h" 16 #import "ios/chrome/browser/physical_web/start_physical_web_discovery.h"
16 #import "ios/chrome/browser/sessions/session_service_ios.h" 17 #import "ios/chrome/browser/sessions/session_service_ios.h"
17 #import "ios/chrome/browser/sessions/session_window_ios.h" 18 #import "ios/chrome/browser/sessions/session_window_ios.h"
18 #import "ios/chrome/browser/tabs/tab.h" 19 #import "ios/chrome/browser/tabs/tab.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 _browserState->GetOffTheRecordChromeBrowserState(); 291 _browserState->GetOffTheRecordChromeBrowserState();
291 DCHECK(otrBrowserState); 292 DCHECK(otrBrowserState);
292 return [self tabModelForBrowserState:otrBrowserState empty:empty]; 293 return [self tabModelForBrowserState:otrBrowserState empty:empty];
293 } 294 }
294 295
295 - (TabModel*)tabModelForBrowserState:(ios::ChromeBrowserState*)browserState 296 - (TabModel*)tabModelForBrowserState:(ios::ChromeBrowserState*)browserState
296 empty:(BOOL)empty { 297 empty:(BOOL)empty {
297 SessionWindowIOS* sessionWindow = nil; 298 SessionWindowIOS* sessionWindow = nil;
298 if (!empty) { 299 if (!empty) {
299 // Load existing saved tab model state. 300 // Load existing saved tab model state.
301 NSString* statePath =
302 base::SysUTF8ToNSString(browserState->GetStatePath().AsUTF8Unsafe());
300 sessionWindow = [[SessionServiceIOS sharedService] 303 sessionWindow = [[SessionServiceIOS sharedService]
301 loadWindowForBrowserState:browserState]; 304 loadSessionWindowFromDirectory:statePath];
302 } 305 }
303 306
304 // Create tab model from saved session (nil is ok). 307 // Create tab model from saved session (nil is ok).
305 TabModel* tabModel = 308 TabModel* tabModel =
306 [[[TabModel alloc] initWithSessionWindow:sessionWindow 309 [[[TabModel alloc] initWithSessionWindow:sessionWindow
307 sessionService:[SessionServiceIOS sharedService] 310 sessionService:[SessionServiceIOS sharedService]
308 browserState:browserState] autorelease]; 311 browserState:browserState] autorelease];
309 // Add observers. 312 // Add observers.
310 if (_tabModelObserver) { 313 if (_tabModelObserver) {
311 [tabModel addObserver:_tabModelObserver]; 314 [tabModel addObserver:_tabModelObserver];
312 [tabModel addObserver:self]; 315 [tabModel addObserver:self];
313 } 316 }
314 ios_internal::breakpad::MonitorTabStateForTabModel(tabModel); 317 ios_internal::breakpad::MonitorTabStateForTabModel(tabModel);
315 318
316 return tabModel; 319 return tabModel;
317 } 320 }
318 321
319 - (BrowserViewController*)bvcForBrowserState: 322 - (BrowserViewController*)bvcForBrowserState:
320 (ios::ChromeBrowserState*)browserState 323 (ios::ChromeBrowserState*)browserState
321 tabModel:(TabModel*)tabModel { 324 tabModel:(TabModel*)tabModel {
322 base::scoped_nsobject<BrowserViewControllerDependencyFactory> factory( 325 base::scoped_nsobject<BrowserViewControllerDependencyFactory> factory(
323 [[BrowserViewControllerDependencyFactory alloc] 326 [[BrowserViewControllerDependencyFactory alloc]
324 initWithBrowserState:browserState]); 327 initWithBrowserState:browserState]);
325 return [[[BrowserViewController alloc] initWithTabModel:tabModel 328 return [[[BrowserViewController alloc] initWithTabModel:tabModel
326 browserState:browserState 329 browserState:browserState
327 dependencyFactory:factory] autorelease]; 330 dependencyFactory:factory] autorelease];
328 } 331 }
329 332
330 @end 333 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/test/perf_test_with_bvc_ios.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698