| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h" |
| 6 |
| 7 #import <Foundation/Foundation.h> |
| 8 |
| 9 #include "base/i18n/rtl.h" |
| 10 #include "chrome/browser/ui/cocoa/l10n_util.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 NSString* const kAppleTextDirectionDefaultsKey = @"AppleTextDirection"; |
| 15 NSString* const kForceRTLWritingDirectionDefaultsKey = |
| 16 @"NSForceRightToLeftWritingDirection"; |
| 17 const char kDefaultRTLLocale[] = "he"; // Hebrew. |
| 18 |
| 19 } // namespace |
| 20 |
| 21 namespace cocoa_l10n_util { |
| 22 |
| 23 ScopedForceRTLMac::ScopedForceRTLMac() { |
| 24 scoped_feature_list_.InitAndEnableFeature(kExperimentalMacRTL); |
| 25 NSUserDefaults* standard_defaults = [NSUserDefaults standardUserDefaults]; |
| 26 original_apple_text_direction_ = |
| 27 [standard_defaults boolForKey:kAppleTextDirectionDefaultsKey]; |
| 28 original_rtl_writing_direction_ = |
| 29 [standard_defaults boolForKey:kForceRTLWritingDirectionDefaultsKey]; |
| 30 [standard_defaults setBool:YES forKey:kAppleTextDirectionDefaultsKey]; |
| 31 [standard_defaults setBool:YES forKey:kForceRTLWritingDirectionDefaultsKey]; |
| 32 original_locale_ = base::i18n::GetConfiguredLocale(); |
| 33 base::i18n::SetICUDefaultLocale(kDefaultRTLLocale); |
| 34 } |
| 35 |
| 36 ScopedForceRTLMac::~ScopedForceRTLMac() { |
| 37 [[NSUserDefaults standardUserDefaults] |
| 38 setBool:original_apple_text_direction_ |
| 39 forKey:kAppleTextDirectionDefaultsKey]; |
| 40 [[NSUserDefaults standardUserDefaults] |
| 41 setBool:original_rtl_writing_direction_ |
| 42 forKey:kForceRTLWritingDirectionDefaultsKey]; |
| 43 base::i18n::SetICUDefaultLocale(original_locale_); |
| 44 } |
| 45 |
| 46 } // namespace cocoa_l10n_util |
| OLD | NEW |