Index: ios/web_view/internal/translate/cwv_translation_controller.mm |
diff --git a/ios/web_view/internal/translate/cwv_translation_controller.mm b/ios/web_view/internal/translate/cwv_translation_controller.mm |
index c62a8680ebdcd0ba3acbb29eda254f5df42185f6..17ed9e99831dac924f91ad294a7bd0d3526293d2 100644 |
--- a/ios/web_view/internal/translate/cwv_translation_controller.mm |
+++ b/ios/web_view/internal/translate/cwv_translation_controller.mm |
@@ -11,8 +11,11 @@ |
#include "base/strings/sys_string_conversions.h" |
#include "components/translate/core/browser/translate_download_manager.h" |
#include "components/translate/core/browser/translate_manager.h" |
+#import "ios/web_view/internal/cwv_web_view_configuration_internal.h" |
+#include "ios/web_view/internal/pref_names.h" |
#import "ios/web_view/internal/translate/cwv_translation_language_internal.h" |
#import "ios/web_view/internal/translate/web_view_translate_client.h" |
+#include "ios/web_view/internal/web_view_browser_state.h" |
#import "ios/web_view/public/cwv_translation_controller_delegate.h" |
#import "ios/web_view/public/cwv_translation_policy.h" |
#include "ui/base/l10n/l10n_util.h" |
@@ -65,6 +68,17 @@ const NSInteger CWVTranslationErrorScriptLoadError = |
@synthesize supportedLanguagesByCode = _supportedLanguagesByCode; |
@synthesize webState = _webState; |
+#pragma mark - Class Methods |
+ |
++ (void)resetTranslationPolicies { |
+ CWVWebViewConfiguration* configuration = |
+ [CWVWebViewConfiguration defaultConfiguration]; |
+ PrefService* prefService = configuration.browserState->GetPrefs(); |
+ translate::TranslatePrefs translatePrefs(prefService, prefs::kAcceptLanguages, |
+ nullptr); |
+ translatePrefs.ResetToDefaults(); |
+} |
+ |
#pragma mark - Internal Methods |
- (void)setWebState:(web::WebState*)webState { |
@@ -155,6 +169,7 @@ const NSInteger CWVTranslationErrorScriptLoadError = |
- (void)setTranslationPolicy:(CWVTranslationPolicy*)policy |
forPageLanguage:(CWVTranslationLanguage*)pageLanguage { |
+ DCHECK(!_webState->GetBrowserState()->IsOffTheRecord()); |
std::string languageCode = base::SysNSStringToUTF8(pageLanguage.languageCode); |
switch (policy.type) { |
case CWVTranslationPolicyAsk: { |
@@ -198,6 +213,7 @@ const NSInteger CWVTranslationErrorScriptLoadError = |
- (void)setTranslationPolicy:(CWVTranslationPolicy*)policy |
forPageHost:(NSString*)pageHost { |
+ DCHECK(!_webState->GetBrowserState()->IsOffTheRecord()); |
DCHECK(pageHost.length); |
switch (policy.type) { |
case CWVTranslationPolicyAsk: { |