OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/clean/chrome/app/steps/root_coordinator+application_step.h" | 5 #import "ios/clean/chrome/app/steps/root_coordinator+application_step.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/supports_user_data.h" | 8 #include "base/supports_user_data.h" |
9 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 9 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
10 #import "ios/chrome/browser/web_state_list/web_state_list.h" | 10 #import "ios/chrome/browser/web_state_list/web_state_list.h" |
11 #import "ios/clean/chrome/app/application_state.h" | 11 #import "ios/clean/chrome/app/application_state.h" |
12 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" | 12 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
13 #import "ios/shared/chrome/browser/ui/browser_list/browser_list.h" | 13 #import "ios/shared/chrome/browser/ui/browser_list/browser_list.h" |
14 #import "ios/shared/chrome/browser/ui/browser_list/browser_list_session_service.
h" | 14 #import "ios/shared/chrome/browser/ui/browser_list/browser_list_session_service.
h" |
15 #import "ios/shared/chrome/browser/ui/browser_list/browser_list_session_service_
factory.h" | 15 #import "ios/shared/chrome/browser/ui/browser_list/browser_list_session_service_
factory.h" |
| 16 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" |
16 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.
h" | 17 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.
h" |
17 #import "ios/web/public/navigation_manager.h" | 18 #import "ios/web/public/navigation_manager.h" |
18 #include "ios/web/public/web_state/web_state.h" | 19 #include "ios/web/public/web_state/web_state.h" |
19 | 20 |
20 #if !defined(__has_feature) || !__has_feature(objc_arc) | 21 #if !defined(__has_feature) || !__has_feature(objc_arc) |
21 #error "This file requires ARC support." | 22 #error "This file requires ARC support." |
22 #endif | 23 #endif |
23 | 24 |
24 namespace { | 25 namespace { |
25 // SupportsUserData storage container for a BrowserCoordinator object, which | 26 // SupportsUserData storage container for a BrowserCoordinator object, which |
(...skipping 17 matching lines...) Expand all Loading... |
43 | 44 |
44 @implementation RootCoordinator (ApplicationStep) | 45 @implementation RootCoordinator (ApplicationStep) |
45 | 46 |
46 - (BOOL)canRunInState:(ApplicationState*)state { | 47 - (BOOL)canRunInState:(ApplicationState*)state { |
47 return [state.window isKeyWindow] && state.phase == APPLICATION_FOREGROUNDED; | 48 return [state.window isKeyWindow] && state.phase == APPLICATION_FOREGROUNDED; |
48 } | 49 } |
49 | 50 |
50 - (void)runInState:(ApplicationState*)state { | 51 - (void)runInState:(ApplicationState*)state { |
51 self.browser = | 52 self.browser = |
52 BrowserList::FromBrowserState(state.browserState)->CreateNewBrowser(); | 53 BrowserList::FromBrowserState(state.browserState)->CreateNewBrowser(); |
| 54 self.dispatcher = [[CommandDispatcher alloc] init]; |
53 | 55 |
54 BrowserListSessionService* service = | 56 BrowserListSessionService* service = |
55 BrowserListSessionServiceFactory::GetForBrowserState(state.browserState); | 57 BrowserListSessionServiceFactory::GetForBrowserState(state.browserState); |
56 | 58 |
57 if (!service || !service->RestoreSession()) { | 59 if (!service || !service->RestoreSession()) { |
58 WebStateList& webStateList = self.browser->web_state_list(); | 60 WebStateList& webStateList = self.browser->web_state_list(); |
59 web::WebState::CreateParams webStateCreateParams( | 61 web::WebState::CreateParams webStateCreateParams( |
60 self.browser->browser_state()); | 62 self.browser->browser_state()); |
61 webStateList.InsertWebState(0, web::WebState::Create(webStateCreateParams)); | 63 webStateList.InsertWebState(0, web::WebState::Create(webStateCreateParams)); |
62 webStateList.ActivateWebStateAt(0); | 64 webStateList.ActivateWebStateAt(0); |
(...skipping 27 matching lines...) Expand all Loading... |
90 | 92 |
91 - (BOOL)canRunInState:(ApplicationState*)state { | 93 - (BOOL)canRunInState:(ApplicationState*)state { |
92 return state.phase = APPLICATION_TERMINATING; | 94 return state.phase = APPLICATION_TERMINATING; |
93 } | 95 } |
94 | 96 |
95 - (void)runInState:(ApplicationState*)state { | 97 - (void)runInState:(ApplicationState*)state { |
96 state.persistentState->RemoveUserData(kRootCoordinatorContainerKey); | 98 state.persistentState->RemoveUserData(kRootCoordinatorContainerKey); |
97 } | 99 } |
98 | 100 |
99 @end | 101 @end |
OLD | NEW |