| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/dom_ui/language_chewing_options_handler.h" | 5 #include "chrome/browser/chromeos/dom_ui/language_chewing_options_handler.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/chromeos/dom_ui/language_options_util.h" | 14 #include "chrome/browser/chromeos/dom_ui/language_options_util.h" |
| 15 #include "chrome/browser/chromeos/language_preferences.h" | 15 #include "chrome/browser/chromeos/language_preferences.h" |
| 16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 17 | 17 |
| 18 namespace chromeos { |
| 19 |
| 18 LanguageChewingOptionsHandler::LanguageChewingOptionsHandler() { | 20 LanguageChewingOptionsHandler::LanguageChewingOptionsHandler() { |
| 19 } | 21 } |
| 20 | 22 |
| 21 LanguageChewingOptionsHandler::~LanguageChewingOptionsHandler() { | 23 LanguageChewingOptionsHandler::~LanguageChewingOptionsHandler() { |
| 22 } | 24 } |
| 23 | 25 |
| 24 void LanguageChewingOptionsHandler::GetLocalizedValues( | 26 void LanguageChewingOptionsHandler::GetLocalizedValues( |
| 25 DictionaryValue* localized_strings) { | 27 DictionaryValue* localized_strings) { |
| 26 DCHECK(localized_strings); | 28 DCHECK(localized_strings); |
| 27 // Language Chewing page - ChromeOS | 29 // Language Chewing page - ChromeOS |
| 28 for (size_t i = 0; i < chromeos::kNumChewingBooleanPrefs; ++i) { | 30 for (size_t i = 0; i < kNumChewingBooleanPrefs; ++i) { |
| 29 localized_strings->SetString( | 31 localized_strings->SetString( |
| 30 GetI18nContentValue(chromeos::kChewingBooleanPrefs[i]), | 32 GetI18nContentValue(kChewingBooleanPrefs[i]), |
| 31 l10n_util::GetString(chromeos::kChewingBooleanPrefs[i].message_id)); | 33 l10n_util::GetString(kChewingBooleanPrefs[i].message_id)); |
| 32 } | 34 } |
| 33 | 35 |
| 34 for (size_t i = 0; i < chromeos::kNumChewingIntegerPrefs; ++i) { | 36 for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) { |
| 35 const chromeos::LanguageIntegerRangePreference& preference = | 37 const LanguageIntegerRangePreference& preference = |
| 36 chromeos::kChewingIntegerPrefs[i]; | 38 kChewingIntegerPrefs[i]; |
| 37 localized_strings->SetString( | 39 localized_strings->SetString( |
| 38 GetI18nContentValue(preference), | 40 GetI18nContentValue(preference), |
| 39 l10n_util::GetString(preference.message_id)); | 41 l10n_util::GetString(preference.message_id)); |
| 40 localized_strings->SetString( | 42 localized_strings->SetString( |
| 41 GetTemplateDataMinName(preference), | 43 GetTemplateDataMinName(preference), |
| 42 UTF8ToWide(base::IntToString(preference.min_pref_value))); | 44 UTF8ToWide(base::IntToString(preference.min_pref_value))); |
| 43 localized_strings->SetString( | 45 localized_strings->SetString( |
| 44 GetTemplateDataMaxName(preference), | 46 GetTemplateDataMaxName(preference), |
| 45 UTF8ToWide(base::IntToString(preference.max_pref_value))); | 47 UTF8ToWide(base::IntToString(preference.max_pref_value))); |
| 46 } | 48 } |
| 47 | 49 |
| 48 for (size_t i = 0; i < chromeos::kNumChewingMultipleChoicePrefs; | 50 for (size_t i = 0; i < kNumChewingMultipleChoicePrefs; |
| 49 ++i) { | 51 ++i) { |
| 50 const chromeos::LanguageMultipleChoicePreference<const char*>& preference = | 52 const LanguageMultipleChoicePreference<const char*>& preference = |
| 51 chromeos::kChewingMultipleChoicePrefs[i]; | 53 kChewingMultipleChoicePrefs[i]; |
| 52 localized_strings->SetString( | 54 localized_strings->SetString( |
| 53 GetI18nContentValue(preference), | 55 GetI18nContentValue(preference), |
| 54 l10n_util::GetString(preference.label_message_id)); | 56 l10n_util::GetString(preference.label_message_id)); |
| 55 localized_strings->Set( | 57 localized_strings->Set( |
| 56 GetTemplateDataPropertyName(preference), | 58 GetTemplateDataPropertyName(preference), |
| 57 chromeos::CreateMultipleChoiceList(preference)); | 59 CreateMultipleChoiceList(preference)); |
| 58 } | 60 } |
| 59 | 61 |
| 60 localized_strings->SetString( | 62 localized_strings->SetString( |
| 61 GetI18nContentValue(chromeos::kChewingHsuSelKeyType), | 63 GetI18nContentValue(kChewingHsuSelKeyType), |
| 62 l10n_util::GetString(chromeos::kChewingHsuSelKeyType.label_message_id)); | 64 l10n_util::GetString(kChewingHsuSelKeyType.label_message_id)); |
| 63 | 65 |
| 64 int hsu_sel_key_type_min = std::numeric_limits<int>::max(); | 66 int hsu_sel_key_type_min = std::numeric_limits<int>::max(); |
| 65 int hsu_sel_key_type_max = std::numeric_limits<int>::min(); | 67 int hsu_sel_key_type_max = std::numeric_limits<int>::min(); |
| 66 for (size_t i = 0; | 68 for (size_t i = 0; |
| 67 i < chromeos::LanguageMultipleChoicePreference<int>::kMaxItems; | 69 i < LanguageMultipleChoicePreference<int>::kMaxItems; |
| 68 ++i) { | 70 ++i) { |
| 69 if (chromeos::kChewingHsuSelKeyType.values_and_ids[i].item_message_id == 0) | 71 if (kChewingHsuSelKeyType.values_and_ids[i].item_message_id == 0) |
| 70 break; | 72 break; |
| 71 const int value = | 73 const int value = |
| 72 chromeos::kChewingHsuSelKeyType.values_and_ids[i].ibus_config_value; | 74 kChewingHsuSelKeyType.values_and_ids[i].ibus_config_value; |
| 73 if (value <= hsu_sel_key_type_min) | 75 if (value <= hsu_sel_key_type_min) |
| 74 hsu_sel_key_type_min = value; | 76 hsu_sel_key_type_min = value; |
| 75 if (value >= hsu_sel_key_type_max) | 77 if (value >= hsu_sel_key_type_max) |
| 76 hsu_sel_key_type_max = value; | 78 hsu_sel_key_type_max = value; |
| 77 } | 79 } |
| 78 DCHECK_NE(hsu_sel_key_type_min, std::numeric_limits<int>::max()); | 80 DCHECK_NE(hsu_sel_key_type_min, std::numeric_limits<int>::max()); |
| 79 DCHECK_NE(hsu_sel_key_type_max, std::numeric_limits<int>::min()); | 81 DCHECK_NE(hsu_sel_key_type_max, std::numeric_limits<int>::min()); |
| 80 | 82 |
| 81 localized_strings->SetString( | 83 localized_strings->SetString( |
| 82 GetTemplateDataMinName(chromeos::kChewingHsuSelKeyType), | 84 GetTemplateDataMinName(kChewingHsuSelKeyType), |
| 83 UTF8ToWide(base::IntToString(hsu_sel_key_type_min))); | 85 UTF8ToWide(base::IntToString(hsu_sel_key_type_min))); |
| 84 localized_strings->SetString( | 86 localized_strings->SetString( |
| 85 GetTemplateDataMaxName(chromeos::kChewingHsuSelKeyType), | 87 GetTemplateDataMaxName(kChewingHsuSelKeyType), |
| 86 UTF8ToWide(base::IntToString(hsu_sel_key_type_max))); | 88 UTF8ToWide(base::IntToString(hsu_sel_key_type_max))); |
| 87 } | 89 } |
| 90 |
| 91 } // namespace chromeos |
| OLD | NEW |