| 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/options/language_config_view.h" | 5 #include "chrome/browser/chromeos/options/language_config_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chromeos/cros/cros_library.h" | 14 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 15 #include "chrome/browser/chromeos/cros/language_library.h" | 15 #include "chrome/browser/chromeos/cros/language_library.h" |
| 16 #include "chrome/browser/chromeos/options/language_hangul_config_view.h" | 16 #include "chrome/browser/chromeos/options/language_hangul_config_view.h" |
| 17 #include "chrome/browser/chromeos/options/language_pinyin_config_view.h" |
| 17 #include "chrome/browser/chromeos/options/options_window_view.h" | 18 #include "chrome/browser/chromeos/options/options_window_view.h" |
| 18 #include "chrome/browser/chromeos/preferences.h" | 19 #include "chrome/browser/chromeos/preferences.h" |
| 19 #include "chrome/browser/language_combobox_model.h" | 20 #include "chrome/browser/language_combobox_model.h" |
| 20 #include "chrome/browser/pref_service.h" | 21 #include "chrome/browser/pref_service.h" |
| 21 #include "chrome/browser/views/restart_message_box.h" | 22 #include "chrome/browser/views/restart_message_box.h" |
| 22 #include "chrome/common/notification_type.h" | 23 #include "chrome/common/notification_type.h" |
| 23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 24 #include "gfx/font.h" | 25 #include "gfx/font.h" |
| 25 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
| 26 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 const char kDefaultLanguageCode[] = "eng"; | 42 const char kDefaultLanguageCode[] = "eng"; |
| 42 | 43 |
| 43 // Creates the LanguageHangulConfigView. The function is used to create | 44 // Creates the LanguageHangulConfigView. The function is used to create |
| 44 // the object via a function pointer. See also InitInputMethodConfigViewMap(). | 45 // the object via a function pointer. See also InitInputMethodConfigViewMap(). |
| 45 views::DialogDelegate* CreateLanguageHangulConfigView(Profile* profile) { | 46 views::DialogDelegate* CreateLanguageHangulConfigView(Profile* profile) { |
| 46 return new LanguageHangulConfigView(profile); | 47 return new LanguageHangulConfigView(profile); |
| 47 } | 48 } |
| 49 views::DialogDelegate* CreateLanguagePinyinConfigView(Profile* profile) { |
| 50 return new LanguagePinyinConfigView(profile); |
| 51 } |
| 48 | 52 |
| 49 // The tags are used to identify buttons in ButtonPressed(). | 53 // The tags are used to identify buttons in ButtonPressed(). |
| 50 enum ButtonTag { | 54 enum ButtonTag { |
| 51 kAddLanguageButton, | 55 kAddLanguageButton, |
| 52 kChangeUiLanguageButton, | 56 kChangeUiLanguageButton, |
| 53 kConfigureInputMethodButton, | 57 kConfigureInputMethodButton, |
| 54 kRemoveLanguageButton, | 58 kRemoveLanguageButton, |
| 55 kSelectInputMethodButton, | 59 kSelectInputMethodButton, |
| 56 }; | 60 }; |
| 57 | 61 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 557 |
| 554 // Select the first row in the language table. | 558 // Select the first row in the language table. |
| 555 // There should be at least one language in the table. | 559 // There should be at least one language in the table. |
| 556 CHECK(!preferred_language_codes_.empty()); | 560 CHECK(!preferred_language_codes_.empty()); |
| 557 preferred_language_table_->SelectRow(0); | 561 preferred_language_table_->SelectRow(0); |
| 558 } | 562 } |
| 559 | 563 |
| 560 void LanguageConfigView::InitInputMethodConfigViewMap() { | 564 void LanguageConfigView::InitInputMethodConfigViewMap() { |
| 561 input_method_config_view_map_["hangul"] = | 565 input_method_config_view_map_["hangul"] = |
| 562 CreateLanguageHangulConfigView; | 566 CreateLanguageHangulConfigView; |
| 567 input_method_config_view_map_["pinyin"] = |
| 568 CreateLanguagePinyinConfigView; |
| 563 } | 569 } |
| 564 | 570 |
| 565 void LanguageConfigView::InitInputMethodIdMaps() { | 571 void LanguageConfigView::InitInputMethodIdMaps() { |
| 566 // GetSupportedLanguages() never return NULL. | 572 // GetSupportedLanguages() never return NULL. |
| 567 scoped_ptr<InputMethodDescriptors> supported_input_methods( | 573 scoped_ptr<InputMethodDescriptors> supported_input_methods( |
| 568 CrosLibrary::Get()->GetLanguageLibrary()->GetSupportedInputMethods()); | 574 CrosLibrary::Get()->GetLanguageLibrary()->GetSupportedInputMethods()); |
| 569 for (size_t i = 0; i < supported_input_methods->size(); ++i) { | 575 for (size_t i = 0; i < supported_input_methods->size(); ++i) { |
| 570 const InputMethodDescriptor& input_method = supported_input_methods->at(i); | 576 const InputMethodDescriptor& input_method = supported_input_methods->at(i); |
| 571 const std::string language_code = | 577 const std::string language_code = |
| 572 LanguageLibrary::GetLanguageCodeFromDescriptor(input_method); | 578 LanguageLibrary::GetLanguageCodeFromDescriptor(input_method); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 // "t" is used as the language code for input methods that don't fall | 814 // "t" is used as the language code for input methods that don't fall |
| 809 // under any other languages. | 815 // under any other languages. |
| 810 if (language_name == L"t") { | 816 if (language_name == L"t") { |
| 811 return l10n_util::GetString( | 817 return l10n_util::GetString( |
| 812 IDS_OPTIONS_SETTINGS_LANGUAGES_OTHERS); | 818 IDS_OPTIONS_SETTINGS_LANGUAGES_OTHERS); |
| 813 } | 819 } |
| 814 return language_name; | 820 return language_name; |
| 815 } | 821 } |
| 816 | 822 |
| 817 } // namespace chromeos | 823 } // namespace chromeos |
| OLD | NEW |