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 @implementation CWVTranslationPolicy | |
14 | |
15 @synthesize language = _language; | |
16 @synthesize type = _type; | |
17 | |
18 + (CWVTranslationPolicy*)translationPolicyAsk { | |
19 CWVTranslationPolicy* policy = [[CWVTranslationPolicy alloc] init]; | |
20 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.
| |
21 return policy; | |
22 } | |
23 | |
24 + (CWVTranslationPolicy*)translationPolicyNever { | |
25 CWVTranslationPolicy* policy = [[CWVTranslationPolicy alloc] init]; | |
26 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.
| |
27 return policy; | |
28 } | |
29 | |
30 + (CWVTranslationPolicy*)translationPolicyAutoTranslateToLanguage: | |
31 (CWVTranslationLanguage*)language { | |
32 CWVTranslationPolicy* policy = [[CWVTranslationPolicy alloc] init]; | |
33 policy->_type = CWVTranslationPolicyAuto; | |
34 policy->_language = language; | |
35 return policy; | |
36 } | |
37 | |
38 @end | |
OLD | NEW |