| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h" | 5 #include "chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "chrome/browser/ui/cocoa/l10n_util.h" | 10 #include "chrome/common/chrome_features.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 NSString* const kAppleTextDirectionDefaultsKey = @"AppleTextDirection"; | 14 NSString* const kAppleTextDirectionDefaultsKey = @"AppleTextDirection"; |
| 15 NSString* const kForceRTLWritingDirectionDefaultsKey = | 15 NSString* const kForceRTLWritingDirectionDefaultsKey = |
| 16 @"NSForceRightToLeftWritingDirection"; | 16 @"NSForceRightToLeftWritingDirection"; |
| 17 const char kDefaultRTLLocale[] = "he"; // Hebrew. | 17 const char kDefaultRTLLocale[] = "he"; // Hebrew. |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 namespace cocoa_l10n_util { | 21 namespace cocoa_l10n_util { |
| 22 | 22 |
| 23 ScopedForceRTLMac::ScopedForceRTLMac() { | 23 ScopedForceRTLMac::ScopedForceRTLMac() { |
| 24 scoped_feature_list_.InitAndEnableFeature(kExperimentalMacRTL); | 24 scoped_feature_list_.InitAndEnableFeature(features::kMacRTL); |
| 25 NSUserDefaults* standard_defaults = [NSUserDefaults standardUserDefaults]; | 25 NSUserDefaults* standard_defaults = [NSUserDefaults standardUserDefaults]; |
| 26 original_apple_text_direction_ = | 26 original_apple_text_direction_ = |
| 27 [standard_defaults boolForKey:kAppleTextDirectionDefaultsKey]; | 27 [standard_defaults boolForKey:kAppleTextDirectionDefaultsKey]; |
| 28 original_rtl_writing_direction_ = | 28 original_rtl_writing_direction_ = |
| 29 [standard_defaults boolForKey:kForceRTLWritingDirectionDefaultsKey]; | 29 [standard_defaults boolForKey:kForceRTLWritingDirectionDefaultsKey]; |
| 30 [standard_defaults setBool:YES forKey:kAppleTextDirectionDefaultsKey]; | 30 [standard_defaults setBool:YES forKey:kAppleTextDirectionDefaultsKey]; |
| 31 [standard_defaults setBool:YES forKey:kForceRTLWritingDirectionDefaultsKey]; | 31 [standard_defaults setBool:YES forKey:kForceRTLWritingDirectionDefaultsKey]; |
| 32 original_locale_ = base::i18n::GetConfiguredLocale(); | 32 original_locale_ = base::i18n::GetConfiguredLocale(); |
| 33 base::i18n::SetICUDefaultLocale(kDefaultRTLLocale); | 33 base::i18n::SetICUDefaultLocale(kDefaultRTLLocale); |
| 34 } | 34 } |
| 35 | 35 |
| 36 ScopedForceRTLMac::~ScopedForceRTLMac() { | 36 ScopedForceRTLMac::~ScopedForceRTLMac() { |
| 37 [[NSUserDefaults standardUserDefaults] | 37 [[NSUserDefaults standardUserDefaults] |
| 38 setBool:original_apple_text_direction_ | 38 setBool:original_apple_text_direction_ |
| 39 forKey:kAppleTextDirectionDefaultsKey]; | 39 forKey:kAppleTextDirectionDefaultsKey]; |
| 40 [[NSUserDefaults standardUserDefaults] | 40 [[NSUserDefaults standardUserDefaults] |
| 41 setBool:original_rtl_writing_direction_ | 41 setBool:original_rtl_writing_direction_ |
| 42 forKey:kForceRTLWritingDirectionDefaultsKey]; | 42 forKey:kForceRTLWritingDirectionDefaultsKey]; |
| 43 base::i18n::SetICUDefaultLocale(original_locale_); | 43 base::i18n::SetICUDefaultLocale(original_locale_); |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace cocoa_l10n_util | 46 } // namespace cocoa_l10n_util |
| OLD | NEW |