Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: chrome/browser/chromeos/preferences.cc

Issue 9999018: chrome/browser/chromeos/input_method/ refactoring [part 6 of 6] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, remove preferences.h and language_preference.* from this CL Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/preferences.h" 5 #include "chrome/browser/chromeos/preferences.h"
6 6
7 #include "base/chromeos/chromeos_version.h" 7 #include "base/chromeos/chromeos_version.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 616
617 void Preferences::SetLanguageConfigStringListAsCSV(const char* section, 617 void Preferences::SetLanguageConfigStringListAsCSV(const char* section,
618 const char* name, 618 const char* name,
619 const std::string& value) { 619 const std::string& value) {
620 VLOG(1) << "Setting " << name << " to '" << value << "'"; 620 VLOG(1) << "Setting " << name << " to '" << value << "'";
621 621
622 std::vector<std::string> split_values; 622 std::vector<std::string> split_values;
623 if (!value.empty()) 623 if (!value.empty())
624 base::SplitString(value, ',', &split_values); 624 base::SplitString(value, ',', &split_values);
625 625
626 if (section == std::string(language_prefs::kGeneralSectionName) &&
627 name == std::string(language_prefs::kPreloadEnginesConfigName)) {
628 input_method_manager_->EnableInputMethods(split_values);
629 return;
630 }
631
626 // We should call the cros API even when |value| is empty, to disable default 632 // We should call the cros API even when |value| is empty, to disable default
627 // config. 633 // config.
628 SetLanguageConfigStringList(section, name, split_values); 634 SetLanguageConfigStringList(section, name, split_values);
629 } 635 }
630 636
631 void Preferences::SetInputMethodList() { 637 void Preferences::SetInputMethodList() {
632 // When |preload_engines_| are set, InputMethodManager::ChangeInputMethod() 638 // When |preload_engines_| are set, InputMethodManager::ChangeInputMethod()
633 // might be called to change the current input method to the first one in the 639 // might be called to change the current input method to the first one in the
634 // |preload_engines_| list. This also updates previous/current input method 640 // |preload_engines_| list. This also updates previous/current input method
635 // prefs. That's why GetValue() calls are placed before the 641 // prefs. That's why GetValue() calls are placed before the
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 return; 693 return;
688 694
689 input_method::AutoRepeatRate rate; 695 input_method::AutoRepeatRate rate;
690 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); 696 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue();
691 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); 697 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue();
692 DCHECK(rate.initial_delay_in_ms > 0); 698 DCHECK(rate.initial_delay_in_ms > 0);
693 DCHECK(rate.repeat_interval_in_ms > 0); 699 DCHECK(rate.repeat_interval_in_ms > 0);
694 input_method::XKeyboard::SetAutoRepeatRate(rate); 700 input_method::XKeyboard::SetAutoRepeatRate(rate);
695 } 701 }
696 702
697 void Preferences::UpdateVirturalKeyboardPreference(PrefService* prefs) { 703 void Preferences::UpdateVirturalKeyboardPreference(PrefService* prefs) {
kinaba 2012/04/13 08:08:53 Not directly related to this CL, but could you add
Yusuke Sato 2012/04/13 08:59:28 Done.
698 const DictionaryValue* virtual_keyboard_pref = 704 const DictionaryValue* virtual_keyboard_pref =
699 prefs->GetDictionary(prefs::kLanguagePreferredVirtualKeyboard); 705 prefs->GetDictionary(prefs::kLanguagePreferredVirtualKeyboard);
700 DCHECK(virtual_keyboard_pref); 706 DCHECK(virtual_keyboard_pref);
701 707
702 input_method::InputMethodManager* input_method_manager = 708 // TODO(yusukes): Clear all virtual keyboard preferences here.
703 input_method::InputMethodManager::GetInstance();
704 input_method_manager->ClearAllVirtualKeyboardPreferences();
705
706 std::string url; 709 std::string url;
707 std::vector<std::string> layouts_to_remove; 710 std::vector<std::string> layouts_to_remove;
708 for (DictionaryValue::key_iterator iter = virtual_keyboard_pref->begin_keys(); 711 for (DictionaryValue::key_iterator iter = virtual_keyboard_pref->begin_keys();
709 iter != virtual_keyboard_pref->end_keys(); 712 iter != virtual_keyboard_pref->end_keys();
710 ++iter) { 713 ++iter) {
711 const std::string& layout_id = *iter; // e.g. "us", "handwriting-vk" 714 const std::string& layout_id = *iter; // e.g. "us", "handwriting-vk"
712 if (!virtual_keyboard_pref->GetString(layout_id, &url)) 715 if (!virtual_keyboard_pref->GetString(layout_id, &url))
713 continue; 716 continue;
714 if (!input_method_manager->SetVirtualKeyboardPreference( 717 // TODO(yusukes): add the virtual keyboard preferences here.
715 layout_id, GURL(url))) {
716 // Either |layout_id| or |url| is invalid. Remove the key from |prefs|
717 // later.
718 layouts_to_remove.push_back(layout_id);
719 LOG(ERROR) << "Removing invalid virtual keyboard pref: layout="
720 << layout_id;
721 }
722 } 718 }
723 719
724 // Remove invalid prefs. 720 // Remove invalid prefs.
725 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); 721 DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard);
726 DictionaryValue* pref_value = updater.Get(); 722 DictionaryValue* pref_value = updater.Get();
727 for (size_t i = 0; i < layouts_to_remove.size(); ++i) { 723 for (size_t i = 0; i < layouts_to_remove.size(); ++i) {
728 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); 724 pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL);
729 } 725 }
730 } 726 }
731 727
732 } // namespace chromeos 728 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698