Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: ios/chrome/browser/ui/page_not_available_controller.mm

Issue 2610923005: Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: weak -> assign Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/page_not_available_controller.h" 5 #import "ios/chrome/browser/ui/page_not_available_controller.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/mac/objc_property_releaser.h" 9 #include "base/mac/objc_release_properties.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 "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "components/strings/grit/components_strings.h" 13 #include "components/strings/grit/components_strings.h"
14 #include "components/url_formatter/url_formatter.h" 14 #include "components/url_formatter/url_formatter.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/l10n/l10n_util_mac.h" 16 #include "ui/base/l10n/l10n_util_mac.h"
17 17
18 namespace { 18 namespace {
19 // Top padding for |self.titleLabel|. 19 // Top padding for |self.titleLabel|.
20 const CGFloat kTitleLabelTopPadding = 20.0; 20 const CGFloat kTitleLabelTopPadding = 20.0;
21 // Height for |self.titleLabel|. 21 // Height for |self.titleLabel|.
22 const CGFloat kTitleLabelHeight = 38.0; 22 const CGFloat kTitleLabelHeight = 38.0;
23 // Top padding for |self.descriptionView|. 23 // Top padding for |self.descriptionView|.
24 const CGFloat kDescriptionViewTopPadding = 66.0; 24 const CGFloat kDescriptionViewTopPadding = 66.0;
25 // Bottom padding for |self.descriptionView|. 25 // Bottom padding for |self.descriptionView|.
26 const CGFloat kDescriptionViewBottomPadding = 20.0; 26 const CGFloat kDescriptionViewBottomPadding = 20.0;
27 // Horizontal padding between subviews and |self.view|. 27 // Horizontal padding between subviews and |self.view|.
28 const CGFloat kHorizontalPadding = 20.0; 28 const CGFloat kHorizontalPadding = 20.0;
29 // Font size for |self.titleLabel|. 29 // Font size for |self.titleLabel|.
30 const CGFloat kTitleLabelFontSize = 18.0; 30 const CGFloat kTitleLabelFontSize = 18.0;
31 // Font size for |self.descriptionView|. 31 // Font size for |self.descriptionView|.
32 const CGFloat kDescriptionViewFontSize = 17.0; 32 const CGFloat kDescriptionViewFontSize = 17.0;
33 } 33 }
34 34
35 @interface PageNotAvailableController () { 35 @interface PageNotAvailableController ()
36 base::mac::ObjCPropertyReleaser _propertyReleaser_PageNotAvailableController;
37 }
38 36
39 // The title label displayed centered at the top of the screen. 37 // The title label displayed centered at the top of the screen.
40 @property(nonatomic, retain) UILabel* titleLabel; 38 @property(nonatomic, retain) UILabel* titleLabel;
41 39
42 // TextView containing a detailed description of the problem. 40 // TextView containing a detailed description of the problem.
43 @property(nonatomic, retain) UITextView* descriptionView; 41 @property(nonatomic, retain) UITextView* descriptionView;
44 42
45 @end 43 @end
46 44
47 @implementation PageNotAvailableController 45 @implementation PageNotAvailableController
48 46
49 @synthesize titleLabel = _titleLabel; 47 @synthesize titleLabel = _titleLabel;
50 @synthesize descriptionView = _descriptionView; 48 @synthesize descriptionView = _descriptionView;
51 @synthesize descriptionText = _descriptionText; 49 @synthesize descriptionText = _descriptionText;
52 50
53 - (instancetype)initWithUrl:(const GURL&)url { 51 - (instancetype)initWithUrl:(const GURL&)url {
54 self = [super initWithNibName:nil url:url]; 52 self = [super initWithNibName:nil url:url];
55 if (self) { 53 if (self) {
56 _propertyReleaser_PageNotAvailableController.Init(
57 self, [PageNotAvailableController class]);
58
59 // Use the host as the page title, unless the URL has a custom scheme. 54 // Use the host as the page title, unless the URL has a custom scheme.
60 if (self.url.SchemeIsHTTPOrHTTPS()) { 55 if (self.url.SchemeIsHTTPOrHTTPS()) {
61 self.title = base::SysUTF16ToNSString( 56 self.title = base::SysUTF16ToNSString(
62 url_formatter::IDNToUnicode(self.url.host())); 57 url_formatter::IDNToUnicode(self.url.host()));
63 } else { 58 } else {
64 base::string16 formattedURL = url_formatter::FormatUrl( 59 base::string16 formattedURL = url_formatter::FormatUrl(
65 self.url, url_formatter::kFormatUrlOmitNothing, 60 self.url, url_formatter::kFormatUrlOmitNothing,
66 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr); 61 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr);
67 if (base::i18n::IsRTL()) { 62 if (base::i18n::IsRTL()) {
68 base::i18n::WrapStringWithLTRFormatting(&formattedURL); 63 base::i18n::WrapStringWithLTRFormatting(&formattedURL);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 base::UTF8ToUTF16(self.url.spec())); 104 base::UTF8ToUTF16(self.url.spec()));
110 _descriptionView.autoresizingMask = 105 _descriptionView.autoresizingMask =
111 UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 106 UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
112 _descriptionView.font = [UIFont systemFontOfSize:kDescriptionViewFontSize]; 107 _descriptionView.font = [UIFont systemFontOfSize:kDescriptionViewFontSize];
113 _descriptionView.editable = NO; 108 _descriptionView.editable = NO;
114 [self.view addSubview:_descriptionView]; 109 [self.view addSubview:_descriptionView];
115 } 110 }
116 return self; 111 return self;
117 } 112 }
118 113
114 - (void)dealloc {
115 base::mac::ReleaseProperties(self);
116 [super dealloc];
117 }
118
119 - (instancetype)initWithNibName:(NSString*)nibName 119 - (instancetype)initWithNibName:(NSString*)nibName
120 url:(const GURL&)url NS_UNAVAILABLE { 120 url:(const GURL&)url NS_UNAVAILABLE {
121 NOTREACHED(); 121 NOTREACHED();
122 return nil; 122 return nil;
123 } 123 }
124 124
125 - (void)setDescriptionText:(NSString*)descriptionText { 125 - (void)setDescriptionText:(NSString*)descriptionText {
126 _descriptionText = descriptionText; 126 _descriptionText = descriptionText;
127 _descriptionView.text = descriptionText; 127 _descriptionView.text = descriptionText;
128 } 128 }
129 129
130 @end 130 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698