| Index: ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper.mm
|
| diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper.mm b/ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cc342d5388e749ed72578d7542a0b71ce8ed872f
|
| --- /dev/null
|
| +++ b/ios/chrome/browser/content_suggestions/content_suggestions_category_wrapper.mm
|
| @@ -0,0 +1,64 @@
|
| +// Copyright 2017 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/content_suggestions/content_suggestions_category_wrapper.h"
|
| +
|
| +#include "base/mac/foundation_util.h"
|
| +
|
| +#if !defined(__has_feature) || !__has_feature(objc_arc)
|
| +#error "This file requires ARC support."
|
| +#endif
|
| +
|
| +@interface ContentSuggestionsCategoryWrapper ()
|
| +
|
| +@property(nonatomic, assign) int categoryID;
|
| +
|
| +@end
|
| +
|
| +@implementation ContentSuggestionsCategoryWrapper
|
| +
|
| +@synthesize categoryID = _categoryID;
|
| +
|
| +- (instancetype)initWithCategory:(ntp_snippets::Category)category {
|
| + self = [super init];
|
| + if (self) {
|
| + _categoryID = category.id();
|
| + }
|
| + return self;
|
| +}
|
| +
|
| +- (ntp_snippets::Category)category {
|
| + return ntp_snippets::Category::FromIDValue(self.categoryID);
|
| +}
|
| +
|
| +#pragma mark - NSObject
|
| +
|
| +- (BOOL)isEqual:(id)object {
|
| + if (self == object) {
|
| + return YES;
|
| + }
|
| +
|
| + if (![object isKindOfClass:[ContentSuggestionsCategoryWrapper class]]) {
|
| + return NO;
|
| + }
|
| +
|
| + ContentSuggestionsCategoryWrapper* other =
|
| + base::mac::ObjCCastStrict<ContentSuggestionsCategoryWrapper>(object);
|
| +
|
| + return self.category == other.category;
|
| +}
|
| +
|
| +- (NSUInteger)hash {
|
| + return self.categoryID;
|
| +}
|
| +
|
| +#pragma mark - NSCopying
|
| +
|
| +- (id)copyWithZone:(nullable NSZone*)zone {
|
| + ContentSuggestionsCategoryWrapper* copy =
|
| + [[[self class] allocWithZone:zone] initWithCategory:self.category];
|
| + return copy;
|
| +}
|
| +
|
| +@end
|
|
|