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 #import "base/ios/weak_nsobject.h" | 7 #import "base/ios/weak_nsobject.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/mac/scoped_block.h" | 9 #include "base/mac/scoped_block.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
12 #include "components/grit/components_scaled_resources.h" | 12 #include "components/grit/components_scaled_resources.h" |
13 #include "components/strings/grit/components_strings.h" | 13 #include "components/strings/grit/components_strings.h" |
14 #include "ios/chrome/browser/chrome_url_constants.h" | 14 #include "ios/chrome/browser/chrome_url_constants.h" |
15 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 15 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
16 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 16 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
17 #import "ios/chrome/browser/ui/commands/open_url_command.h" | 17 #import "ios/chrome/browser/ui/commands/open_url_command.h" |
18 #include "ios/chrome/browser/ui/rtl_geometry.h" | 18 #include "ios/chrome/browser/ui/rtl_geometry.h" |
19 #include "ios/chrome/browser/ui/ui_util.h" | 19 #include "ios/chrome/browser/ui/ui_util.h" |
| 20 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
20 #import "ios/chrome/browser/ui/url_loader.h" | 21 #import "ios/chrome/browser/ui/url_loader.h" |
21 #import "ios/chrome/browser/ui/util/label_link_controller.h" | 22 #import "ios/chrome/browser/ui/util/label_link_controller.h" |
22 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" | 23 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" |
23 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 24 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
24 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 25 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
25 #include "ios/web/public/interstitials/web_interstitial.h" | 26 #include "ios/web/public/interstitials/web_interstitial.h" |
26 #include "ios/web/public/web_state/web_state.h" | 27 #include "ios/web/public/web_state/web_state.h" |
27 #import "net/base/mac/url_conversions.h" | 28 #import "net/base/mac/url_conversions.h" |
28 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
29 #include "ui/base/resource/resource_bundle.h" | |
30 #include "ui/gfx/image/image.h" | |
31 | 30 |
32 namespace { | 31 namespace { |
33 // Color constants. | 32 // Color constants. |
34 const CGFloat kBackgroundColorBrightness = 247.0f / 255.0f; | 33 const CGFloat kBackgroundColorBrightness = 247.0f / 255.0f; |
35 const CGFloat kTitleLabelTextColorBrightness = 22.0f / 255.0f; | 34 const CGFloat kTitleLabelTextColorBrightness = 22.0f / 255.0f; |
36 const CGFloat kMessageLabelTextColorBrightness = 80.0f / 255.0f; | 35 const CGFloat kMessageLabelTextColorBrightness = 80.0f / 255.0f; |
37 // Layout constants. | 36 // Layout constants. |
38 const UIEdgeInsets kLayoutInsets = {24.0f, 24.0f, 24.0f, 24.0f}; | 37 const UIEdgeInsets kLayoutInsets = {24.0f, 24.0f, 24.0f, 24.0f}; |
39 const CGFloat kLayoutBoundsMaxWidth = 600.0f; | 38 const CGFloat kLayoutBoundsMaxWidth = 600.0f; |
40 const CGFloat kContainerViewLandscapeTopPadding = 22.0f; | 39 const CGFloat kContainerViewLandscapeTopPadding = 22.0f; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 - (UIView*)containerView { | 129 - (UIView*)containerView { |
131 if (!_containerView) { | 130 if (!_containerView) { |
132 _containerView.reset([[UIView alloc] initWithFrame:CGRectZero]); | 131 _containerView.reset([[UIView alloc] initWithFrame:CGRectZero]); |
133 [_containerView setBackgroundColor:self.backgroundColor]; | 132 [_containerView setBackgroundColor:self.backgroundColor]; |
134 } | 133 } |
135 return _containerView; | 134 return _containerView; |
136 } | 135 } |
137 | 136 |
138 - (UIImageView*)imageView { | 137 - (UIImageView*)imageView { |
139 if (!_imageView) { | 138 if (!_imageView) { |
140 ui::ResourceBundle& resourceBundle = | 139 _imageView.reset( |
141 ui::ResourceBundle::GetSharedInstance(); | 140 [[UIImageView alloc] initWithImage:NativeImage(IDR_CRASH_SAD_TAB)]); |
142 UIImage* image = | |
143 resourceBundle.GetNativeImageNamed(IDR_CRASH_SAD_TAB).ToUIImage(); | |
144 _imageView.reset([[UIImageView alloc] initWithImage:image]); | |
145 [_imageView setBackgroundColor:self.backgroundColor]; | 141 [_imageView setBackgroundColor:self.backgroundColor]; |
146 } | 142 } |
147 return _imageView.get(); | 143 return _imageView.get(); |
148 } | 144 } |
149 | 145 |
150 - (UILabel*)titleLabel { | 146 - (UILabel*)titleLabel { |
151 if (!_titleLabel) { | 147 if (!_titleLabel) { |
152 _titleLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]); | 148 _titleLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]); |
153 [_titleLabel setBackgroundColor:self.backgroundColor]; | 149 [_titleLabel setBackgroundColor:self.backgroundColor]; |
154 [_titleLabel setText:base::SysUTF8ToNSString( | 150 [_titleLabel setText:base::SysUTF8ToNSString( |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 388 |
393 - (void)handleReloadButtonTapped { | 389 - (void)handleReloadButtonTapped { |
394 _reloadHandler.get()(); | 390 _reloadHandler.get()(); |
395 } | 391 } |
396 | 392 |
397 + (UIColor*)sadTabBackgroundColor { | 393 + (UIColor*)sadTabBackgroundColor { |
398 return [UIColor colorWithWhite:kBackgroundColorBrightness alpha:1.0]; | 394 return [UIColor colorWithWhite:kBackgroundColorBrightness alpha:1.0]; |
399 } | 395 } |
400 | 396 |
401 @end | 397 @end |
OLD | NEW |