OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/favicon/favicon_attributes.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/mac/objc_property_releaser.h" |
| 9 |
| 10 @implementation FaviconAttributes { |
| 11 base::mac::ObjCPropertyReleaser _propertyReleaser_FaviconAttributes; |
| 12 } |
| 13 @synthesize faviconImage = _faviconImage; |
| 14 @synthesize monogramString = _monogramString; |
| 15 @synthesize textColor = _textColor; |
| 16 @synthesize backgroundColor = _backgroundColor; |
| 17 |
| 18 - (instancetype)initWithImage:(UIImage*)image |
| 19 monogram:(NSString*)monogram |
| 20 textColor:(UIColor*)textColor |
| 21 backgroundColor:(UIColor*)backgroundColor { |
| 22 DCHECK(image || (monogram && textColor && backgroundColor)); |
| 23 self = [super init]; |
| 24 if (self) { |
| 25 _propertyReleaser_FaviconAttributes.Init(self, [FaviconAttributes class]); |
| 26 _faviconImage = [image retain]; |
| 27 _monogramString = [monogram copy]; |
| 28 _textColor = [textColor retain]; |
| 29 _backgroundColor = [backgroundColor retain]; |
| 30 } |
| 31 |
| 32 return self; |
| 33 } |
| 34 |
| 35 - (instancetype)initWithImage:(UIImage*)image { |
| 36 DCHECK(image); |
| 37 return |
| 38 [self initWithImage:image monogram:nil textColor:nil backgroundColor:nil]; |
| 39 } |
| 40 |
| 41 - (instancetype)initWithMonogram:(NSString*)monogram |
| 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] autorelease]; |
| 53 } |
| 54 |
| 55 + (instancetype)attributesWithMonogram:(NSString*)monogram |
| 56 textColor:(UIColor*)textColor |
| 57 backgroundColor:(UIColor*)backgroundColor { |
| 58 return [[[self alloc] initWithMonogram:monogram |
| 59 textColor:textColor |
| 60 backgroundColor:backgroundColor] autorelease]; |
| 61 } |
| 62 |
| 63 @end |
OLD | NEW |