Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #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.
| |
| 6 #import "ios/web_view/internal/cwv_preferences_internal.h" | |
| 7 | |
| 8 #include "components/prefs/pref_service.h" | |
| 9 #include "components/translate/core/browser/translate_pref_names.h" | |
| 10 #include "components/translate/core/browser/translate_prefs.h" | |
| 11 #include "ios/web_view/internal/pref_names.h" | |
| 12 | |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 14 #error "This file requires ARC support." | |
| 15 #endif | |
| 16 | |
| 17 @implementation CWVPreferences { | |
| 18 PrefService* _prefService; | |
| 19 } | |
| 20 | |
| 21 @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
| |
| 22 | |
| 23 - (instancetype)initWithPrefService:(PrefService*)prefService { | |
| 24 self = [super init]; | |
| 25 if (self) { | |
| 26 _prefService = prefService; | |
| 27 } | |
| 28 return self; | |
| 29 } | |
| 30 | |
| 31 #pragma mark - Public Methods | |
| 32 | |
| 33 - (void)setTranslationEnabled:(BOOL)enabled { | |
| 34 _prefService->SetBoolean(prefs::kEnableTranslate, enabled); | |
| 35 } | |
| 36 | |
| 37 - (BOOL)isTranslationEnabled { | |
| 38 return _prefService->GetBoolean(prefs::kEnableTranslate); | |
| 39 } | |
| 40 | |
| 41 - (void)resetTranslationSettings { | |
| 42 translate::TranslatePrefs translatePrefs( | |
| 43 _prefService, prefs::kAcceptLanguages, | |
| 44 /*preferred_languages_pref=*/nullptr); | |
| 45 translatePrefs.ResetToDefaults(); | |
| 46 } | |
| 47 | |
| 48 @end | |
| OLD | NEW |