diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-20 02:50:23 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-20 02:50:23 +0000 |
commit | b65c5d24f7c869b7caefe14533ae83e71c200101 (patch) | |
tree | caa6ee0a19c95b014acba45b109862291036551f /chrome/browser/chromeos/options | |
parent | c3b3e06a5b08d71e8fe0642c2aacd480cee5b691 (diff) | |
download | chromium_src-b65c5d24f7c869b7caefe14533ae83e71c200101.zip chromium_src-b65c5d24f7c869b7caefe14533ae83e71c200101.tar.gz chromium_src-b65c5d24f7c869b7caefe14533ae83e71c200101.tar.bz2 |
Add language_prefs namespace to language_preferences.h.
language_preferences.h exports lots of constants hence polutes chromeos
namespace.
TEST=compiles. try bots.
BUG=chromium-os:5848
Review URL: http://codereview.chromium.org/3132023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56803 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/options')
9 files changed, 140 insertions, 101 deletions
diff --git a/chrome/browser/chromeos/options/language_chewing_config_view.cc b/chrome/browser/chromeos/options/language_chewing_config_view.cc index a1da7ae..40a597e 100644 --- a/chrome/browser/chromeos/options/language_chewing_config_view.cc +++ b/chrome/browser/chromeos/options/language_chewing_config_view.cc @@ -25,29 +25,34 @@ namespace chromeos { LanguageChewingConfigView::LanguageChewingConfigView(Profile* profile) : OptionsPageView(profile), contents_(NULL) { - for (size_t i = 0; i < kNumChewingBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { chewing_boolean_prefs_[i].Init( - kChewingBooleanPrefs[i].pref_name, profile->GetPrefs(), this); + language_prefs::kChewingBooleanPrefs[i].pref_name, + profile->GetPrefs(), this); chewing_boolean_checkboxes_[i] = NULL; } - for (size_t i = 0; i < kNumChewingMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { ChewingPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; current.multiple_choice_pref.Init( - kChewingMultipleChoicePrefs[i].pref_name, profile->GetPrefs(), this); + language_prefs::kChewingMultipleChoicePrefs[i].pref_name, + profile->GetPrefs(), this); current.combobox_model = - new LanguageComboboxModel<const char*>(&kChewingMultipleChoicePrefs[i]); + new LanguageComboboxModel<const char*>( + &language_prefs::kChewingMultipleChoicePrefs[i]); current.combobox = NULL; } hsu_sel_key_type_.multiple_choice_pref.Init( - kChewingHsuSelKeyType.pref_name, profile->GetPrefs(), this); + language_prefs::kChewingHsuSelKeyType.pref_name, profile->GetPrefs(), + this); hsu_sel_key_type_.combobox_model = - new LanguageComboboxModel<int>(&kChewingHsuSelKeyType); + new LanguageComboboxModel<int>(&language_prefs::kChewingHsuSelKeyType); hsu_sel_key_type_.combobox = NULL; - for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { chewing_integer_prefs_[i].Init( - kChewingIntegerPrefs[i].pref_name, profile->GetPrefs(), this); + language_prefs::kChewingIntegerPrefs[i].pref_name, + profile->GetPrefs(), this); chewing_integer_sliders_[i] = NULL; } } @@ -59,13 +64,14 @@ void LanguageChewingConfigView::ButtonPressed( views::Button* sender, const views::Event& event) { views::Checkbox* checkbox = static_cast<views::Checkbox*>(sender); const int pref_id = checkbox->tag(); - DCHECK(pref_id >= 0 && pref_id < static_cast<int>(kNumChewingBooleanPrefs)); + DCHECK(pref_id >= 0 && pref_id < static_cast<int>( + language_prefs::kNumChewingBooleanPrefs)); chewing_boolean_prefs_[pref_id].SetValue(checkbox->checked()); } void LanguageChewingConfigView::ItemChanged( views::Combobox* sender, int prev_index, int new_index) { - for (size_t i = 0; i < kNumChewingMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { ChewingPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; if (current.combobox == sender) { const std::string config_value = @@ -87,11 +93,12 @@ void LanguageChewingConfigView::ItemChanged( void LanguageChewingConfigView::SliderValueChanged(views::Slider* sender) { size_t pref_id; - for (pref_id = 0; pref_id < kNumChewingIntegerPrefs; ++pref_id) { + for (pref_id = 0; pref_id < language_prefs::kNumChewingIntegerPrefs; + ++pref_id) { if (chewing_integer_sliders_[pref_id] == sender) break; } - DCHECK(pref_id < kNumChewingIntegerPrefs); + DCHECK(pref_id < language_prefs::kNumChewingIntegerPrefs); chewing_integer_prefs_[pref_id].SetValue(sender->value()); } @@ -144,13 +151,14 @@ void LanguageChewingConfigView::InitControlLayout() { column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1, GridLayout::USE_PREF, 0, 0); - for (size_t i = 0; i < kNumChewingBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { chewing_boolean_checkboxes_[i] = new views::Checkbox( - l10n_util::GetString(kChewingBooleanPrefs[i].message_id)); + l10n_util::GetString( + language_prefs::kChewingBooleanPrefs[i].message_id)); chewing_boolean_checkboxes_[i]->set_listener(this); chewing_boolean_checkboxes_[i]->set_tag(i); } - for (size_t i = 0; i < kNumChewingMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { ChewingPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; current.combobox = new LanguageCombobox(current.combobox_model); current.combobox->set_listener(this); @@ -159,31 +167,32 @@ void LanguageChewingConfigView::InitControlLayout() { new LanguageCombobox(hsu_sel_key_type_.combobox_model); hsu_sel_key_type_.combobox->set_listener(this); - for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { chewing_integer_sliders_[i] = new views::Slider( - kChewingIntegerPrefs[i].min_pref_value, - kChewingIntegerPrefs[i].max_pref_value, + language_prefs::kChewingIntegerPrefs[i].min_pref_value, + language_prefs::kChewingIntegerPrefs[i].max_pref_value, 1, static_cast<views::Slider::StyleFlags>( views::Slider::STYLE_DRAW_VALUE | views::Slider::STYLE_UPDATE_ON_RELEASE), this); } - for (size_t i = 0; i < kNumChewingBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { layout->StartRow(0, kColumnSetId); layout->AddView(chewing_boolean_checkboxes_[i]); } - for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { layout->StartRow(0, kColumnSetId); layout->AddView(new views::Label( - l10n_util::GetString(kChewingIntegerPrefs[i].message_id))); + l10n_util::GetString( + language_prefs::kChewingIntegerPrefs[i].message_id))); layout->AddView(chewing_integer_sliders_[i]); } NotifyPrefChanged(); // Show the comboboxes. - for (size_t i = 0; i < kNumChewingMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { const ChewingPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; layout->StartRow(0, kColumnSetId); layout->AddView(new views::Label(current.combobox_model->GetLabel())); @@ -204,15 +213,15 @@ void LanguageChewingConfigView::Observe(NotificationType type, } void LanguageChewingConfigView::NotifyPrefChanged() { - for (size_t i = 0; i < kNumChewingBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { const bool checked = chewing_boolean_prefs_[i].GetValue(); chewing_boolean_checkboxes_[i]->SetChecked(checked); } - for (size_t i = 0; i < kNumChewingIntegerPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) { const int value = chewing_integer_prefs_[i].GetValue(); chewing_integer_sliders_[i]->SetValue(value); } - for (size_t i = 0; i < kNumChewingMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) { ChewingPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; const std::string value = current.multiple_choice_pref.GetValue(); for (int i = 0; i < current.combobox_model->num_items(); ++i) { diff --git a/chrome/browser/chromeos/options/language_chewing_config_view.h b/chrome/browser/chromeos/options/language_chewing_config_view.h index 4a230f0..a018131 100644 --- a/chrome/browser/chromeos/options/language_chewing_config_view.h +++ b/chrome/browser/chromeos/options/language_chewing_config_view.h @@ -70,20 +70,24 @@ class LanguageChewingConfigView : public views::ButtonListener, // Updates the chewing checkboxes. void NotifyPrefChanged(); - BooleanPrefMember chewing_boolean_prefs_[kNumChewingBooleanPrefs]; - IntegerPrefMember chewing_integer_prefs_[kNumChewingIntegerPrefs]; + BooleanPrefMember chewing_boolean_prefs_[ + language_prefs::kNumChewingBooleanPrefs]; + IntegerPrefMember chewing_integer_prefs_[ + language_prefs::kNumChewingIntegerPrefs]; views::View* contents_; // Checkboxes for Chewing. - views::Checkbox* chewing_boolean_checkboxes_[kNumChewingBooleanPrefs]; + views::Checkbox* chewing_boolean_checkboxes_[ + language_prefs::kNumChewingBooleanPrefs]; - views::Slider* chewing_integer_sliders_[kNumChewingIntegerPrefs]; + views::Slider* chewing_integer_sliders_[ + language_prefs::kNumChewingIntegerPrefs]; struct ChewingPrefAndAssociatedCombobox { StringPrefMember multiple_choice_pref; LanguageComboboxModel<const char*>* combobox_model; LanguageCombobox* combobox; - } prefs_and_comboboxes_[kNumChewingMultipleChoicePrefs]; + } prefs_and_comboboxes_[language_prefs::kNumChewingMultipleChoicePrefs]; struct HsuSelKeyTypePrefAndAssociatedCombobox { IntegerPrefMember multiple_choice_pref; diff --git a/chrome/browser/chromeos/options/language_config_util.h b/chrome/browser/chromeos/options/language_config_util.h index 9bca566..21a5705 100644 --- a/chrome/browser/chromeos/options/language_config_util.h +++ b/chrome/browser/chromeos/options/language_config_util.h @@ -17,12 +17,14 @@ template <typename DataType> class LanguageComboboxModel : public ComboboxModel { public: explicit LanguageComboboxModel( - const LanguageMultipleChoicePreference<DataType>* pref_data) + const language_prefs::LanguageMultipleChoicePreference<DataType>* + pref_data) : pref_data_(pref_data), num_items_(0) { // Check how many items are defined in the |pref_data->values_and_ids| // array. for (size_t i = 0; - i < LanguageMultipleChoicePreference<DataType>::kMaxItems; ++i) { + i < language_prefs::LanguageMultipleChoicePreference<DataType>:: + kMaxItems; ++i) { if ((pref_data_->values_and_ids)[i].item_message_id == 0) { break; } @@ -67,7 +69,7 @@ class LanguageComboboxModel : public ComboboxModel { } private: - const LanguageMultipleChoicePreference<DataType>* pref_data_; + const language_prefs::LanguageMultipleChoicePreference<DataType>* pref_data_; int num_items_; DISALLOW_COPY_AND_ASSIGN(LanguageComboboxModel); diff --git a/chrome/browser/chromeos/options/language_hangul_config_view.cc b/chrome/browser/chromeos/options/language_hangul_config_view.cc index 02eed33..29991c6 100644 --- a/chrome/browser/chromeos/options/language_hangul_config_view.cc +++ b/chrome/browser/chromeos/options/language_hangul_config_view.cc @@ -28,10 +28,12 @@ namespace chromeos { class HangulKeyboardComboboxModel : public ComboboxModel { public: HangulKeyboardComboboxModel() { - for (size_t i = 0; i < kNumHangulKeyboardNameIDPairs; ++i) { + for (size_t i = 0; i < language_prefs::kNumHangulKeyboardNameIDPairs; + ++i) { layouts_.push_back(std::make_pair( - l10n_util::GetStringUTF8(kHangulKeyboardNameIDPairs[i].message_id), - kHangulKeyboardNameIDPairs[i].keyboard_id)); + l10n_util::GetStringUTF8( + language_prefs::kHangulKeyboardNameIDPairs[i].message_id), + language_prefs::kHangulKeyboardNameIDPairs[i].keyboard_id)); } } diff --git a/chrome/browser/chromeos/options/language_mozc_config_view.cc b/chrome/browser/chromeos/options/language_mozc_config_view.cc index 35b8a85..15fbfdf 100644 --- a/chrome/browser/chromeos/options/language_mozc_config_view.cc +++ b/chrome/browser/chromeos/options/language_mozc_config_view.cc @@ -25,7 +25,7 @@ namespace { enum ButtonTag { // 0 to kNumMozcBooleanPrefs - 1 are reserved for the checkboxes for integer // preferences. - kResetToDefaultsButton = chromeos::kNumMozcBooleanPrefs, + kResetToDefaultsButton = chromeos::language_prefs::kNumMozcBooleanPrefs, }; } // namespace @@ -35,30 +35,34 @@ LanguageMozcConfigView::LanguageMozcConfigView(Profile* profile) : OptionsPageView(profile), contents_(NULL), reset_to_defaults_button_(NULL) { - for (size_t i = 0; i < kNumMozcBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { MozcPrefAndAssociatedCheckbox& current = prefs_and_checkboxes_[i]; current.boolean_pref.Init( - kMozcBooleanPrefs[i].pref_name, profile->GetPrefs(), this); + language_prefs::kMozcBooleanPrefs[i].pref_name, profile->GetPrefs(), + this); current.checkbox = NULL; } - for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; current.multiple_choice_pref.Init( - kMozcMultipleChoicePrefs[i].pref_name, profile->GetPrefs(), this); + language_prefs::kMozcMultipleChoicePrefs[i].pref_name, + profile->GetPrefs(), this); current.combobox_model = - new LanguageComboboxModel<const char*>(&kMozcMultipleChoicePrefs[i]); + new LanguageComboboxModel<const char*>( + &language_prefs::kMozcMultipleChoicePrefs[i]); current.combobox = NULL; } - for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { MozcPrefAndAssociatedSlider& current = prefs_and_sliders_[i]; current.integer_pref.Init( - kMozcIntegerPrefs[i].pref_name, profile->GetPrefs(), this); + language_prefs::kMozcIntegerPrefs[i].pref_name, profile->GetPrefs(), + this); current.slider = NULL; } } LanguageMozcConfigView::~LanguageMozcConfigView() { - for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { delete prefs_and_comboboxes_[i].combobox_model; } } @@ -71,7 +75,8 @@ void LanguageMozcConfigView::ButtonPressed( return; } views::Checkbox* checkbox = static_cast<views::Checkbox*>(sender); - DCHECK(pref_id >= 0 && pref_id < static_cast<int>(kNumMozcBooleanPrefs)); + DCHECK(pref_id >= 0 && pref_id < static_cast<int>( + language_prefs::kNumMozcBooleanPrefs)); prefs_and_checkboxes_[pref_id].boolean_pref.SetValue(checkbox->checked()); } @@ -81,7 +86,7 @@ void LanguageMozcConfigView::ItemChanged( LOG(ERROR) << "Invalid new_index: " << new_index; return; } - for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; if (current.combobox == sender) { const std::string config_value = @@ -96,11 +101,12 @@ void LanguageMozcConfigView::ItemChanged( void LanguageMozcConfigView::SliderValueChanged(views::Slider* sender) { size_t pref_id; - for (pref_id = 0; pref_id < kNumMozcIntegerPrefs; ++pref_id) { + for (pref_id = 0; pref_id < language_prefs::kNumMozcIntegerPrefs; + ++pref_id) { if (prefs_and_sliders_[pref_id].slider == sender) break; } - DCHECK(pref_id < kNumMozcIntegerPrefs); + DCHECK(pref_id < language_prefs::kNumMozcIntegerPrefs); prefs_and_sliders_[pref_id].integer_pref.SetValue(sender->value()); } @@ -158,23 +164,23 @@ void LanguageMozcConfigView::InitControlLayout() { column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, GridLayout::USE_PREF, 0, 0); - for (size_t i = 0; i < kNumMozcBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { MozcPrefAndAssociatedCheckbox& current = prefs_and_checkboxes_[i]; current.checkbox = new views::Checkbox( - l10n_util::GetString(kMozcBooleanPrefs[i].message_id)); + l10n_util::GetString(language_prefs::kMozcBooleanPrefs[i].message_id)); current.checkbox->set_listener(this); current.checkbox->set_tag(i); } - for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; current.combobox = new LanguageCombobox(current.combobox_model); current.combobox->set_listener(this); } - for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { MozcPrefAndAssociatedSlider& current = prefs_and_sliders_[i]; current.slider = new views::Slider( - kMozcIntegerPrefs[i].min_pref_value, - kMozcIntegerPrefs[i].max_pref_value, + language_prefs::kMozcIntegerPrefs[i].min_pref_value, + language_prefs::kMozcIntegerPrefs[i].max_pref_value, 1, static_cast<views::Slider::StyleFlags>( views::Slider::STYLE_DRAW_VALUE | @@ -191,23 +197,24 @@ void LanguageMozcConfigView::InitControlLayout() { layout->AddView(reset_to_defaults_button_); // Show the checkboxes. - for (size_t i = 0; i < kNumMozcBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { const MozcPrefAndAssociatedCheckbox& current = prefs_and_checkboxes_[i]; layout->StartRow(0, kColumnSetId); layout->AddView(current.checkbox, 3, 1); } // Show the comboboxes. - for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { const MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; layout->StartRow(0, kColumnSetId); layout->AddView(new views::Label(current.combobox_model->GetLabel())); layout->AddView(current.combobox); } - for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { const MozcPrefAndAssociatedSlider& current = prefs_and_sliders_[i]; layout->StartRow(0, kColumnSetId); layout->AddView(new views::Label( - l10n_util::GetString(kMozcIntegerPrefs[i].message_id))); + l10n_util::GetString( + language_prefs::kMozcIntegerPrefs[i].message_id))); layout->AddView(current.slider); } NotifyPrefChanged(); // Sync the slider with current Chrome prefs. @@ -224,12 +231,12 @@ void LanguageMozcConfigView::Observe(NotificationType type, void LanguageMozcConfigView::NotifyPrefChanged() { // Update comboboxes. // TODO(yusukes): We don't have to update all UI controls. - for (size_t i = 0; i < kNumMozcBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { MozcPrefAndAssociatedCheckbox& current = prefs_and_checkboxes_[i]; const bool checked = current.boolean_pref.GetValue(); current.checkbox->SetChecked(checked); } - for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { MozcPrefAndAssociatedCombobox& current = prefs_and_comboboxes_[i]; const std::string value = current.multiple_choice_pref.GetValue(); for (int i = 0; i < current.combobox_model->num_items(); ++i) { @@ -239,7 +246,7 @@ void LanguageMozcConfigView::NotifyPrefChanged() { } } } - for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { MozcPrefAndAssociatedSlider& current = prefs_and_sliders_[i]; const int value = current.integer_pref.GetValue(); current.slider->SetValue(value); @@ -247,17 +254,17 @@ void LanguageMozcConfigView::NotifyPrefChanged() { } void LanguageMozcConfigView::ResetToDefaults() { - for (size_t i = 0; i < kNumMozcBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { prefs_and_checkboxes_[i].boolean_pref.SetValue( - kMozcBooleanPrefs[i].default_pref_value); + language_prefs::kMozcBooleanPrefs[i].default_pref_value); } - for (size_t i = 0; i < kNumMozcMultipleChoicePrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { prefs_and_comboboxes_[i].multiple_choice_pref.SetValue( - kMozcMultipleChoicePrefs[i].default_pref_value); + language_prefs::kMozcMultipleChoicePrefs[i].default_pref_value); } - for (size_t i = 0; i < kNumMozcIntegerPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { prefs_and_sliders_[i].integer_pref.SetValue( - kMozcIntegerPrefs[i].default_pref_value); + language_prefs::kMozcIntegerPrefs[i].default_pref_value); } // Reflect the preference changes to the controls. NotifyPrefChanged(); diff --git a/chrome/browser/chromeos/options/language_mozc_config_view.h b/chrome/browser/chromeos/options/language_mozc_config_view.h index 2a798fe..e7a4066 100644 --- a/chrome/browser/chromeos/options/language_mozc_config_view.h +++ b/chrome/browser/chromeos/options/language_mozc_config_view.h @@ -83,18 +83,18 @@ class LanguageMozcConfigView : public views::ButtonListener, struct MozcPrefAndAssociatedCheckbox { BooleanPrefMember boolean_pref; views::Checkbox* checkbox; - } prefs_and_checkboxes_[kNumMozcBooleanPrefs]; + } prefs_and_checkboxes_[language_prefs::kNumMozcBooleanPrefs]; struct MozcPrefAndAssociatedCombobox { StringPrefMember multiple_choice_pref; LanguageComboboxModel<const char*>* combobox_model; LanguageCombobox* combobox; - } prefs_and_comboboxes_[kNumMozcMultipleChoicePrefs]; + } prefs_and_comboboxes_[language_prefs::kNumMozcMultipleChoicePrefs]; struct MozcPrefAndAssociatedSlider { IntegerPrefMember integer_pref; views::Slider* slider; - } prefs_and_sliders_[kNumMozcIntegerPrefs]; + } prefs_and_sliders_[language_prefs::kNumMozcIntegerPrefs]; DISALLOW_COPY_AND_ASSIGN(LanguageMozcConfigView); }; diff --git a/chrome/browser/chromeos/options/language_pinyin_config_view.cc b/chrome/browser/chromeos/options/language_pinyin_config_view.cc index 32d526a..5a78752 100644 --- a/chrome/browser/chromeos/options/language_pinyin_config_view.cc +++ b/chrome/browser/chromeos/options/language_pinyin_config_view.cc @@ -25,16 +25,19 @@ namespace chromeos { LanguagePinyinConfigView::LanguagePinyinConfigView(Profile* profile) : OptionsPageView(profile), contents_(NULL) { - for (size_t i = 0; i < kNumPinyinBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { pinyin_boolean_prefs_[i].Init( - kPinyinBooleanPrefs[i].pref_name, profile->GetPrefs(), this); + language_prefs::kPinyinBooleanPrefs[i].pref_name, profile->GetPrefs(), + this); pinyin_boolean_checkboxes_[i] = NULL; } double_pinyin_schema_.multiple_choice_pref.Init( - kPinyinDoublePinyinSchema.pref_name, profile->GetPrefs(), this); + language_prefs::kPinyinDoublePinyinSchema.pref_name, + profile->GetPrefs(), this); double_pinyin_schema_.combobox_model = - new LanguageComboboxModel<int>(&kPinyinDoublePinyinSchema); + new LanguageComboboxModel<int>( + &language_prefs::kPinyinDoublePinyinSchema); double_pinyin_schema_.combobox = NULL; } @@ -45,7 +48,8 @@ void LanguagePinyinConfigView::ButtonPressed( views::Button* sender, const views::Event& event) { views::Checkbox* checkbox = static_cast<views::Checkbox*>(sender); const int pref_id = checkbox->tag(); - DCHECK(pref_id >= 0 && pref_id < static_cast<int>(kNumPinyinBooleanPrefs)); + DCHECK(pref_id >= 0 && pref_id < static_cast<int>( + language_prefs::kNumPinyinBooleanPrefs)); pinyin_boolean_prefs_[pref_id].SetValue(checkbox->checked()); } @@ -109,9 +113,10 @@ void LanguagePinyinConfigView::InitControlLayout() { column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0); - for (size_t i = 0; i < kNumPinyinBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { pinyin_boolean_checkboxes_[i] = new views::Checkbox( - l10n_util::GetString(kPinyinBooleanPrefs[i].message_id)); + l10n_util::GetString( + language_prefs::kPinyinBooleanPrefs[i].message_id)); pinyin_boolean_checkboxes_[i]->set_listener(this); pinyin_boolean_checkboxes_[i]->set_tag(i); } @@ -120,7 +125,7 @@ void LanguagePinyinConfigView::InitControlLayout() { double_pinyin_schema_.combobox->set_listener(this); NotifyPrefChanged(); - for (size_t i = 0; i < kNumPinyinBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { layout->StartRow(0, kColumnSetId); layout->AddView(pinyin_boolean_checkboxes_[i]); } @@ -139,7 +144,7 @@ void LanguagePinyinConfigView::Observe(NotificationType type, } void LanguagePinyinConfigView::NotifyPrefChanged() { - for (size_t i = 0; i < kNumPinyinBooleanPrefs; ++i) { + for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { const bool checked = pinyin_boolean_prefs_[i].GetValue(); pinyin_boolean_checkboxes_[i]->SetChecked(checked); } diff --git a/chrome/browser/chromeos/options/language_pinyin_config_view.h b/chrome/browser/chromeos/options/language_pinyin_config_view.h index 2e01e18..a72be04 100644 --- a/chrome/browser/chromeos/options/language_pinyin_config_view.h +++ b/chrome/browser/chromeos/options/language_pinyin_config_view.h @@ -65,12 +65,14 @@ class LanguagePinyinConfigView : public views::ButtonListener, // Updates the pinyin checkboxes. void NotifyPrefChanged(); - BooleanPrefMember pinyin_boolean_prefs_[kNumPinyinBooleanPrefs]; + BooleanPrefMember pinyin_boolean_prefs_[ + language_prefs::kNumPinyinBooleanPrefs]; // TODO(yusukes): Support integer prefs if needed. views::View* contents_; // A checkboxes for Pinyin. - views::Checkbox* pinyin_boolean_checkboxes_[kNumPinyinBooleanPrefs]; + views::Checkbox* pinyin_boolean_checkboxes_[ + language_prefs::kNumPinyinBooleanPrefs]; struct DoublePinyinSchemaPrefAndAssociatedCombobox { IntegerPrefMember multiple_choice_pref; diff --git a/chrome/browser/chromeos/options/system_page_view.cc b/chrome/browser/chromeos/options/system_page_view.cc index c7cd183..c6fb721 100644 --- a/chrome/browser/chromeos/options/system_page_view.cc +++ b/chrome/browser/chromeos/options/system_page_view.cc @@ -403,7 +403,8 @@ LanguageSection::LanguageSection(Profile* profile) : SettingsPageSection(profile, IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE), xkb_modifier_combobox_(NULL), - xkb_modifier_combobox_model_(&kXkbModifierMultipleChoicePrefs), + xkb_modifier_combobox_model_( + &language_prefs::kXkbModifierMultipleChoicePrefs), xkb_auto_repeat_delay_slider_(NULL), xkb_auto_repeat_interval_slider_(NULL) { xkb_remap_search_key_pref_.Init( @@ -415,9 +416,11 @@ LanguageSection::LanguageSection(Profile* profile) xkb_auto_repeat_pref_.Init( prefs::kLanguageXkbAutoRepeatEnabled, profile->GetPrefs(), this); xkb_auto_repeat_delay_pref_.Init( - kXkbAutoRepeatDelayPref.pref_name, profile->GetPrefs(), this); + language_prefs::kXkbAutoRepeatDelayPref.pref_name, + profile->GetPrefs(), this); xkb_auto_repeat_interval_pref_.Init( - kXkbAutoRepeatIntervalPref.pref_name, profile->GetPrefs(), this); + language_prefs::kXkbAutoRepeatIntervalPref.pref_name, + profile->GetPrefs(), this); } void LanguageSection::InitContents(GridLayout* layout) { @@ -437,15 +440,15 @@ void LanguageSection::InitContents(GridLayout* layout) { xkb_auto_repeat_checkbox_->set_listener(this); xkb_auto_repeat_delay_slider_ = new views::Slider( - kXkbAutoRepeatDelayPref.min_pref_value, - kXkbAutoRepeatDelayPref.max_pref_value, + language_prefs::kXkbAutoRepeatDelayPref.min_pref_value, + language_prefs::kXkbAutoRepeatDelayPref.max_pref_value, 1, static_cast<views::Slider::StyleFlags>( views::Slider::STYLE_UPDATE_ON_RELEASE), this); xkb_auto_repeat_interval_slider_ = new views::Slider( - kXkbAutoRepeatIntervalPref.min_pref_value, - kXkbAutoRepeatIntervalPref.max_pref_value, + language_prefs::kXkbAutoRepeatIntervalPref.min_pref_value, + language_prefs::kXkbAutoRepeatIntervalPref.max_pref_value, 1, static_cast<views::Slider::StyleFlags>( views::Slider::STYLE_UPDATE_ON_RELEASE), @@ -465,7 +468,8 @@ void LanguageSection::InitContents(GridLayout* layout) { layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, quad_column_view_set_id()); layout->AddView(new views::Label( - l10n_util::GetString(kXkbAutoRepeatDelayPref.message_id)), + l10n_util::GetString( + language_prefs::kXkbAutoRepeatDelayPref.message_id)), 1, 1, GridLayout::LEADING, GridLayout::CENTER); layout->AddView(new views::Label( l10n_util::GetString( @@ -478,7 +482,8 @@ void LanguageSection::InitContents(GridLayout* layout) { layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, quad_column_view_set_id()); layout->AddView(new views::Label( - l10n_util::GetString(kXkbAutoRepeatIntervalPref.message_id)), + l10n_util::GetString( + language_prefs::kXkbAutoRepeatIntervalPref.message_id)), 1, 1, GridLayout::LEADING, GridLayout::CENTER); layout->AddView(new views::Label( l10n_util::GetString( @@ -509,17 +514,17 @@ void LanguageSection::ItemChanged(views::Combobox* sender, default: LOG(ERROR) << "Unexpected mapping: " << new_index; /* fall through */ - case kNoRemap: + case language_prefs::kNoRemap: xkb_remap_search_key_pref_.SetValue(kSearchKey); xkb_remap_control_key_pref_.SetValue(kLeftControlKey); xkb_remap_alt_key_pref_.SetValue(kLeftAltKey); break; - case kSwapCtrlAndAlt: + case language_prefs::kSwapCtrlAndAlt: xkb_remap_search_key_pref_.SetValue(kSearchKey); xkb_remap_control_key_pref_.SetValue(kLeftAltKey); xkb_remap_alt_key_pref_.SetValue(kLeftControlKey); break; - case kSwapSearchAndCtrl: + case language_prefs::kSwapSearchAndCtrl: xkb_remap_search_key_pref_.SetValue(kLeftControlKey); xkb_remap_control_key_pref_.SetValue(kSearchKey); xkb_remap_alt_key_pref_.SetValue(kLeftAltKey); @@ -545,29 +550,32 @@ void LanguageSection::NotifyPrefChanged(const std::string* pref_name) { if ((search_remap == kSearchKey) && (control_remap == kLeftControlKey) && (alt_remap == kLeftAltKey)) { - xkb_modifier_combobox_->SetSelectedItem(kNoRemap); + xkb_modifier_combobox_->SetSelectedItem(language_prefs::kNoRemap); } else if ((search_remap == kLeftControlKey) && (control_remap == kSearchKey) && (alt_remap == kLeftAltKey)) { - xkb_modifier_combobox_->SetSelectedItem(kSwapSearchAndCtrl); + xkb_modifier_combobox_->SetSelectedItem( + language_prefs::kSwapSearchAndCtrl); } else if ((search_remap == kSearchKey) && (control_remap == kLeftAltKey) && (alt_remap == kLeftControlKey)) { - xkb_modifier_combobox_->SetSelectedItem(kSwapCtrlAndAlt); + xkb_modifier_combobox_->SetSelectedItem(language_prefs::kSwapCtrlAndAlt); } else { LOG(ERROR) << "Unexpected mapping. The prefs are updated by DOMUI?"; - xkb_modifier_combobox_->SetSelectedItem(kNoRemap); + xkb_modifier_combobox_->SetSelectedItem(language_prefs::kNoRemap); } } if (!pref_name || *pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { const bool enabled = xkb_auto_repeat_pref_.GetValue(); xkb_auto_repeat_checkbox_->SetChecked(enabled); } - if (!pref_name || *pref_name == kXkbAutoRepeatDelayPref.pref_name) { + if (!pref_name || + *pref_name == language_prefs::kXkbAutoRepeatDelayPref.pref_name) { const int delay_value = xkb_auto_repeat_delay_pref_.GetValue(); xkb_auto_repeat_delay_slider_->SetValue(delay_value); } - if (!pref_name || *pref_name == kXkbAutoRepeatIntervalPref.pref_name) { + if (!pref_name || + *pref_name == language_prefs::kXkbAutoRepeatIntervalPref.pref_name) { const int interval_value = xkb_auto_repeat_interval_pref_.GetValue(); xkb_auto_repeat_interval_slider_->SetValue(interval_value); } |