Chromium Code Reviews| Index: ios/chrome/browser/favicon/favicon_attributes.mm |
| diff --git a/ios/chrome/browser/favicon/favicon_attributes.mm b/ios/chrome/browser/favicon/favicon_attributes.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b843163263dfaf1adb801c401f074255be636f42 |
| --- /dev/null |
| +++ b/ios/chrome/browser/favicon/favicon_attributes.mm |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "ios/chrome/browser/favicon/favicon_attributes.h" |
| + |
| +#include "base/logging.h" |
| + |
| +@implementation FaviconAttributes |
| +@synthesize faviconImage = _faviconImage; |
| +@synthesize monogramString = _monogramString; |
| +@synthesize textColor = _textColor; |
| +@synthesize backgroundColor = _backgroundColor; |
| + |
| +- (instancetype)initWithImage:(UIImage*)image |
| + monogram:(NSString*)monogram |
| + textColor:(UIColor*)textColor |
| + backgroundColor:(UIColor*)backgroundColor { |
| + DCHECK(image || (monogram && textColor && backgroundColor)); |
| + self = [super init]; |
| + if (self) { |
| + _faviconImage = [image retain]; |
| + _monogramString = [monogram copy]; |
| + _textColor = [textColor retain]; |
| + _backgroundColor = [backgroundColor retain]; |
| + } |
| + |
| + return self; |
| +} |
| + |
| +- (instancetype)initWithImage:(UIImage* _Nonnull)image { |
| + DCHECK(image); |
| + return |
| + [self initWithImage:image monogram:nil textColor:nil backgroundColor:nil]; |
| +} |
| + |
| +- (instancetype)initWithMonogram:(NSString* _Nonnull)monogram |
| + textColor:(UIColor* _Nonnull)textColor |
| + backgroundColor:(UIColor* _Nonnull)backgroundColor { |
| + DCHECK(monogram && textColor && backgroundColor); |
| + return [self initWithImage:nil |
| + monogram:monogram |
| + textColor:textColor |
| + backgroundColor:backgroundColor]; |
| +} |
| + |
| ++ (instancetype)attributesWithImage:(UIImage* _Nonnull)image { |
| + return [[[self alloc] initWithImage:image] autorelease]; |
| +} |
| + |
| ++ (instancetype)attributesWithMonogram:(NSString* _Nonnull)monogram |
| + textColor:(UIColor* _Nonnull)textColor |
| + backgroundColor:(UIColor* _Nonnull)backgroundColor { |
| + return [[[self alloc] initWithMonogram:monogram |
| + textColor:textColor |
| + backgroundColor:backgroundColor] autorelease]; |
| +} |
| + |
| +- (void)dealloc { |
| + [_faviconImage release]; |
|
jif
2016/09/26 10:58:13
We are supposed to use an ObjCPropertyReleaser
stkhapugin
2016/09/26 15:51:36
Done.
|
| + [_monogramString release]; |
| + [_textColor release]; |
| + [_backgroundColor release]; |
| + [super dealloc]; |
| +} |
| + |
| +@end |