| 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..8471293cba3712e4d2c84cd29e5bc8da88f0b681 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,9 @@ const NSInteger CWVTranslationErrorScriptLoadError =
|
|
|
| - (void)setTranslationPolicy:(CWVTranslationPolicy*)policy
|
| forPageLanguage:(CWVTranslationLanguage*)pageLanguage {
|
| + if (_webState->GetBrowserState()->IsOffTheRecord()) {
|
| + return;
|
| + }
|
| std::string languageCode = base::SysNSStringToUTF8(pageLanguage.languageCode);
|
| switch (policy.type) {
|
| case CWVTranslationPolicyAsk: {
|
| @@ -198,6 +215,9 @@ const NSInteger CWVTranslationErrorScriptLoadError =
|
|
|
| - (void)setTranslationPolicy:(CWVTranslationPolicy*)policy
|
| forPageHost:(NSString*)pageHost {
|
| + if (_webState->GetBrowserState()->IsOffTheRecord()) {
|
| + return;
|
| + }
|
| DCHECK(pageHost.length);
|
| switch (policy.type) {
|
| case CWVTranslationPolicyAsk: {
|
|
|