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

Unified Diff: ios/web_view/internal/cwv_preferences.mm

Issue 2983453002: Expose way to enable/disable translate. (Closed)
Patch Set: comment non obvious param 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
« no previous file with comments | « ios/web_view/BUILD.gn ('k') | ios/web_view/internal/cwv_preferences_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web_view/internal/cwv_preferences.mm
diff --git a/ios/web_view/internal/cwv_preferences.mm b/ios/web_view/internal/cwv_preferences.mm
new file mode 100644
index 0000000000000000000000000000000000000000..e64376c92f2f0933da1deac29d0b3f66fdc28306
--- /dev/null
+++ b/ios/web_view/internal/cwv_preferences.mm
@@ -0,0 +1,48 @@
+// 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_preferences.h"
michaeldo 2017/07/14 16:11:08 No need for cwv_preferences import. Other objects
jzw1 2017/07/14 17:37:19 Done.
+#import "ios/web_view/internal/cwv_preferences_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 CWVPreferences {
+ PrefService* _prefService;
+}
+
+@dynamic translationEnabled;
michaeldo 2017/07/14 16:11:08 I don't think @dynamic is needed here because both
jzw1 2017/07/14 17:37:19 Oh yeah, I guess I've been doing it wrong for a lo
michaeldo 2017/07/14 17:39:32 Thanks. No worries, I was only trying to learn why
+
+- (instancetype)initWithPrefService:(PrefService*)prefService {
+ self = [super init];
+ if (self) {
+ _prefService = prefService;
+ }
+ return self;
+}
+
+#pragma mark - Public Methods
+
+- (void)setTranslationEnabled:(BOOL)enabled {
+ _prefService->SetBoolean(prefs::kEnableTranslate, enabled);
+}
+
+- (BOOL)isTranslationEnabled {
+ return _prefService->GetBoolean(prefs::kEnableTranslate);
+}
+
+- (void)resetTranslationSettings {
+ translate::TranslatePrefs translatePrefs(
+ _prefService, prefs::kAcceptLanguages,
+ /*preferred_languages_pref=*/nullptr);
+ translatePrefs.ResetToDefaults();
+}
+
+@end
« no previous file with comments | « ios/web_view/BUILD.gn ('k') | ios/web_view/internal/cwv_preferences_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698