OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/sad_tab/sad_tab_view.h" | 5 #import "ios/chrome/browser/ui/sad_tab/sad_tab_view.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "components/grit/components_scaled_resources.h" | 9 #include "components/grit/components_scaled_resources.h" |
10 #include "components/strings/grit/components_strings.h" | 10 #include "components/strings/grit/components_strings.h" |
11 #include "components/ui_metrics/sadtab_metrics_types.h" | 11 #include "components/ui_metrics/sadtab_metrics_types.h" |
12 #include "ios/chrome/browser/chrome_url_constants.h" | 12 #include "ios/chrome/browser/chrome_url_constants.h" |
13 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 13 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
14 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 14 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
15 #import "ios/chrome/browser/ui/commands/ios_command_ids.h" | 15 #import "ios/chrome/browser/ui/commands/ios_command_ids.h" |
16 #import "ios/chrome/browser/ui/commands/open_url_command.h" | 16 #import "ios/chrome/browser/ui/commands/open_url_command.h" |
17 #include "ios/chrome/browser/ui/rtl_geometry.h" | 17 #include "ios/chrome/browser/ui/rtl_geometry.h" |
18 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 18 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
19 #import "ios/chrome/browser/ui/url_loader.h" | 19 #import "ios/chrome/browser/ui/url_loader.h" |
20 #import "ios/chrome/browser/ui/util/label_link_controller.h" | 20 #import "ios/chrome/browser/ui/util/label_link_controller.h" |
21 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" | 21 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" |
22 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 22 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 23 #include "ios/web/public/browser_state.h" |
23 #include "ios/web/public/navigation_manager.h" | 24 #include "ios/web/public/navigation_manager.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
26 | 27 |
27 #if !defined(__has_feature) || !__has_feature(objc_arc) | 28 #if !defined(__has_feature) || !__has_feature(objc_arc) |
28 #error "This file requires ARC support." | 29 #error "This file requires ARC support." |
29 #endif | 30 #endif |
30 | 31 |
31 namespace { | 32 namespace { |
32 // Color constants. | 33 // Color constants. |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 label = [[NSAttributedString alloc] | 234 label = [[NSAttributedString alloc] |
234 initWithString:l10n_util::GetNSString(IDS_SAD_TAB_MESSAGE)]; | 235 initWithString:l10n_util::GetNSString(IDS_SAD_TAB_MESSAGE)]; |
235 break; | 236 break; |
236 case SadTabViewMode::FEEDBACK: { | 237 case SadTabViewMode::FEEDBACK: { |
237 NSString* feedbackIntroductionString = [NSString | 238 NSString* feedbackIntroductionString = [NSString |
238 stringWithFormat:@"%@\n\n", | 239 stringWithFormat:@"%@\n\n", |
239 l10n_util::GetNSString(IDS_SAD_TAB_RELOAD_TRY)]; | 240 l10n_util::GetNSString(IDS_SAD_TAB_RELOAD_TRY)]; |
240 NSMutableAttributedString* feedbackString = | 241 NSMutableAttributedString* feedbackString = |
241 [[NSMutableAttributedString alloc] | 242 [[NSMutableAttributedString alloc] |
242 initWithString:feedbackIntroductionString]; | 243 initWithString:feedbackIntroductionString]; |
| 244 |
| 245 BOOL isAlreadyInIncognitoMode = |
| 246 _navigationManager |
| 247 ? _navigationManager->GetBrowserState()->IsOffTheRecord() |
| 248 : NO; |
| 249 NSMutableArray* stringsArray = [NSMutableArray |
| 250 arrayWithObjects:l10n_util::GetNSString( |
| 251 IDS_SAD_TAB_RELOAD_RESTART_BROWSER), |
| 252 l10n_util::GetNSString( |
| 253 IDS_SAD_TAB_RELOAD_RESTART_DEVICE), |
| 254 nil]; |
| 255 if (!isAlreadyInIncognitoMode) { |
| 256 NSString* incognitoSuggestionString = |
| 257 l10n_util::GetNSString(IDS_SAD_TAB_RELOAD_INCOGNITO); |
| 258 [stringsArray insertObject:incognitoSuggestionString atIndex:0]; |
| 259 } |
| 260 |
243 NSAttributedString* bulletedListString = | 261 NSAttributedString* bulletedListString = |
244 [[self class] bulletedAttributedStringFromStrings:@[ | 262 [[self class] bulletedAttributedStringFromStrings:stringsArray]; |
245 l10n_util::GetNSString(IDS_SAD_TAB_RELOAD_INCOGNITO), | |
246 l10n_util::GetNSString(IDS_SAD_TAB_RELOAD_RESTART_BROWSER), | |
247 l10n_util::GetNSString(IDS_SAD_TAB_RELOAD_RESTART_DEVICE) | |
248 ]]; | |
249 [feedbackString appendAttributedString:bulletedListString]; | 263 [feedbackString appendAttributedString:bulletedListString]; |
250 label = feedbackString; | 264 label = feedbackString; |
251 break; | 265 break; |
252 } | 266 } |
253 } | 267 } |
254 DCHECK(label); | 268 DCHECK(label); |
255 return label; | 269 return label; |
256 } | 270 } |
257 | 271 |
258 - (nonnull NSString*)footerLabelText { | 272 - (nonnull NSString*)footerLabelText { |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 break; | 586 break; |
573 } | 587 } |
574 }; | 588 }; |
575 } | 589 } |
576 | 590 |
577 + (UIColor*)sadTabBackgroundColor { | 591 + (UIColor*)sadTabBackgroundColor { |
578 return [UIColor colorWithWhite:kBackgroundColorBrightness alpha:1.0]; | 592 return [UIColor colorWithWhite:kBackgroundColorBrightness alpha:1.0]; |
579 } | 593 } |
580 | 594 |
581 @end | 595 @end |
OLD | NEW |