| Index: ios/web_view/internal/translate/cwv_translation_policy.mm
|
| diff --git a/ios/web_view/internal/translate/cwv_translation_policy.mm b/ios/web_view/internal/translate/cwv_translation_policy.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..312481046b1273b4b465af95488c172d48a9a985
|
| --- /dev/null
|
| +++ b/ios/web_view/internal/translate/cwv_translation_policy.mm
|
| @@ -0,0 +1,51 @@
|
| +// 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/web_view/public/cwv_translation_policy.h"
|
| +
|
| +#import "ios/web_view/public/cwv_translation_language.h"
|
| +
|
| +#if !defined(__has_feature) || !__has_feature(objc_arc)
|
| +#error "This file requires ARC support."
|
| +#endif
|
| +
|
| +@interface CWVTranslationPolicy ()
|
| +// Internal initializer.
|
| +- (instancetype)initWithType:(CWVTranslationPolicyType)type
|
| + language:(CWVTranslationLanguage*)language
|
| + NS_DESIGNATED_INITIALIZER;
|
| +@end
|
| +
|
| +@implementation CWVTranslationPolicy
|
| +
|
| +@synthesize language = _language;
|
| +@synthesize type = _type;
|
| +
|
| +- (instancetype)initWithType:(CWVTranslationPolicyType)type
|
| + language:(CWVTranslationLanguage*)language {
|
| + self = [super init];
|
| + if (self) {
|
| + _type = type;
|
| + _language = language;
|
| + }
|
| + return self;
|
| +}
|
| +
|
| ++ (CWVTranslationPolicy*)translationPolicyAsk {
|
| + return [[CWVTranslationPolicy alloc] initWithType:CWVTranslationPolicyAsk
|
| + language:nil];
|
| +}
|
| +
|
| ++ (CWVTranslationPolicy*)translationPolicyNever {
|
| + return [[CWVTranslationPolicy alloc] initWithType:CWVTranslationPolicyNever
|
| + language:nil];
|
| +}
|
| +
|
| ++ (CWVTranslationPolicy*)translationPolicyAutoTranslateToLanguage:
|
| + (CWVTranslationLanguage*)language {
|
| + return [[CWVTranslationPolicy alloc] initWithType:CWVTranslationPolicyAuto
|
| + language:language];
|
| +}
|
| +
|
| +@end
|
|
|