diff options
author | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-16 11:01:17 +0000 |
---|---|---|
committer | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-16 11:01:17 +0000 |
commit | a9a8181f080a61ea6b7632784ec1d748717e8c4e (patch) | |
tree | 44329b54d1a8b103a9e88cd61975eedf22f42079 /chrome/browser/ui | |
parent | 8eb127e07794373951ee9935e73d06b35082a9b0 (diff) | |
download | chromium_src-a9a8181f080a61ea6b7632784ec1d748717e8c4e.zip chromium_src-a9a8181f080a61ea6b7632784ec1d748717e8c4e.tar.gz chromium_src-a9a8181f080a61ea6b7632784ec1d748717e8c4e.tar.bz2 |
Fix memory leaks caused by chrome/browser/chromeos/input_method/*.cc (part 3)
- Removed the IdMaps singleton class from input_method_util.cc to remove Valgrind warnings (see the issue 48130).
- Put all free functions in input_method_util.cc in a newly created class InputMethodUtil. Moved all std::sets and std::maps in IdMaps to the new class.
- Add an instance of InputMethodUtil to InputMethodManagerImpl.
- Removed wide string and UTF-8 string versions of GetString function from input_method_util.h since using wstring is now highly discouraged and the UTF-8 version is unused.
- Replaced all IME related std::wstrings with string16.
BUG=chromium:48130
TEST=ran unit_tests under valgrind (without suppressions) and confirmed that no leaks were reported.
Review URL: http://codereview.chromium.org/7903004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
4 files changed, 24 insertions, 10 deletions
diff --git a/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc index 112148e..b2c658a 100644 --- a/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc @@ -216,8 +216,8 @@ ListValue* NetworkScreenHandler::GetInputMethods() { for (size_t i = 0; i < input_methods->size(); ++i) { DictionaryValue* input_method = new DictionaryValue; input_method->SetString("value", input_methods->at(i).id()); - input_method->SetString("title", - WideToUTF16(InputMethodMenu::GetTextForMenu(input_methods->at(i)))); + input_method->SetString( + "title", InputMethodMenu::GetTextForMenu(input_methods->at(i))); input_method->SetBoolean("selected", input_methods->at(i).id() == current_input_method_id); input_methods_list->Append(input_method); diff --git a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc index da02d7f..392a7f4 100644 --- a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc @@ -13,6 +13,7 @@ #include "base/values.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/chromeos/input_method/input_method_manager.h" #include "chrome/browser/chromeos/input_method/input_method_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -85,15 +86,20 @@ void CrosLanguageOptionsHandler::RegisterMessages() { ListValue* CrosLanguageOptionsHandler::GetInputMethodList( const input_method::InputMethodDescriptors& descriptors) { + input_method::InputMethodManager* manager = + input_method::InputMethodManager::GetInstance(); + ListValue* input_method_list = new ListValue(); for (size_t i = 0; i < descriptors.size(); ++i) { const input_method::InputMethodDescriptor& descriptor = descriptors[i]; const std::string language_code = - input_method::GetLanguageCodeFromDescriptor(descriptor); + manager->GetInputMethodUtil()->GetLanguageCodeFromDescriptor( + descriptor); const std::string display_name = - input_method::GetInputMethodDisplayNameFromId(descriptor.id()); + manager->GetInputMethodUtil()->GetInputMethodDisplayNameFromId( + descriptor.id()); DictionaryValue* dictionary = new DictionaryValue(); dictionary->SetString("id", descriptor.id()); @@ -124,12 +130,16 @@ ListValue* CrosLanguageOptionsHandler::GetInputMethodList( ListValue* CrosLanguageOptionsHandler::GetLanguageList( const input_method::InputMethodDescriptors& descriptors) { + input_method::InputMethodManager* manager = + input_method::InputMethodManager::GetInstance(); + std::set<std::string> language_codes; // Collect the language codes from the supported input methods. for (size_t i = 0; i < descriptors.size(); ++i) { const input_method::InputMethodDescriptor& descriptor = descriptors[i]; const std::string language_code = - input_method::GetLanguageCodeFromDescriptor(descriptor); + manager->GetInputMethodUtil()->GetLanguageCodeFromDescriptor( + descriptor); language_codes.insert(language_code); } // Collect the language codes from kExtraLanguages. @@ -153,9 +163,10 @@ ListValue* CrosLanguageOptionsHandler::GetLanguageList( for (std::set<std::string>::const_iterator iter = language_codes.begin(); iter != language_codes.end(); ++iter) { const string16 display_name = - input_method::GetLanguageDisplayNameFromCode(*iter); + input_method::InputMethodUtil::GetLanguageDisplayNameFromCode(*iter); const string16 native_display_name = - input_method::GetLanguageNativeDisplayNameFromCode(*iter); + input_method::InputMethodUtil::GetLanguageNativeDisplayNameFromCode( + *iter); display_names.push_back(display_name); language_map[display_name] = std::make_pair(*iter, native_display_name); diff --git a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.h b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.h index fda593c..31ee318 100644 --- a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.h +++ b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H_ #pragma once -#include "chrome/browser/chromeos/input_method/input_method_util.h" +#include "chrome/browser/chromeos/input_method/ibus_controller.h" #include "chrome/browser/ui/webui/options/language_options_handler.h" namespace chromeos { diff --git a/chrome/browser/ui/webui/options/chromeos/virtual_keyboard_manager_handler.cc b/chrome/browser/ui/webui/options/chromeos/virtual_keyboard_manager_handler.cc index 44fa2c2..ee009c9 100644 --- a/chrome/browser/ui/webui/options/chromeos/virtual_keyboard_manager_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/virtual_keyboard_manager_handler.cc @@ -203,10 +203,13 @@ ListValue* VirtualKeyboardManagerHandler::CreateVirtualKeyboardList( layout_list->Append(dictionary); // Set layout id as well as its human readable form. + ime::InputMethodManager* manager = ime::InputMethodManager::GetInstance(); const ime::InputMethodDescriptor* desc = - ime::GetInputMethodDescriptorFromXkbId(layout_id); + manager->GetInputMethodUtil()->GetInputMethodDescriptorFromXkbId( + layout_id); const std::string layout_name = desc ? - ime::GetInputMethodDisplayNameFromId(desc->id()) : layout_id; + manager->GetInputMethodUtil()->GetInputMethodDisplayNameFromId( + desc->id()) : layout_id; dictionary->SetString("layout", layout_id); dictionary->SetString("layoutName", layout_name); |