| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/favicon/favicon_attributes.h" | 5 #import "ios/chrome/browser/ui/favicon/favicon_attributes.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) | 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." | 10 #error "This file requires ARC support." |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 @implementation FaviconAttributes | 13 @implementation FaviconAttributes |
| 14 @synthesize faviconImage = _faviconImage; | 14 @synthesize faviconImage = _faviconImage; |
| 15 @synthesize monogramString = _monogramString; | 15 @synthesize monogramString = _monogramString; |
| 16 @synthesize textColor = _textColor; | 16 @synthesize textColor = _textColor; |
| 17 @synthesize backgroundColor = _backgroundColor; | 17 @synthesize backgroundColor = _backgroundColor; |
| 18 @synthesize defaultBackgroundColor = _defaultBackgroundColor; |
| 18 | 19 |
| 20 // Designated initializer. Either |image| or all of |textColor|, |
| 21 // |backgroundColor| and |monogram| must be not nil. |
| 19 - (instancetype)initWithImage:(UIImage*)image | 22 - (instancetype)initWithImage:(UIImage*)image |
| 20 monogram:(NSString*)monogram | 23 monogram:(NSString*)monogram |
| 21 textColor:(UIColor*)textColor | 24 textColor:(UIColor*)textColor |
| 22 backgroundColor:(UIColor*)backgroundColor { | 25 backgroundColor:(UIColor*)backgroundColor |
| 26 defaultBackgroundColor:(BOOL)defaultBackgroundColor { |
| 23 DCHECK(image || (monogram && textColor && backgroundColor)); | 27 DCHECK(image || (monogram && textColor && backgroundColor)); |
| 24 self = [super init]; | 28 self = [super init]; |
| 25 if (self) { | 29 if (self) { |
| 26 _faviconImage = image; | 30 _faviconImage = image; |
| 27 _monogramString = [monogram copy]; | 31 _monogramString = [monogram copy]; |
| 28 _textColor = textColor; | 32 _textColor = textColor; |
| 29 _backgroundColor = backgroundColor; | 33 _backgroundColor = backgroundColor; |
| 34 _defaultBackgroundColor = defaultBackgroundColor; |
| 30 } | 35 } |
| 31 | 36 |
| 32 return self; | 37 return self; |
| 33 } | 38 } |
| 34 | 39 |
| 35 - (instancetype)initWithImage:(UIImage*)image { | 40 + (instancetype)attributesWithImage:(UIImage*)image { |
| 36 DCHECK(image); | 41 DCHECK(image); |
| 37 return | 42 return [[self alloc] initWithImage:image |
| 38 [self initWithImage:image monogram:nil textColor:nil backgroundColor:nil]; | 43 monogram:nil |
| 39 } | 44 textColor:nil |
| 40 | 45 backgroundColor:nil |
| 41 - (instancetype)initWithMonogram:(NSString*)monogram | 46 defaultBackgroundColor:NO]; |
| 42 textColor:(UIColor*)textColor | |
| 43 backgroundColor:(UIColor*)backgroundColor { | |
| 44 DCHECK(monogram && textColor && backgroundColor); | |
| 45 return [self initWithImage:nil | |
| 46 monogram:monogram | |
| 47 textColor:textColor | |
| 48 backgroundColor:backgroundColor]; | |
| 49 } | |
| 50 | |
| 51 + (instancetype)attributesWithImage:(UIImage*)image { | |
| 52 return [[self alloc] initWithImage:image]; | |
| 53 } | 47 } |
| 54 | 48 |
| 55 + (instancetype)attributesWithMonogram:(NSString*)monogram | 49 + (instancetype)attributesWithMonogram:(NSString*)monogram |
| 56 textColor:(UIColor*)textColor | 50 textColor:(UIColor*)textColor |
| 57 backgroundColor:(UIColor*)backgroundColor { | 51 backgroundColor:(UIColor*)backgroundColor |
| 58 return [[self alloc] initWithMonogram:monogram | 52 defaultBackgroundColor:(BOOL)defaultBackgroundColor { |
| 59 textColor:textColor | 53 return [[self alloc] initWithImage:nil |
| 60 backgroundColor:backgroundColor]; | 54 monogram:monogram |
| 55 textColor:textColor |
| 56 backgroundColor:backgroundColor |
| 57 defaultBackgroundColor:defaultBackgroundColor]; |
| 61 } | 58 } |
| 62 | 59 |
| 63 @end | 60 @end |
| OLD | NEW |