Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.mm

Issue 2555033003: Add ScopedMacRTL class for Cocoa browser RTL testing (Closed)
Patch Set: Review comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/test/scoped_force_rtl_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698