Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Unified Diff: ios/web_view/internal/translate/cwv_translation_policy.mm

Issue 2872083003: Added translation policy API. (Closed)
Patch Set: addressed michael and eugene comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..5c0f2711069332a5e54b49495c688825a68d4a71
--- /dev/null
+++ b/ios/web_view/internal/translate/cwv_translation_policy.mm
@@ -0,0 +1,44 @@
+// 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 ()
+// Redefined to allow setters for private use.
+@property(nonatomic, assign) CWVTranslationPolicyType type;
+@property(nonatomic, strong) CWVTranslationLanguage* language;
michaeldo 2017/05/12 15:29:09 please explicitly specify "readwrite" here
jzw1 2017/05/15 02:43:30 Done.
+@end
+
+@implementation CWVTranslationPolicy
+
+@synthesize language = _language;
+@synthesize type = _type;
+
++ (CWVTranslationPolicy*)translationPolicyAsk {
+ CWVTranslationPolicy* policy = [[CWVTranslationPolicy alloc] init];
+ policy.type = CWVTranslationPolicyAsk;
+ return policy;
+}
+
++ (CWVTranslationPolicy*)translationPolicyNever {
+ CWVTranslationPolicy* policy = [[CWVTranslationPolicy alloc] init];
+ policy.type = CWVTranslationPolicyNever;
+ return policy;
+}
+
++ (CWVTranslationPolicy*)translationPolicyAutoTranslateToLanguage:
+ (CWVTranslationLanguage*)language {
+ CWVTranslationPolicy* policy = [[CWVTranslationPolicy alloc] init];
+ policy.type = CWVTranslationPolicyAuto;
+ policy.language = language;
+ return policy;
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698