OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webui/options/language_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/language_options_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 #include <utility> | 12 #include <utility> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/bind.h" | 15 #include "base/bind.h" |
15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
16 #include "base/i18n/rtl.h" | 17 #include "base/i18n/rtl.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "base/values.h" | 19 #include "base/values.h" |
19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 base::string16 adjusted_display_name(display_name); | 97 base::string16 adjusted_display_name(display_name); |
97 base::i18n::AdjustStringForLocaleDirection(&adjusted_display_name); | 98 base::i18n::AdjustStringForLocaleDirection(&adjusted_display_name); |
98 | 99 |
99 const LanguagePair& pair = language_map[display_name]; | 100 const LanguagePair& pair = language_map[display_name]; |
100 base::string16 adjusted_native_display_name(pair.second); | 101 base::string16 adjusted_native_display_name(pair.second); |
101 base::i18n::AdjustStringForLocaleDirection(&adjusted_native_display_name); | 102 base::i18n::AdjustStringForLocaleDirection(&adjusted_native_display_name); |
102 | 103 |
103 bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(display_name); | 104 bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(display_name); |
104 std::string directionality = has_rtl_chars ? "rtl" : "ltr"; | 105 std::string directionality = has_rtl_chars ? "rtl" : "ltr"; |
105 | 106 |
106 base::DictionaryValue* dictionary = new base::DictionaryValue(); | 107 std::unique_ptr<base::DictionaryValue> dictionary( |
| 108 new base::DictionaryValue()); |
107 dictionary->SetString("code", pair.first); | 109 dictionary->SetString("code", pair.first); |
108 dictionary->SetString("displayName", adjusted_display_name); | 110 dictionary->SetString("displayName", adjusted_display_name); |
109 dictionary->SetString("textDirection", directionality); | 111 dictionary->SetString("textDirection", directionality); |
110 dictionary->SetString("nativeDisplayName", adjusted_native_display_name); | 112 dictionary->SetString("nativeDisplayName", adjusted_native_display_name); |
111 language_list->Append(dictionary); | 113 language_list->Append(std::move(dictionary)); |
112 } | 114 } |
113 | 115 |
114 return language_list; | 116 return language_list; |
115 } | 117 } |
116 | 118 |
117 void LanguageOptionsHandler::SetApplicationLocale( | 119 void LanguageOptionsHandler::SetApplicationLocale( |
118 const std::string& language_code) { | 120 const std::string& language_code) { |
119 PrefService* pref_service = g_browser_process->local_state(); | 121 PrefService* pref_service = g_browser_process->local_state(); |
120 pref_service->SetString(prefs::kApplicationLocale, language_code); | 122 pref_service->SetString(prefs::kApplicationLocale, language_code); |
121 } | 123 } |
122 | 124 |
123 void LanguageOptionsHandler::RestartCallback(const base::ListValue* args) { | 125 void LanguageOptionsHandler::RestartCallback(const base::ListValue* args) { |
124 content::RecordAction(UserMetricsAction("LanguageOptions_Restart")); | 126 content::RecordAction(UserMetricsAction("LanguageOptions_Restart")); |
125 chrome::AttemptRestart(); | 127 chrome::AttemptRestart(); |
126 } | 128 } |
127 | 129 |
128 } // namespace options | 130 } // namespace options |
OLD | NEW |