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

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

Issue 2983453002: Expose way to enable/disable translate. (Closed)
Patch Set: Refactor settings Created 3 years, 5 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_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

Powered by Google App Engine
This is Rietveld 408576698