Commit b4478d57 authored by lpromero's avatar lpromero Committed by Commit bot

Make BrowserCoordinator use a Browser instead of a BrowserState

BUG=none
R=sdefresne@chromium.org

Review-Url: https://codereview.chromium.org/2735973003
Cr-Commit-Position: refs/heads/master@{#455780}
parent cde968df
......@@ -29,6 +29,7 @@ source_set("steps") {
"//ios/chrome/browser/web:web_internal",
"//ios/clean/chrome/app:application_state",
"//ios/clean/chrome/browser",
"//ios/clean/chrome/browser/model",
"//ios/clean/chrome/browser/ui/tab_grid",
"//ios/net",
"//ios/web:web_arc",
......
......@@ -11,6 +11,8 @@
#import "base/supports_user_data.h"
#import "ios/clean/chrome/app/application_state.h"
#import "ios/clean/chrome/browser/browser_coordinator+internal.h"
#import "ios/clean/chrome/browser/model/browser.h"
#import "ios/clean/chrome/browser/model/browser_list.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -43,7 +45,8 @@ const char kRootCoordinatorContainerKey[] = "root_coordinator";
}
- (void)runInState:(ApplicationState*)state {
self.browserState = state.browserState;
self.browser =
BrowserList::FromBrowserState(state.browserState)->CreateNewBrowser();
[self start];
state.window.rootViewController = self.viewController;
......
......@@ -18,6 +18,7 @@ source_set("browser") {
"//ios/chrome/browser",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/tabs:tabs_internal",
"//ios/clean/chrome/browser/model",
"//ios/shared/chrome/browser/coordinator_context",
]
}
......
......@@ -48,7 +48,7 @@
// Adds |coordinator| as a child, taking ownership of it, setting the receiver's
// viewController (if any) as the child's baseViewController, and setting
// the receiver's browserState as the child's browserState.
// the receiver's |browser| as the child's |browser|.
- (void)addChildCoordinator:(BrowserCoordinator*)coordinator;
// Removes |coordinator| as a child, relinquishing ownership of it. If
......
......@@ -11,10 +11,8 @@
#import <UIKit/UIKit.h>
class Browser;
@class CoordinatorContext;
namespace ios {
class ChromeBrowserState;
}
// An object that manages a UI component via a view controller.
// This is the public interface to this class; subclasses should also import
......@@ -26,10 +24,10 @@ class ChromeBrowserState;
// The context object for this coordinator.
@property(nonatomic, strong, readonly) CoordinatorContext* context;
// The browser state used by this coordinator and passed into any child
// The browser object used by this coordinator and passed into any child
// coordinators added to it. This is a weak pointer, and setting this property
// doesn't transfer ownership of the browser state.
@property(nonatomic, assign) ios::ChromeBrowserState* browserState;
// doesn't transfer ownership of the browser.
@property(nonatomic, assign) Browser* browser;
// The basic lifecycle methods for coordinators are -start and -stop. These
// are blank template methods; child classes are expected to implement them and
......
......@@ -27,7 +27,7 @@
@implementation BrowserCoordinator
@synthesize context = _context;
@synthesize browserState = _browserState;
@synthesize browser = _browser;
@synthesize childCoordinators = _childCoordinators;
@synthesize parentCoordinator = _parentCoordinator;
@synthesize overlaying = _overlaying;
......@@ -66,7 +66,7 @@
"property.";
[self.childCoordinators addObject:coordinator];
coordinator.parentCoordinator = self;
coordinator.browserState = self.browserState;
coordinator.browser = self.browser;
coordinator.context.baseViewController = self.viewController;
}
......
......@@ -13,6 +13,7 @@ source_set("settings") {
deps = [
"//ios/chrome/browser/ui/settings",
"//ios/clean/chrome/browser",
"//ios/clean/chrome/browser/model",
"//ios/clean/chrome/browser/ui/actions",
"//ios/clean/chrome/browser/ui/commands",
"//ios/shared/chrome/browser/coordinator_context",
......
......@@ -10,6 +10,7 @@
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/clean/chrome/browser/browser_coordinator+internal.h"
#import "ios/clean/chrome/browser/model/browser.h"
#import "ios/clean/chrome/browser/ui/commands/settings_commands.h"
#import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h"
......@@ -29,8 +30,10 @@
- (void)start {
self.viewController = [SettingsNavigationController
newSettingsMainControllerWithMainBrowserState:self.browserState
currentBrowserState:self.browserState
newSettingsMainControllerWithMainBrowserState:self.browser
->browser_state()
currentBrowserState:self.browser
->browser_state()
delegate:self];
[self.context.baseViewController presentViewController:self.viewController
animated:self.context.animated
......
......@@ -15,6 +15,7 @@ source_set("tab_grid") {
"//base",
"//ios/chrome/browser/browser_state",
"//ios/clean/chrome/browser",
"//ios/clean/chrome/browser/model",
"//ios/clean/chrome/browser/ui/commands",
"//ios/clean/chrome/browser/ui/settings",
"//ios/clean/chrome/browser/ui/tab",
......
......@@ -13,6 +13,7 @@
#include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/clean/chrome/browser/browser_coordinator+internal.h"
#import "ios/clean/chrome/browser/model/browser.h"
#import "ios/clean/chrome/browser/ui/commands/settings_commands.h"
#import "ios/clean/chrome/browser/ui/commands/tab_commands.h"
#import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h"
......@@ -47,11 +48,11 @@
#pragma mark - Properties
- (void)setBrowserState:(ios::ChromeBrowserState*)browserState {
[super setBrowserState:browserState];
- (void)setBrowser:(Browser*)browser {
[super setBrowser:browser];
for (int i = 0; i < 7; i++) {
web::WebState::CreateParams webStateCreateParams(browserState);
web::WebState::CreateParams webStateCreateParams(browser->browser_state());
std::unique_ptr<web::WebState> webState =
web::WebState::Create(webStateCreateParams);
_webStates.push_back(std::move(webState));
......@@ -118,7 +119,8 @@
}
- (void)createNewTabAtIndexPath:(NSIndexPath*)indexPath {
web::WebState::CreateParams webStateCreateParams(self.browserState);
web::WebState::CreateParams webStateCreateParams(
self.browser->browser_state());
std::unique_ptr<web::WebState> webState =
web::WebState::Create(webStateCreateParams);
_webStates.push_back(std::move(webState));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment