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

Side by Side Diff: ios/chrome/app/steps/tab_grid_coordinator+application_step.mm

Issue 2580363002: Upstream Chrome on iOS source code [1/11]. (Closed)
Patch Set: Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // ====== New Architecture =====
6 // = This code is only used in the new iOS Chrome architecture. =
7 // ============================================================================
8
9 #import "ios/chrome/app/steps/tab_grid_coordinator+application_step.h"
10
11 #import "base/supports_user_data.h"
12 #import "ios/chrome/app/application_state.h"
13 #import "ios/chrome/browser/browser_coordinator+internal.h"
14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
19 namespace {
20 // SupportsUserData storage container for a BrowserCoordinator object, which
21 // keeps a strong reference to the object it is initialized with.
22 class RootCoordinatorContainer : public base::SupportsUserData::Data {
23 public:
24 explicit RootCoordinatorContainer(BrowserCoordinator* coordinator)
25 : coordinator_(coordinator) {}
26
27 private:
28 // Mark this variable unused to avoid a compiler warning; the compiler
29 // doesn't have visibility into the ARC-injected retain/release.
30 BrowserCoordinator* __attribute__((unused)) coordinator_;
31 };
32
33 const char kRootCoordinatorContainerKey[] = "root_coordinator";
34 } // namespace
35
36 @interface StopTabGridCoordinator : NSObject<ApplicationStep>
37 @end
38
39 @implementation TabGridCoordinator (ApplicationStep)
40
41 - (BOOL)canRunInState:(ApplicationState*)state {
42 return [state.window isKeyWindow] && state.phase == APPLICATION_FOREGROUNDED;
43 }
44
45 - (void)runInState:(ApplicationState*)state {
46 self.browserState = state.browserState;
47 [self start];
48
49 state.window.rootViewController = self.viewController;
50
51 // Size the main view controller to fit the whole screen.
52 [self.viewController.view setFrame:state.window.bounds];
53
54 // Tell the application state to use this object to open URLs.
55 state.URLOpener = self;
56
57 // Show the window.
58 state.window.hidden = NO;
59
60 // Make sure this object stays alive.
61 state.persistentState->SetUserData(kRootCoordinatorContainerKey,
62 new RootCoordinatorContainer(self));
63
64 // Add a termination step to remove this object.
65 [[state terminationSteps] addObject:[[StopTabGridCoordinator alloc] init]];
66 }
67
68 @end
69
70 @implementation StopTabGridCoordinator
71
72 - (BOOL)canRunInState:(ApplicationState*)state {
73 return state.phase = APPLICATION_TERMINATING;
74 }
75
76 - (void)runInState:(ApplicationState*)state {
77 state.persistentState->RemoveUserData(kRootCoordinatorContainerKey);
78 }
79
80 @end
OLDNEW
« no previous file with comments | « ios/chrome/app/steps/tab_grid_coordinator+application_step.h ('k') | ios/chrome/browser/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698