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

Side by Side Diff: ios/chrome/app/safe_mode/safe_mode_view_controller.mm

Issue 2915043003: [ObjC ARC] Converts ios/chrome/app/safe_mode:safe_mode to ARC. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « ios/chrome/app/safe_mode/safe_mode_coordinator.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app/safe_mode/safe_mode_view_controller.h" 5 #import "ios/chrome/app/safe_mode/safe_mode_view_controller.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #import "ios/chrome/app/safe_mode_crashing_modules_config.h" 10 #import "ios/chrome/app/safe_mode_crashing_modules_config.h"
11 #import "ios/chrome/app/safe_mode_util.h" 11 #import "ios/chrome/app/safe_mode_util.h"
12 #include "ios/chrome/browser/crash_report/breakpad_helper.h" 12 #include "ios/chrome/browser/crash_report/breakpad_helper.h"
13 #import "ios/chrome/browser/ui/fancy_ui/primary_action_button.h" 13 #import "ios/chrome/browser/ui/fancy_ui/primary_action_button.h"
14 #include "ios/chrome/browser/ui/ui_util.h" 14 #include "ios/chrome/browser/ui/ui_util.h"
15 #import "ios/chrome/browser/ui/uikit_ui_util.h" 15 #import "ios/chrome/browser/ui/uikit_ui_util.h"
16 #include "ios/chrome/grit/ios_chromium_strings.h" 16 #include "ios/chrome/grit/ios_chromium_strings.h"
17 #import "ui/gfx/ios/NSString+CrStringDrawing.h" 17 #import "ui/gfx/ios/NSString+CrStringDrawing.h"
18 18
19 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support."
21 #endif
22
19 namespace { 23 namespace {
20 const CGFloat kVerticalSpacing = 20; 24 const CGFloat kVerticalSpacing = 20;
21 const CGFloat kUploadProgressSpacing = 5; 25 const CGFloat kUploadProgressSpacing = 5;
22 const NSTimeInterval kUploadPumpInterval = 0.1; 26 const NSTimeInterval kUploadPumpInterval = 0.1;
23 const NSTimeInterval kUploadTotalTime = 5; 27 const NSTimeInterval kUploadTotalTime = 5;
24 } // anonymous namespace 28 } // anonymous namespace
25 29
26 @interface SafeModeViewController () 30 @interface SafeModeViewController ()
27 // Returns |YES| if any third-party modifications are detected. 31 // Returns |YES| if any third-party modifications are detected.
28 + (BOOL)detectedThirdPartyMods; 32 + (BOOL)detectedThirdPartyMods;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 CGRect mainBounds = [[UIScreen mainScreen] bounds]; 136 CGRect mainBounds = [[UIScreen mainScreen] bounds];
133 // SafeModeViewController only supports portrait orientation (see 137 // SafeModeViewController only supports portrait orientation (see
134 // implementation of supportedInterfaceOrientations: below) but if the app is 138 // implementation of supportedInterfaceOrientations: below) but if the app is
135 // launched from landscape mode (e.g. iPad or iPhone 6+) then the mainScreen's 139 // launched from landscape mode (e.g. iPad or iPhone 6+) then the mainScreen's
136 // bounds will still be landscape at this point. Swap the height and width 140 // bounds will still be landscape at this point. Swap the height and width
137 // here so that the dimensions will be correct once the app rotates to 141 // here so that the dimensions will be correct once the app rotates to
138 // portrait. 142 // portrait.
139 if (IsLandscape()) { 143 if (IsLandscape()) {
140 mainBounds.size = CGSizeMake(mainBounds.size.height, mainBounds.size.width); 144 mainBounds.size = CGSizeMake(mainBounds.size.height, mainBounds.size.width);
141 } 145 }
142 base::scoped_nsobject<UIScrollView> scrollView( 146 UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:mainBounds];
143 [[UIScrollView alloc] initWithFrame:mainBounds]);
144 self.view = scrollView; 147 self.view = scrollView;
145 [self.view setBackgroundColor:[UIColor colorWithWhite:0.902 alpha:1.0]]; 148 [self.view setBackgroundColor:[UIColor colorWithWhite:0.902 alpha:1.0]];
146 const CGFloat kIPadInset = 149 const CGFloat kIPadInset =
147 (mainBounds.size.width - kIPadWidth - kHorizontalSpacing) / 2; 150 (mainBounds.size.width - kIPadWidth - kHorizontalSpacing) / 2;
148 const CGFloat widthInset = IsIPadIdiom() ? kIPadInset : kHorizontalSpacing; 151 const CGFloat widthInset = IsIPadIdiom() ? kIPadInset : kHorizontalSpacing;
149 innerView_.reset([[UIView alloc] 152 innerView_.reset([[UIView alloc]
150 initWithFrame:CGRectInset(mainBounds, widthInset, kVerticalSpacing * 2)]); 153 initWithFrame:CGRectInset(mainBounds, widthInset, kVerticalSpacing * 2)]);
151 [innerView_ setBackgroundColor:[UIColor whiteColor]]; 154 [innerView_ setBackgroundColor:[UIColor whiteColor]];
152 [innerView_ layer].cornerRadius = 3; 155 [innerView_ layer].cornerRadius = 3;
153 [innerView_ layer].borderWidth = 1; 156 [innerView_ layer].borderWidth = 1;
154 [innerView_ layer].borderColor = 157 [innerView_ layer].borderColor =
155 [UIColor colorWithWhite:0.851 alpha:1.0].CGColor; 158 [UIColor colorWithWhite:0.851 alpha:1.0].CGColor;
156 [innerView_ layer].masksToBounds = YES; 159 [innerView_ layer].masksToBounds = YES;
157 [scrollView addSubview:innerView_]; 160 [scrollView addSubview:innerView_];
158 161
159 UIImage* fatalImage = [UIImage imageNamed:@"fatal_error.png"]; 162 UIImage* fatalImage = [UIImage imageNamed:@"fatal_error.png"];
160 base::scoped_nsobject<UIImageView> imageView( 163 UIImageView* imageView = [[UIImageView alloc] initWithImage:fatalImage];
161 [[UIImageView alloc] initWithImage:fatalImage]);
162 // Shift the image down a bit. 164 // Shift the image down a bit.
163 CGRect imageFrame = [imageView frame]; 165 CGRect imageFrame = [imageView frame];
164 imageFrame.origin.y = kVerticalSpacing; 166 imageFrame.origin.y = kVerticalSpacing;
165 [imageView setFrame:imageFrame]; 167 [imageView setFrame:imageFrame];
166 [self centerView:imageView afterView:nil]; 168 [self centerView:imageView afterView:nil];
167 [innerView_ addSubview:imageView]; 169 [innerView_ addSubview:imageView];
168 170
169 base::scoped_nsobject<UILabel> awSnap([[UILabel alloc] init]); 171 UILabel* awSnap = [[UILabel alloc] init];
170 [awSnap setText:NSLocalizedString(@"IDS_IOS_SAFE_MODE_AW_SNAP", @"")]; 172 [awSnap setText:NSLocalizedString(@"IDS_IOS_SAFE_MODE_AW_SNAP", @"")];
171 [awSnap setBackgroundColor:[UIColor clearColor]]; 173 [awSnap setBackgroundColor:[UIColor clearColor]];
172 [awSnap setTextColor:[UIColor blackColor]]; 174 [awSnap setTextColor:[UIColor blackColor]];
173 [awSnap setFont:[UIFont boldSystemFontOfSize:21]]; 175 [awSnap setFont:[UIFont boldSystemFontOfSize:21]];
174 [awSnap sizeToFit]; 176 [awSnap sizeToFit];
175 [self centerView:awSnap afterView:imageView]; 177 [self centerView:awSnap afterView:imageView];
176 [innerView_ addSubview:awSnap]; 178 [innerView_ addSubview:awSnap];
177 179
178 base::scoped_nsobject<UILabel> description([[UILabel alloc] init]); 180 UILabel* description = [[UILabel alloc] init];
179 [description setText:[self startupCrashModuleText]]; 181 [description setText:[self startupCrashModuleText]];
180 [description setBackgroundColor:[UIColor clearColor]]; 182 [description setBackgroundColor:[UIColor clearColor]];
181 [description setTextColor:[UIColor colorWithWhite:0.31 alpha:1.0]]; 183 [description setTextColor:[UIColor colorWithWhite:0.31 alpha:1.0]];
182 [description setTextAlignment:NSTextAlignmentCenter]; 184 [description setTextAlignment:NSTextAlignmentCenter];
183 [description setNumberOfLines:0]; 185 [description setNumberOfLines:0];
184 [description setLineBreakMode:NSLineBreakByWordWrapping]; 186 [description setLineBreakMode:NSLineBreakByWordWrapping];
185 CGRect frame = [description frame]; 187 CGRect frame = [description frame];
186 frame.size.width = IsIPadIdiom() ? kIPadWidth : kIPhoneWidth; 188 frame.size.width = IsIPadIdiom() ? kIPadWidth : kIPhoneWidth;
187 CGSize maxSize = CGSizeMake(frame.size.width, 999999.0f); 189 CGSize maxSize = CGSizeMake(frame.size.width, 999999.0f);
188 frame.size.height = 190 frame.size.height =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 [scrollView setContentSize:scrollSize]; 260 [scrollView setContentSize:scrollSize];
259 } 261 }
260 262
261 - (NSUInteger)supportedInterfaceOrientations { 263 - (NSUInteger)supportedInterfaceOrientations {
262 return UIInterfaceOrientationMaskPortrait; 264 return UIInterfaceOrientationMaskPortrait;
263 } 265 }
264 266
265 #pragma mark - Private 267 #pragma mark - Private
266 268
267 - (void)startUploadProgress { 269 - (void)startUploadProgress {
268 uploadStartTime_.reset([[NSDate date] retain]); 270 uploadStartTime_.reset([NSDate date]);
rohitrao (ping after 24h) 2017/06/05 14:33:13 Could all of these ivars move out of the header (a
stkhapugin 2017/06/15 16:26:48 Done
269 uploadTimer_.reset( 271 uploadTimer_.reset([NSTimer
270 [[NSTimer scheduledTimerWithTimeInterval:kUploadPumpInterval 272 scheduledTimerWithTimeInterval:kUploadPumpInterval
271 target:self 273 target:self
272 selector:@selector(pumpUploadProgress) 274 selector:@selector(pumpUploadProgress)
273 userInfo:nil 275 userInfo:nil
274 repeats:YES] retain]); 276 repeats:YES]);
275 } 277 }
276 278
277 - (void)pumpUploadProgress { 279 - (void)pumpUploadProgress {
278 NSTimeInterval elapsed = 280 NSTimeInterval elapsed =
279 [[NSDate date] timeIntervalSinceDate:uploadStartTime_]; 281 [[NSDate date] timeIntervalSinceDate:uploadStartTime_];
280 // Theoretically we could stop early when the value returned by 282 // Theoretically we could stop early when the value returned by
281 // ios_internal::breakpad::GetCrashReportCount() changes, but this is 283 // ios_internal::breakpad::GetCrashReportCount() changes, but this is
282 // simpler. If we decide to look for a change in crash report count, then we 284 // simpler. If we decide to look for a change in crash report count, then we
283 // also probably want to replace the UIProgressView with a 285 // also probably want to replace the UIProgressView with a
284 // UIActivityIndicatorView. 286 // UIActivityIndicatorView.
(...skipping 11 matching lines...) Expand all
296 [uploadProgress_ setHidden:YES]; 298 [uploadProgress_ setHidden:YES];
297 } 299 }
298 } 300 }
299 301
300 - (void)startBrowserFromSafeMode { 302 - (void)startBrowserFromSafeMode {
301 breakpad_helper::RestoreDefaultConfiguration(); 303 breakpad_helper::RestoreDefaultConfiguration();
302 [delegate_ startBrowserFromSafeMode]; 304 [delegate_ startBrowserFromSafeMode];
303 } 305 }
304 306
305 @end 307 @end
OLDNEW
« no previous file with comments | « ios/chrome/app/safe_mode/safe_mode_coordinator.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698