OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/ntp/new_tab_page_header_view.h" | 5 #import "ios/chrome/browser/ui/ntp/new_tab_page_header_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 #import "ios/chrome/browser/tabs/tab_model.h" | 9 #import "ios/chrome/browser/tabs/tab_model.h" |
10 #import "ios/chrome/browser/tabs/tab_model_observer.h" | 10 #import "ios/chrome/browser/tabs/tab_model_observer.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 - (void)reparentToolbarController { | 63 - (void)reparentToolbarController { |
64 [self addSubview:[_toolbarController view]]; | 64 [self addSubview:[_toolbarController view]]; |
65 } | 65 } |
66 | 66 |
67 - (void)addToolbarWithDataSource:(id<GoogleLandingDataSource>)dataSource { | 67 - (void)addToolbarWithDataSource:(id<GoogleLandingDataSource>)dataSource { |
68 DCHECK(!_toolbarController); | 68 DCHECK(!_toolbarController); |
69 DCHECK(dataSource); | 69 DCHECK(dataSource); |
70 | 70 |
71 _toolbarController.reset([[NewTabPageToolbarController alloc] | 71 _toolbarController.reset([[NewTabPageToolbarController alloc] |
72 initWithToolbarDelegate:[dataSource toolbarDelegate] | 72 initWithToolbarDataSource:dataSource]); |
73 focuser:dataSource]); | |
74 _toolbarController.get().readingListModel = [dataSource readingListModel]; | 73 _toolbarController.get().readingListModel = [dataSource readingListModel]; |
75 | 74 |
76 UIView* toolbarView = [_toolbarController view]; | 75 UIView* toolbarView = [_toolbarController view]; |
77 CGRect toolbarFrame = self.bounds; | 76 CGRect toolbarFrame = self.bounds; |
78 toolbarFrame.size.height = ntp_header::kToolbarHeight; | 77 toolbarFrame.size.height = ntp_header::kToolbarHeight; |
79 toolbarView.frame = toolbarFrame; | 78 toolbarView.frame = toolbarFrame; |
80 [toolbarView setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; | 79 [toolbarView setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; |
81 [self hideToolbarViewsForNewTabPage]; | |
82 | 80 |
83 [self setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; | 81 [self setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; |
84 [self addSubview:[_toolbarController view]]; | 82 [self addSubview:[_toolbarController view]]; |
85 } | 83 } |
86 | 84 |
| 85 - (void)setCanGoForward:(BOOL)canGoForward { |
| 86 [_toolbarController setCanGoForward:canGoForward]; |
| 87 [self hideToolbarViewsForNewTabPage]; |
| 88 } |
| 89 |
| 90 - (void)setCanGoBack:(BOOL)canGoBack { |
| 91 [_toolbarController setCanGoBack:canGoBack]; |
| 92 [self hideToolbarViewsForNewTabPage]; |
| 93 } |
| 94 |
87 - (void)hideToolbarViewsForNewTabPage { | 95 - (void)hideToolbarViewsForNewTabPage { |
88 [_toolbarController hideViewsForNewTabPage:YES]; | 96 [_toolbarController hideViewsForNewTabPage:YES]; |
89 }; | 97 }; |
90 | 98 |
91 - (void)setToolbarTabCount:(int)tabCount { | 99 - (void)setToolbarTabCount:(int)tabCount { |
92 [_toolbarController setTabCount:tabCount]; | 100 [_toolbarController setTabCount:tabCount]; |
93 } | 101 } |
94 | 102 |
95 - (void)addViewsToSearchField:(UIView*)searchField { | 103 - (void)addViewsToSearchField:(UIView*)searchField { |
96 [searchField setBackgroundColor:[UIColor whiteColor]]; | 104 [searchField setBackgroundColor:[UIColor whiteColor]]; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 166 } |
159 | 167 |
160 - (void)fadeOutShadow { | 168 - (void)fadeOutShadow { |
161 [UIView animateWithDuration:ios::material::kDuration1 | 169 [UIView animateWithDuration:ios::material::kDuration1 |
162 animations:^{ | 170 animations:^{ |
163 [_shadow setAlpha:0]; | 171 [_shadow setAlpha:0]; |
164 }]; | 172 }]; |
165 } | 173 } |
166 | 174 |
167 @end | 175 @end |
OLD | NEW |