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/chrome/browser/content_suggestions/content_suggestions_coordinator.
h" | 5 #import "ios/chrome/browser/content_suggestions/content_suggestions_coordinator.
h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #import "ios/chrome/browser/ui/suggestions/suggestions_commands.h" | 8 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.
h" |
9 #import "ios/chrome/browser/ui/suggestions/suggestions_view_controller.h" | 9 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_cont
roller.h" |
10 #include "ios/chrome/grit/ios_strings.h" | 10 #include "ios/chrome/grit/ios_strings.h" |
11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
12 | 12 |
13 #if !defined(__has_feature) || !__has_feature(objc_arc) | 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
14 #error "This file requires ARC support." | 14 #error "This file requires ARC support." |
15 #endif | 15 #endif |
16 | 16 |
17 @interface ContentSuggestionsCoordinator ()<SuggestionsCommands> { | 17 @interface ContentSuggestionsCoordinator ()<ContentSuggestionsCommands> { |
18 UINavigationController* _navigationController; | 18 UINavigationController* _navigationController; |
19 } | 19 } |
20 | 20 |
21 @end | 21 @end |
22 | 22 |
23 @implementation ContentSuggestionsCoordinator | 23 @implementation ContentSuggestionsCoordinator |
24 | 24 |
25 - (void)start { | 25 - (void)start { |
26 if (_navigationController) { | 26 if (_navigationController) { |
27 // Prevent this coordinator to be started twice in a row. | 27 // Prevent this coordinator to be started twice in a row. |
28 return; | 28 return; |
29 } | 29 } |
30 | 30 |
31 SuggestionsViewController* suggestionsViewController = | 31 ContentSuggestionsViewController* suggestionsViewController = |
32 [[SuggestionsViewController alloc] | 32 [[ContentSuggestionsViewController alloc] |
33 initWithStyle:CollectionViewControllerStyleDefault]; | 33 initWithStyle:CollectionViewControllerStyleDefault]; |
34 | 34 |
35 suggestionsViewController.suggestionCommandHandler = self; | 35 suggestionsViewController.suggestionCommandHandler = self; |
36 _navigationController = [[UINavigationController alloc] | 36 _navigationController = [[UINavigationController alloc] |
37 initWithRootViewController:suggestionsViewController]; | 37 initWithRootViewController:suggestionsViewController]; |
38 | 38 |
39 suggestionsViewController.navigationItem.leftBarButtonItem = | 39 suggestionsViewController.navigationItem.leftBarButtonItem = |
40 [[UIBarButtonItem alloc] | 40 [[UIBarButtonItem alloc] |
41 initWithTitle:l10n_util::GetNSString(IDS_IOS_SUGGESTIONS_DONE) | 41 initWithTitle:l10n_util::GetNSString(IDS_IOS_SUGGESTIONS_DONE) |
42 style:UIBarButtonItemStylePlain | 42 style:UIBarButtonItemStylePlain |
43 target:self | 43 target:self |
44 action:@selector(stop)]; | 44 action:@selector(stop)]; |
45 | 45 |
46 [self.baseViewController presentViewController:_navigationController | 46 [self.baseViewController presentViewController:_navigationController |
47 animated:YES | 47 animated:YES |
48 completion:nil]; | 48 completion:nil]; |
49 } | 49 } |
50 | 50 |
51 - (void)stop { | 51 - (void)stop { |
52 [[_navigationController presentingViewController] | 52 [[_navigationController presentingViewController] |
53 dismissViewControllerAnimated:YES | 53 dismissViewControllerAnimated:YES |
54 completion:nil]; | 54 completion:nil]; |
55 _navigationController = nil; | 55 _navigationController = nil; |
56 } | 56 } |
57 | 57 |
58 #pragma mark - SuggestionsCommands | 58 #pragma mark - ContentSuggestionsCommands |
59 | 59 |
60 - (void)openReadingList { | 60 - (void)openReadingList { |
61 } | 61 } |
62 | 62 |
63 - (void)openFirstPageOfReadingList { | 63 - (void)openFirstPageOfReadingList { |
64 } | 64 } |
65 | 65 |
66 - (void)addEmptyItem { | 66 - (void)addEmptyItem { |
67 } | 67 } |
68 | 68 |
69 @end | 69 @end |
OLD | NEW |