OLD | NEW |
---|---|
(Empty) | |
1 | |
2 // Copyright 2017 The Chromium Authors. All rights reserved. | |
3 // Use of this source code is governed by a BSD-style license that can be | |
4 // found in the LICENSE file. | |
5 | |
6 #import "ios/clean/chrome/browser/ui/ntp/new_tab_page_mediator.h" | |
7 | |
8 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar_item.h" | |
9 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" | |
10 #include "ios/chrome/browser/ui/ui_util.h" | |
11 #include "ios/chrome/grit/ios_strings.h" | |
12 #import "ios/clean/chrome/browser/ui/ntp/new_tab_page_consumer.h" | |
13 #include "ui/base/l10n/l10n_util.h" | |
14 | |
15 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
16 #error "This file requires ARC support." | |
17 #endif | |
18 | |
19 @interface NTPMediator () | |
20 @property(nonatomic, strong) id<NTPConsumer> consumer; | |
21 @end | |
22 | |
23 @implementation NTPMediator | |
24 | |
25 @synthesize consumer = _consumer; | |
26 | |
27 - (instancetype)initWithConsumer:(id<NTPConsumer>)consumer { | |
28 self = [super init]; | |
29 if (self) { | |
30 self.consumer = consumer; | |
marq (ping after 24h)
2017/04/05 12:22:48
_consumer = consumer;
justincohen
2017/04/05 19:28:24
Done.
| |
31 [self setTabBarItems]; | |
32 } | |
33 | |
34 return self; | |
35 } | |
36 | |
37 - (void)setTabBarItems { | |
38 NSString* mostVisited = l10n_util::GetNSString(IDS_IOS_NEW_TAB_MOST_VISITED); | |
39 NSString* bookmarks = | |
40 l10n_util::GetNSString(IDS_IOS_NEW_TAB_BOOKMARKS_PAGE_TITLE_MOBILE); | |
41 NSString* openTabs = l10n_util::GetNSString(IDS_IOS_NEW_TAB_RECENT_TABS); | |
42 | |
43 NSMutableArray* tabBarItems = [NSMutableArray array]; | |
44 | |
45 NewTabPageBarItem* mostVisitedItem = [NewTabPageBarItem | |
46 newTabPageBarItemWithTitle:mostVisited | |
47 identifier:NewTabPage::kMostVisitedPanel | |
48 image:[UIImage imageNamed:@"ntp_mv_search"]]; | |
49 NewTabPageBarItem* bookmarksItem = [NewTabPageBarItem | |
50 newTabPageBarItemWithTitle:bookmarks | |
51 identifier:NewTabPage::kBookmarksPanel | |
52 image:[UIImage imageNamed:@"ntp_bookmarks"]]; | |
53 [tabBarItems addObject:bookmarksItem]; | |
54 if (IsIPadIdiom()) { | |
55 [tabBarItems addObject:mostVisitedItem]; | |
56 } | |
57 | |
58 NewTabPageBarItem* openTabsItem = [NewTabPageBarItem | |
59 newTabPageBarItemWithTitle:openTabs | |
60 identifier:NewTabPage::kOpenTabsPanel | |
61 image:[UIImage imageNamed:@"ntp_opentabs"]]; | |
62 [tabBarItems addObject:openTabsItem]; | |
63 | |
64 [self.consumer setTabBarItems:tabBarItems]; | |
65 } | |
66 | |
67 @end | |
OLD | NEW |