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

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: 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 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.
300 sessionWindow = [[SessionServiceIOS sharedService] 301 SessionServiceIOS* sessionService = [SessionServiceIOS sharedService];
301 loadWindowForBrowserState:browserState]; 302 NSString* statePath =
303 base::SysUTF8ToNSString(browserState->GetStatePath().AsUTF8Unsafe());
304 NSString* sessionPath = [sessionService sessionPathForDirectory:statePath];
305 sessionWindow = [sessionService loadSessionWindowFromPath:sessionPath];
302 } 306 }
303 307
304 // Create tab model from saved session (nil is ok). 308 // Create tab model from saved session (nil is ok).
305 TabModel* tabModel = 309 TabModel* tabModel =
306 [[[TabModel alloc] initWithSessionWindow:sessionWindow 310 [[[TabModel alloc] initWithSessionWindow:sessionWindow
307 sessionService:[SessionServiceIOS sharedService] 311 sessionService:[SessionServiceIOS sharedService]
308 browserState:browserState] autorelease]; 312 browserState:browserState] autorelease];
309 // Add observers. 313 // Add observers.
310 if (_tabModelObserver) { 314 if (_tabModelObserver) {
311 [tabModel addObserver:_tabModelObserver]; 315 [tabModel addObserver:_tabModelObserver];
312 [tabModel addObserver:self]; 316 [tabModel addObserver:self];
313 } 317 }
314 ios_internal::breakpad::MonitorTabStateForTabModel(tabModel); 318 ios_internal::breakpad::MonitorTabStateForTabModel(tabModel);
315 319
316 return tabModel; 320 return tabModel;
317 } 321 }
318 322
319 - (BrowserViewController*)bvcForBrowserState: 323 - (BrowserViewController*)bvcForBrowserState:
320 (ios::ChromeBrowserState*)browserState 324 (ios::ChromeBrowserState*)browserState
321 tabModel:(TabModel*)tabModel { 325 tabModel:(TabModel*)tabModel {
322 base::scoped_nsobject<BrowserViewControllerDependencyFactory> factory( 326 base::scoped_nsobject<BrowserViewControllerDependencyFactory> factory(
323 [[BrowserViewControllerDependencyFactory alloc] 327 [[BrowserViewControllerDependencyFactory alloc]
324 initWithBrowserState:browserState]); 328 initWithBrowserState:browserState]);
325 return [[[BrowserViewController alloc] initWithTabModel:tabModel 329 return [[[BrowserViewController alloc] initWithTabModel:tabModel
326 browserState:browserState 330 browserState:browserState
327 dependencyFactory:factory] autorelease]; 331 dependencyFactory:factory] autorelease];
328 } 332 }
329 333
330 @end 334 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698