Index: ios/web_view/internal/translate/cwv_translation_configuration.mm |
diff --git a/ios/web_view/internal/translate/cwv_translation_configuration.mm b/ios/web_view/internal/translate/cwv_translation_configuration.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bb02f712698a3ff1e2110c9ea1c4afbd1f22fdb7 |
--- /dev/null |
+++ b/ios/web_view/internal/translate/cwv_translation_configuration.mm |
@@ -0,0 +1,47 @@ |
+// 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_configuration.h" |
+#import "ios/web_view/internal/translate/cwv_translation_configuration_internal.h" |
+ |
+#include "components/prefs/pref_service.h" |
+#include "components/translate/core/browser/translate_pref_names.h" |
+#include "components/translate/core/browser/translate_prefs.h" |
+#include "ios/web_view/internal/pref_names.h" |
+ |
+#if !defined(__has_feature) || !__has_feature(objc_arc) |
+#error "This file requires ARC support." |
+#endif |
+ |
+@implementation CWVTranslationConfiguration { |
+ PrefService* _prefService; |
+} |
+ |
+@dynamic enabled; |
+ |
+- (instancetype)initWithPrefService:(PrefService*)prefService { |
+ self = [super init]; |
+ if (self) { |
+ _prefService = prefService; |
+ } |
+ return self; |
+} |
+ |
+#pragma mark - Public Methods |
+ |
+- (void)setEnabled:(BOOL)enabled { |
+ _prefService->SetBoolean(prefs::kEnableTranslate, enabled); |
+} |
+ |
+- (BOOL)enabled { |
+ return _prefService->GetBoolean(prefs::kEnableTranslate); |
+} |
+ |
+- (void)reset { |
+ translate::TranslatePrefs translatePrefs(_prefService, |
+ prefs::kAcceptLanguages, nullptr); |
Eugene But (OOO till 7-30)
2017/07/14 00:22:42
nit: Do you want to document nullptr with comments
jzw1
2017/07/14 02:09:49
I think it's OK to omit. The initializer in transl
Hiroshi Ichikawa
2017/07/14 02:55:49
No, it should be still commented. It can be like t
|
+ translatePrefs.ResetToDefaults(); |
+} |
+ |
+@end |