OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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/web_view/public/cwv_translation_policy.h" |
| 6 |
| 7 #import "ios/web_view/public/cwv_translation_language.h" |
| 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." |
| 11 #endif |
| 12 |
| 13 @interface CWVTranslationPolicy () |
| 14 // Internal initializer. |
| 15 - (instancetype)initWithType:(CWVTranslationPolicyType)type |
| 16 language:(CWVTranslationLanguage*)language |
| 17 NS_DESIGNATED_INITIALIZER; |
| 18 @end |
| 19 |
| 20 @implementation CWVTranslationPolicy |
| 21 |
| 22 @synthesize language = _language; |
| 23 @synthesize type = _type; |
| 24 |
| 25 - (instancetype)initWithType:(CWVTranslationPolicyType)type |
| 26 language:(CWVTranslationLanguage*)language { |
| 27 self = [super init]; |
| 28 if (self) { |
| 29 _type = type; |
| 30 _language = language; |
| 31 } |
| 32 return self; |
| 33 } |
| 34 |
| 35 + (CWVTranslationPolicy*)translationPolicyAsk { |
| 36 return [[CWVTranslationPolicy alloc] initWithType:CWVTranslationPolicyAsk |
| 37 language:nil]; |
| 38 } |
| 39 |
| 40 + (CWVTranslationPolicy*)translationPolicyNever { |
| 41 return [[CWVTranslationPolicy alloc] initWithType:CWVTranslationPolicyNever |
| 42 language:nil]; |
| 43 } |
| 44 |
| 45 + (CWVTranslationPolicy*)translationPolicyAutoTranslateToLanguage: |
| 46 (CWVTranslationLanguage*)language { |
| 47 return [[CWVTranslationPolicy alloc] initWithType:CWVTranslationPolicyAuto |
| 48 language:language]; |
| 49 } |
| 50 |
| 51 @end |
OLD | NEW |