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 | |
9 @implementation FaviconAttributes | |
10 @synthesize faviconImage = _faviconImage; | |
11 @synthesize monogramString = _monogramString; | |
12 @synthesize textColor = _textColor; | |
13 @synthesize backgroundColor = _backgroundColor; | |
14 | |
15 - (instancetype)initWithImage:(UIImage*)image | |
16 monogram:(NSString*)monogram | |
17 textColor:(UIColor*)textColor | |
18 backgroundColor:(UIColor*)backgroundColor { | |
19 DCHECK(image || (monogram && textColor && backgroundColor)); | |
20 self = [super init]; | |
21 if (self) { | |
22 _faviconImage = [image retain]; | |
23 _monogramString = [monogram copy]; | |
24 _textColor = [textColor retain]; | |
25 _backgroundColor = [backgroundColor retain]; | |
26 } | |
27 | |
28 return self; | |
29 } | |
30 | |
31 - (instancetype)initWithImage:(UIImage* _Nonnull)image { | |
32 DCHECK(image); | |
33 return | |
34 [self initWithImage:image monogram:nil textColor:nil backgroundColor:nil]; | |
35 } | |
36 | |
37 - (instancetype)initWithMonogram:(NSString* _Nonnull)monogram | |
38 textColor:(UIColor* _Nonnull)textColor | |
39 backgroundColor:(UIColor* _Nonnull)backgroundColor { | |
40 DCHECK(monogram && textColor && backgroundColor); | |
41 return [self initWithImage:nil | |
42 monogram:monogram | |
43 textColor:textColor | |
44 backgroundColor:backgroundColor]; | |
45 } | |
46 | |
47 + (instancetype)attributesWithImage:(UIImage* _Nonnull)image { | |
48 return [[[self alloc] initWithImage:image] autorelease]; | |
49 } | |
50 | |
51 + (instancetype)attributesWithMonogram:(NSString* _Nonnull)monogram | |
52 textColor:(UIColor* _Nonnull)textColor | |
53 backgroundColor:(UIColor* _Nonnull)backgroundColor { | |
54 return [[[self alloc] initWithMonogram:monogram | |
55 textColor:textColor | |
56 backgroundColor:backgroundColor] autorelease]; | |
57 } | |
58 | |
59 - (void)dealloc { | |
60 [_faviconImage release]; | |
jif
2016/09/26 10:58:13
We are supposed to use an ObjCPropertyReleaser
stkhapugin
2016/09/26 15:51:36
Done.
| |
61 [_monogramString release]; | |
62 [_textColor release]; | |
63 [_backgroundColor release]; | |
64 [super dealloc]; | |
65 } | |
66 | |
67 @end | |
OLD | NEW |