| 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/settings/bar_button_activity_indicator.h" | 5 #import "ios/chrome/browser/ui/settings/bar_button_activity_indicator.h" |
| 6 | 6 |
| 7 #import "base/mac/scoped_nsobject.h" | |
| 8 #include "ios/chrome/browser/ui/ui_util.h" | 7 #include "ios/chrome/browser/ui/ui_util.h" |
| 9 | 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." |
| 11 #endif |
| 12 |
| 10 @implementation BarButtonActivityIndicator { | 13 @implementation BarButtonActivityIndicator { |
| 11 base::scoped_nsobject<UIActivityIndicatorView> activityIndicator_; | 14 UIActivityIndicatorView* activityIndicator_; |
| 12 } | 15 } |
| 13 | 16 |
| 14 - (id)initWithFrame:(CGRect)frame { | 17 - (id)initWithFrame:(CGRect)frame { |
| 15 self = [super initWithFrame:frame]; | 18 self = [super initWithFrame:frame]; |
| 16 if (self) { | 19 if (self) { |
| 17 activityIndicator_.reset([[UIActivityIndicatorView alloc] | 20 activityIndicator_ = [[UIActivityIndicatorView alloc] |
| 18 initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]); | 21 initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; |
| 19 [activityIndicator_ setBackgroundColor:[UIColor clearColor]]; | 22 [activityIndicator_ setBackgroundColor:[UIColor clearColor]]; |
| 20 [activityIndicator_ setHidesWhenStopped:YES]; | 23 [activityIndicator_ setHidesWhenStopped:YES]; |
| 21 [activityIndicator_ startAnimating]; | 24 [activityIndicator_ startAnimating]; |
| 22 [self addSubview:activityIndicator_]; | 25 [self addSubview:activityIndicator_]; |
| 23 } | 26 } |
| 24 return self; | 27 return self; |
| 25 } | 28 } |
| 26 | 29 |
| 27 - (void)dealloc { | 30 - (void)dealloc { |
| 28 [activityIndicator_ stopAnimating]; | 31 [activityIndicator_ stopAnimating]; |
| 29 [super dealloc]; | |
| 30 } | 32 } |
| 31 | 33 |
| 32 - (void)layoutSubviews { | 34 - (void)layoutSubviews { |
| 33 [super layoutSubviews]; | 35 [super layoutSubviews]; |
| 34 CGSize boundsSize = self.bounds.size; | 36 CGSize boundsSize = self.bounds.size; |
| 35 CGPoint center = CGPointMake(boundsSize.width / 2, boundsSize.height / 2); | 37 CGPoint center = CGPointMake(boundsSize.width / 2, boundsSize.height / 2); |
| 36 [activityIndicator_ setCenter:AlignPointToPixel(center)]; | 38 [activityIndicator_ setCenter:AlignPointToPixel(center)]; |
| 37 } | 39 } |
| 38 | 40 |
| 39 @end | 41 @end |
| OLD | NEW |