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

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

Issue 2872083003: Added translation policy API. (Closed)
Patch Set: sync 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..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
« no previous file with comments | « ios/web_view/internal/translate/cwv_translation_language.mm ('k') | ios/web_view/public/cwv_translation_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698