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/input_method/input_method_util.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/chromeos/cros/keyboard_library.h" | 22 #include "chrome/browser/chromeos/cros/keyboard_library.h" |
23 #include "chrome/browser/chromeos/language_preferences.h" | 23 #include "chrome/browser/chromeos/language_preferences.h" |
24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
25 #include "third_party/icu/public/common/unicode/uloc.h" | 25 #include "third_party/icu/public/common/unicode/uloc.h" |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // Map from language code to associated input method IDs, etc. | 29 // Map from language code to associated input method IDs, etc. |
30 typedef std::multimap<std::string, std::string> LanguageCodeToIdsMap; | 30 typedef std::multimap<std::string, std::string> LanguageCodeToIdsMap; |
31 struct IdMaps { | 31 struct IdMaps { |
32 LanguageCodeToIdsMap* language_code_to_ids; | 32 scoped_ptr<LanguageCodeToIdsMap> language_code_to_ids; |
33 std::map<std::string, std::string>* id_to_language_code; | 33 scoped_ptr<std::map<std::string, std::string> > id_to_language_code; |
34 std::map<std::string, std::string>* id_to_display_name; | 34 scoped_ptr<std::map<std::string, std::string> > id_to_display_name; |
35 | 35 |
36 private: | 36 private: |
37 IdMaps() : language_code_to_ids(NULL), | 37 IdMaps() : language_code_to_ids(NULL), |
38 id_to_language_code(NULL), | 38 id_to_language_code(NULL), |
39 id_to_display_name(NULL) { | 39 id_to_display_name(NULL) { |
40 chromeos::InputMethodLibrary* library = | 40 chromeos::InputMethodLibrary* library = |
41 chromeos::CrosLibrary::Get()->GetInputMethodLibrary(); | 41 chromeos::CrosLibrary::Get()->GetInputMethodLibrary(); |
42 scoped_ptr<chromeos::InputMethodDescriptors> supported_input_methods( | 42 scoped_ptr<chromeos::InputMethodDescriptors> supported_input_methods( |
43 library->GetSupportedInputMethods()); | 43 library->GetSupportedInputMethods()); |
44 if (supported_input_methods->size() <= 1) { | 44 if (supported_input_methods->size() <= 1) { |
45 LOG(ERROR) << "GetSupportedInputMethods returned a fallback ID"; | 45 LOG(ERROR) << "GetSupportedInputMethods returned a fallback ID"; |
46 // TODO(yusukes): Handle this error in nicer way. | 46 // TODO(yusukes): Handle this error in nicer way. |
47 } | 47 } |
48 | 48 |
49 language_code_to_ids = new LanguageCodeToIdsMap; | 49 language_code_to_ids.reset(new LanguageCodeToIdsMap); |
50 id_to_language_code = new std::map<std::string, std::string>; | 50 id_to_language_code.reset(new std::map<std::string, std::string>); |
51 id_to_display_name = new std::map<std::string, std::string>; | 51 id_to_display_name.reset(new std::map<std::string, std::string>); |
52 | 52 |
53 // Build the id to descriptor map for handling kExtraLanguages later. | 53 // Build the id to descriptor map for handling kExtraLanguages later. |
54 typedef std::map<std::string, | 54 typedef std::map<std::string, |
55 const chromeos::InputMethodDescriptor*> DescMap; | 55 const chromeos::InputMethodDescriptor*> DescMap; |
56 DescMap id_to_descriptor_map; | 56 DescMap id_to_descriptor_map; |
57 | 57 |
58 for (size_t i = 0; i < supported_input_methods->size(); ++i) { | 58 for (size_t i = 0; i < supported_input_methods->size(); ++i) { |
59 const chromeos::InputMethodDescriptor& input_method = | 59 const chromeos::InputMethodDescriptor& input_method = |
60 supported_input_methods->at(i); | 60 supported_input_methods->at(i); |
61 const std::string language_code = | 61 const std::string language_code = |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 value.string_list_value = input_method_ids; | 611 value.string_list_value = input_method_ids; |
612 InputMethodLibrary* library = CrosLibrary::Get()->GetInputMethodLibrary(); | 612 InputMethodLibrary* library = CrosLibrary::Get()->GetInputMethodLibrary(); |
613 library->SetImeConfig(kGeneralSectionName, kPreloadEnginesConfigName, value); | 613 library->SetImeConfig(kGeneralSectionName, kPreloadEnginesConfigName, value); |
614 if (!initial_input_method_id.empty()) { | 614 if (!initial_input_method_id.empty()) { |
615 library->ChangeInputMethod(initial_input_method_id); | 615 library->ChangeInputMethod(initial_input_method_id); |
616 } | 616 } |
617 } | 617 } |
618 | 618 |
619 } // namespace input_method | 619 } // namespace input_method |
620 } // namespace chromeos | 620 } // namespace chromeos |
OLD | NEW |