Chromium Code Reviews| 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..475a0811e702273d9b45811832a25b293245bf60 |
| --- /dev/null |
| +++ b/ios/web_view/internal/translate/cwv_translation_policy.mm |
| @@ -0,0 +1,38 @@ |
| +// 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 |
| + |
| +@implementation CWVTranslationPolicy |
| + |
| +@synthesize language = _language; |
| +@synthesize type = _type; |
| + |
| ++ (CWVTranslationPolicy*)translationPolicyAsk { |
| + CWVTranslationPolicy* policy = [[CWVTranslationPolicy alloc] init]; |
| + policy->_type = CWVTranslationPolicyAsk; |
|
Eugene But (OOO till 7-30)
2017/05/11 15:48:59
alloc/init can return null and this will crash. Do
jzw1
2017/05/12 03:46:46
Done.
|
| + return policy; |
| +} |
| + |
| ++ (CWVTranslationPolicy*)translationPolicyNever { |
| + CWVTranslationPolicy* policy = [[CWVTranslationPolicy alloc] init]; |
| + policy->_type = CWVTranslationPolicyNever; |
|
michaeldo
2017/05/11 23:51:33
Can you use synthesized setters instead? I don't k
jzw1
2017/05/12 03:46:46
Done.
|
| + return policy; |
| +} |
| + |
| ++ (CWVTranslationPolicy*)translationPolicyAutoTranslateToLanguage: |
| + (CWVTranslationLanguage*)language { |
| + CWVTranslationPolicy* policy = [[CWVTranslationPolicy alloc] init]; |
| + policy->_type = CWVTranslationPolicyAuto; |
| + policy->_language = language; |
| + return policy; |
| +} |
| + |
| +@end |