OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/incognito_panel_controller.h" | 5 #import "ios/chrome/browser/ui/ntp/incognito_panel_controller.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
10 #include "components/google/core/browser/google_util.h" | 10 #include "components/google/core/browser/google_util.h" |
11 #include "components/strings/grit/components_strings.h" | 11 #include "components/strings/grit/components_strings.h" |
12 #include "ios/chrome/browser/application_context.h" | 12 #include "ios/chrome/browser/application_context.h" |
13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
14 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" | 14 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" |
15 #include "ios/chrome/browser/ui/ui_util.h" | 15 #include "ios/chrome/browser/ui/ui_util.h" |
16 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 16 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
17 #import "ios/chrome/browser/ui/url_loader.h" | 17 #import "ios/chrome/browser/ui/url_loader.h" |
18 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" | 18 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" |
19 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 19 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
20 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 20 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
21 #include "ios/web/public/referrer.h" | 21 #include "ios/web/public/referrer.h" |
22 #import "net/base/mac/url_conversions.h" | 22 #import "net/base/mac/url_conversions.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
26 namespace { | 26 namespace { |
27 // The URL for the the Learn More page shown on incognito new tab. | 27 // The URL for the the Learn More page shown on incognito new tab. |
28 // Taken from ntp_resource_cache.cc. | 28 // Taken from ntp_resource_cache.cc. |
29 const char kLearnMoreIncognitoUrl[] = | 29 const char kLearnMoreIncognitoUrl[] = |
30 "https://www.google.com/support/chrome/bin/answer.py?answer=95464"; | 30 "https://www.google.com/support/chrome/bin/answer.py?answer=95464"; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 _containerView.reset([[UIView alloc] initWithFrame:frame]); | 79 _containerView.reset([[UIView alloc] initWithFrame:frame]); |
80 [_containerView setTranslatesAutoresizingMaskIntoConstraints:NO]; | 80 [_containerView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
81 | 81 |
82 // Incognito image. | 82 // Incognito image. |
83 base::scoped_nsobject<UIImageView> incognitoImage([[UIImageView alloc] | 83 base::scoped_nsobject<UIImageView> incognitoImage([[UIImageView alloc] |
84 initWithImage:[UIImage imageNamed:@"incognito_icon"]]); | 84 initWithImage:[UIImage imageNamed:@"incognito_icon"]]); |
85 [incognitoImage setTranslatesAutoresizingMaskIntoConstraints:NO]; | 85 [incognitoImage setTranslatesAutoresizingMaskIntoConstraints:NO]; |
86 [_containerView addSubview:incognitoImage]; | 86 [_containerView addSubview:incognitoImage]; |
87 | 87 |
88 // Title. | 88 // Title. |
89 UIFont* titleFont = | 89 UIFont* titleFont = [[MDCTypography fontLoader] lightFontOfSize:24]; |
90 [[MDFRobotoFontLoader sharedInstance] lightFontOfSize:24]; | |
91 base::scoped_nsobject<UILabel> incognitoTabHeading( | 90 base::scoped_nsobject<UILabel> incognitoTabHeading( |
92 [[self labelWithString:l10n_util::GetNSString(IDS_NEW_TAB_OTR_HEADING) | 91 [[self labelWithString:l10n_util::GetNSString(IDS_NEW_TAB_OTR_HEADING) |
93 font:titleFont | 92 font:titleFont |
94 alpha:0.8] retain]); | 93 alpha:0.8] retain]); |
95 [_containerView addSubview:incognitoTabHeading]; | 94 [_containerView addSubview:incognitoTabHeading]; |
96 | 95 |
97 // Description paragraph. | 96 // Description paragraph. |
98 UIFont* regularFont = | 97 UIFont* regularFont = [[MDCTypography fontLoader] regularFontOfSize:14]; |
99 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:14]; | |
100 base::scoped_nsobject<UILabel> incognitoTabDescription([[self | 98 base::scoped_nsobject<UILabel> incognitoTabDescription([[self |
101 labelWithString:l10n_util::GetNSString(IDS_NEW_TAB_OTR_DESCRIPTION) | 99 labelWithString:l10n_util::GetNSString(IDS_NEW_TAB_OTR_DESCRIPTION) |
102 font:regularFont | 100 font:regularFont |
103 alpha:0.7] retain]); | 101 alpha:0.7] retain]); |
104 [_containerView addSubview:incognitoTabDescription]; | 102 [_containerView addSubview:incognitoTabDescription]; |
105 | 103 |
106 // Warning paragraph. | 104 // Warning paragraph. |
107 base::scoped_nsobject<UILabel> incognitoTabWarning([[self | 105 base::scoped_nsobject<UILabel> incognitoTabWarning([[self |
108 labelWithString:l10n_util::GetNSString(IDS_NEW_TAB_OTR_MESSAGE_WARNING) | 106 labelWithString:l10n_util::GetNSString(IDS_NEW_TAB_OTR_MESSAGE_WARNING) |
109 font:regularFont | 107 font:regularFont |
110 alpha:0.7] retain]); | 108 alpha:0.7] retain]); |
111 [_containerView addSubview:incognitoTabWarning]; | 109 [_containerView addSubview:incognitoTabWarning]; |
112 | 110 |
113 // Learn more button. | 111 // Learn more button. |
114 base::scoped_nsobject<MDCButton> learnMore([[MDCFlatButton alloc] init]); | 112 base::scoped_nsobject<MDCButton> learnMore([[MDCFlatButton alloc] init]); |
115 UIColor* inkColor = | 113 UIColor* inkColor = |
116 [[[MDCPalette greyPalette] tint300] colorWithAlphaComponent:0.25]; | 114 [[[MDCPalette greyPalette] tint300] colorWithAlphaComponent:0.25]; |
117 [learnMore setInkColor:inkColor]; | 115 [learnMore setInkColor:inkColor]; |
118 [learnMore setTranslatesAutoresizingMaskIntoConstraints:NO]; | 116 [learnMore setTranslatesAutoresizingMaskIntoConstraints:NO]; |
119 [learnMore setTitle:l10n_util::GetNSString(IDS_NEW_TAB_OTR_LEARN_MORE_LINK) | 117 [learnMore setTitle:l10n_util::GetNSString(IDS_NEW_TAB_OTR_LEARN_MORE_LINK) |
120 forState:UIControlStateNormal]; | 118 forState:UIControlStateNormal]; |
121 [learnMore setTitleColor:UIColorFromRGB(kLinkColor) | 119 [learnMore setTitleColor:UIColorFromRGB(kLinkColor) |
122 forState:UIControlStateNormal]; | 120 forState:UIControlStateNormal]; |
123 UIFont* buttonFont = | 121 UIFont* buttonFont = [[MDCTypography fontLoader] boldFontOfSize:14]; |
124 [[MDFRobotoFontLoader sharedInstance] boldFontOfSize:14]; | |
125 [[learnMore titleLabel] setFont:buttonFont]; | 122 [[learnMore titleLabel] setFont:buttonFont]; |
126 [learnMore addTarget:self | 123 [learnMore addTarget:self |
127 action:@selector(learnMoreButtonPressed) | 124 action:@selector(learnMoreButtonPressed) |
128 forControlEvents:UIControlEventTouchUpInside]; | 125 forControlEvents:UIControlEventTouchUpInside]; |
129 [_containerView addSubview:learnMore]; | 126 [_containerView addSubview:learnMore]; |
130 | 127 |
131 // |topGuide| and |bottomGuide| exist to vertically center the sibling views | 128 // |topGuide| and |bottomGuide| exist to vertically center the sibling views |
132 // located in between them. | 129 // located in between them. |
133 base::scoped_nsobject<UILayoutGuide> topGuide([[UILayoutGuide alloc] init]); | 130 base::scoped_nsobject<UILayoutGuide> topGuide([[UILayoutGuide alloc] init]); |
134 base::scoped_nsobject<UILayoutGuide> bottomGuide( | 131 base::scoped_nsobject<UILayoutGuide> bottomGuide( |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 349 |
353 #pragma mark - | 350 #pragma mark - |
354 #pragma mark UIScrollViewDelegate methods | 351 #pragma mark UIScrollViewDelegate methods |
355 | 352 |
356 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { | 353 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { |
357 CGFloat alpha = [self toolbarAlphaForScrollView:_incognitoView]; | 354 CGFloat alpha = [self toolbarAlphaForScrollView:_incognitoView]; |
358 [_webToolbarDelegate updateToolbarBackgroundAlpha:alpha]; | 355 [_webToolbarDelegate updateToolbarBackgroundAlpha:alpha]; |
359 } | 356 } |
360 | 357 |
361 @end | 358 @end |
OLD | NEW |