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

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

Issue 312023002: Sync starting language and input method preferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes in progress, probably broken... Created 6 years, 6 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
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/browser/chromeos/preferences_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 7 #include <algorithm>
8 8
9 #include "ash/autoclick/autoclick_controller.h" 9 #include "ash/autoclick/autoclick_controller.h"
10 #include "ash/magnifier/magnifier_constants.h" 10 #include "ash/magnifier/magnifier_constants.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/i18n/time_formatting.h" 13 #include "base/i18n/time_formatting.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/prefs/pref_member.h" 15 #include "base/prefs/pref_member.h"
16 #include "base/prefs/pref_registry_simple.h" 16 #include "base/prefs/pref_registry_simple.h"
17 #include "base/prefs/scoped_user_pref_update.h" 17 #include "base/prefs/scoped_user_pref_update.h"
18 #include "base/strings/string_split.h" 18 #include "base/strings/string_split.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/sys_info.h" 21 #include "base/sys_info.h"
22 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
24 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 24 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
25 #include "chrome/browser/chromeos/drive/file_system_util.h" 25 #include "chrome/browser/chromeos/drive/file_system_util.h"
26 #include "chrome/browser/chromeos/input_method/input_method_util.h" 26 #include "chrome/browser/chromeos/input_method/input_method_util.h"
27 #include "chrome/browser/chromeos/login/login_utils.h" 27 #include "chrome/browser/chromeos/login/login_utils.h"
28 #include "chrome/browser/chromeos/login/users/user.h" 28 #include "chrome/browser/chromeos/login/users/user.h"
29 #include "chrome/browser/chromeos/system/input_device_settings.h" 29 #include "chrome/browser/chromeos/system/input_device_settings.h"
30 #include "chrome/browser/download/download_prefs.h" 30 #include "chrome/browser/download/download_prefs.h"
31 #include "chrome/browser/prefs/pref_service_syncable.h" 31 #include "chrome/browser/prefs/pref_service_syncable.h"
32 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
34 #include "chromeos/chromeos_switches.h" 34 #include "chromeos/chromeos_switches.h"
35 #include "chromeos/ime/component_extension_ime_manager.h"
35 #include "chromeos/ime/extension_ime_util.h" 36 #include "chromeos/ime/extension_ime_util.h"
36 #include "chromeos/ime/ime_keyboard.h" 37 #include "chromeos/ime/ime_keyboard.h"
37 #include "chromeos/ime/input_method_manager.h" 38 #include "chromeos/ime/input_method_manager.h"
38 #include "chromeos/system/statistics_provider.h" 39 #include "chromeos/system/statistics_provider.h"
39 #include "components/feedback/tracing_manager.h" 40 #include "components/feedback/tracing_manager.h"
40 #include "components/pref_registry/pref_registry_syncable.h" 41 #include "components/pref_registry/pref_registry_syncable.h"
41 #include "third_party/icu/source/i18n/unicode/timezone.h" 42 #include "third_party/icu/source/i18n/unicode/timezone.h"
43 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/events/event_constants.h" 44 #include "ui/events/event_constants.h"
43 #include "ui/events/event_utils.h" 45 #include "ui/events/event_utils.h"
44 #include "url/gurl.h" 46 #include "url/gurl.h"
45 47
46 namespace chromeos { 48 namespace chromeos {
47 49
50 namespace {
51
48 static const char kFallbackInputMethodLocale[] = "en-US"; 52 static const char kFallbackInputMethodLocale[] = "en-US";
49 53
54 // Removes unsupported languages from |values|.
55 void CheckLanguages(std::vector<std::string>& values) {
56 std::vector<std::string>::iterator iter = values.begin();
57 while (iter != values.end()) {
58 std::string locale = *iter;
59 if (l10n_util::CheckAndResolveLocale(locale, &locale) &&
60 locale == *iter)
61 ++iter;
62 else
63 iter = values.erase(iter);
64 }
65 }
66
67 // Removes unsupported input method IDs from |values|.
68 void CheckInputMethodIDs(
69 std::vector<std::string>& values,
70 const input_method::InputMethodDescriptors& supported) {
71 // Convert legacay descriptors to input method extension IDs.
72 std::vector<std::string> input_method_ids;
73 for (size_t i = 0; i < input_method_ids.size(); i++) {
74 input_method_ids.push_back(
75 extension_ime_util::GetInputMethodIDByEngineID(supported[i].id()));
76 }
77
78 // Remove values that aren't in the list of input method IDs.
79 std::vector<std::string>::iterator value_iter = values.begin();
80 while (value_iter != values.end()) {
81 if (std::find(input_method_ids.begin(),
82 input_method_ids.end(),
83 *value_iter) != input_method_ids.end()) {
84 ++value_iter;
85 } else {
86 value_iter = values.erase(value_iter);
87 }
88 }
89 }
90
91 // Returns the result of merging supported tokens from the CSV string
92 // |new_value| into |old_value| for the given pref. Quadratic runtime; use only
93 // for small lists.
94 std::string MergeCSVPrefs(const std::string& old_value,
95 const std::string& new_value,
96 const std::string& pref_name) {
97 std::vector<std::string> old_tokens;
98 std::vector<std::string> new_tokens;
99
100 base::SplitString(old_value, ',', &old_tokens);
101 base::SplitString(new_value, ',', &new_tokens);
102
103 if (pref_name == prefs::kLanguagePreferredLanguages) {
104 CheckLanguages(new_tokens);
105 } else if (pref_name == prefs::kLanguagePreloadEngines ||
106 pref_name == prefs::kLanguageEnabledExtensionImes) {
107 input_method::InputMethodManager* manager =
108 input_method::InputMethodManager::Get();
109 // Supported input methods.
110 scoped_ptr<input_method::InputMethodDescriptors> descriptors;
111
112 if (pref_name == prefs::kLanguagePreloadEngines) {
113 // Set the known input methods.
114 descriptors = manager->GetSupportedInputMethods();
115 // Add the available component extension IMEs.
116 ComponentExtensionIMEManager* component_extension_manager =
117 input_method::InputMethodManager::Get()->
118 GetComponentExtensionIMEManager();
119 if (component_extension_manager->IsInitialized()) {
120 input_method::InputMethodDescriptors component_descriptors =
121 component_extension_manager->GetAllIMEAsInputMethodDescriptor();
122 descriptors->insert(descriptors->end(),
123 component_descriptors.begin(),
124 component_descriptors.end());
125 }
126 } else {
127 descriptors.reset(new input_method::InputMethodDescriptors);
128 manager->GetInputMethodExtensions(descriptors.get());
129 }
130 CheckInputMethodIDs(new_tokens, *descriptors);
131 } else {
132 NOTREACHED() << "Attempting to merge an invalid preference.";
133 }
134 return JoinString(old_tokens, ',');
135 }
136
137 } // anonymous namespace
138
50 Preferences::Preferences() 139 Preferences::Preferences()
51 : prefs_(NULL), 140 : prefs_(NULL),
52 input_method_manager_(input_method::InputMethodManager::Get()), 141 input_method_manager_(input_method::InputMethodManager::Get()),
53 user_(NULL), 142 user_(NULL),
54 user_is_primary_(false) { 143 user_is_primary_(false) {
55 // Do not observe shell, if there is no shell instance; e.g., in some unit 144 // Do not observe shell, if there is no shell instance; e.g., in some unit
56 // tests. 145 // tests.
57 if (ash::Shell::HasInstance()) 146 if (ash::Shell::HasInstance())
58 ash::Shell::GetInstance()->AddShellObserver(this); 147 ash::Shell::GetInstance()->AddShellObserver(this);
59 } 148 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // We don't sync prefs::kLanguageCurrentInputMethod and PreviousInputMethod 295 // We don't sync prefs::kLanguageCurrentInputMethod and PreviousInputMethod
207 // because they're just used to track the logout state of the device. 296 // because they're just used to track the logout state of the device.
208 registry->RegisterStringPref( 297 registry->RegisterStringPref(
209 prefs::kLanguageCurrentInputMethod, 298 prefs::kLanguageCurrentInputMethod,
210 "", 299 "",
211 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 300 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
212 registry->RegisterStringPref( 301 registry->RegisterStringPref(
213 prefs::kLanguagePreviousInputMethod, 302 prefs::kLanguagePreviousInputMethod,
214 "", 303 "",
215 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 304 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
216 // We don't sync the list of input methods and preferred languages since a
217 // user might use two or more devices with different hardware keyboards.
218 // crosbug.com/15181
219 registry->RegisterStringPref( 305 registry->RegisterStringPref(
220 prefs::kLanguagePreferredLanguages, 306 prefs::kLanguagePreferredLanguages,
221 kFallbackInputMethodLocale, 307 kFallbackInputMethodLocale,
222 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 308 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
223 registry->RegisterStringPref( 309 registry->RegisterStringPref(
310 prefs::kLanguagePreferredLanguagesSyncable,
311 "",
312 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
313 registry->RegisterStringPref(
224 prefs::kLanguagePreloadEngines, 314 prefs::kLanguagePreloadEngines,
225 hardware_keyboard_id, 315 hardware_keyboard_id,
226 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 316 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
227 registry->RegisterStringPref( 317 registry->RegisterStringPref(
318 prefs::kLanguagePreloadEnginesSyncable,
319 "",
320 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
321 registry->RegisterStringPref(
228 prefs::kLanguageEnabledExtensionImes, 322 prefs::kLanguageEnabledExtensionImes,
229 "", 323 "",
230 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 324 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
325 registry->RegisterStringPref(
326 prefs::kLanguageEnabledExtensionImesSyncable,
327 "",
328 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
329 registry->RegisterBooleanPref(
330 prefs::kLanguageShouldMergeInputMethods,
331 false,
332 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
231 333
232 registry->RegisterIntegerPref( 334 registry->RegisterIntegerPref(
233 prefs::kLanguageRemapSearchKeyTo, 335 prefs::kLanguageRemapSearchKeyTo,
234 input_method::kSearchKey, 336 input_method::kSearchKey,
235 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); 337 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF);
236 registry->RegisterIntegerPref( 338 registry->RegisterIntegerPref(
237 prefs::kLanguageRemapControlKeyTo, 339 prefs::kLanguageRemapControlKeyTo,
238 input_method::kControlKey, 340 input_method::kControlKey,
239 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF); 341 user_prefs::PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF);
240 registry->RegisterIntegerPref( 342 registry->RegisterIntegerPref(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 prefs, callback); 424 prefs, callback);
323 natural_scroll_.Init(prefs::kNaturalScroll, prefs, callback); 425 natural_scroll_.Init(prefs::kNaturalScroll, prefs, callback);
324 mouse_sensitivity_.Init(prefs::kMouseSensitivity, prefs, callback); 426 mouse_sensitivity_.Init(prefs::kMouseSensitivity, prefs, callback);
325 touchpad_sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, callback); 427 touchpad_sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, callback);
326 primary_mouse_button_right_.Init(prefs::kPrimaryMouseButtonRight, 428 primary_mouse_button_right_.Init(prefs::kPrimaryMouseButtonRight,
327 prefs, callback); 429 prefs, callback);
328 download_default_directory_.Init(prefs::kDownloadDefaultDirectory, 430 download_default_directory_.Init(prefs::kDownloadDefaultDirectory,
329 prefs, callback); 431 prefs, callback);
330 touch_hud_projection_enabled_.Init(prefs::kTouchHudProjectionEnabled, 432 touch_hud_projection_enabled_.Init(prefs::kTouchHudProjectionEnabled,
331 prefs, callback); 433 prefs, callback);
434 preferred_languages_.Init(prefs::kLanguagePreferredLanguages,
435 prefs, callback);
436 preferred_languages_syncable_.Init(prefs::kLanguagePreferredLanguagesSyncable,
437 prefs, callback);
332 preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, callback); 438 preload_engines_.Init(prefs::kLanguagePreloadEngines, prefs, callback);
439 preload_engines_syncable_.Init(prefs::kLanguagePreloadEnginesSyncable,
440 prefs, callback);
333 enabled_extension_imes_.Init(prefs::kLanguageEnabledExtensionImes, 441 enabled_extension_imes_.Init(prefs::kLanguageEnabledExtensionImes,
334 prefs, callback); 442 prefs, callback);
443 enabled_extension_imes_syncable_.Init(
444 prefs::kLanguageEnabledExtensionImesSyncable, prefs, callback);
335 current_input_method_.Init(prefs::kLanguageCurrentInputMethod, 445 current_input_method_.Init(prefs::kLanguageCurrentInputMethod,
336 prefs, callback); 446 prefs, callback);
337 previous_input_method_.Init(prefs::kLanguagePreviousInputMethod, 447 previous_input_method_.Init(prefs::kLanguagePreviousInputMethod,
338 prefs, callback); 448 prefs, callback);
339 449
340 xkb_auto_repeat_enabled_.Init( 450 xkb_auto_repeat_enabled_.Init(
341 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback); 451 prefs::kLanguageXkbAutoRepeatEnabled, prefs, callback);
342 xkb_auto_repeat_delay_pref_.Init( 452 xkb_auto_repeat_delay_pref_.Init(
343 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); 453 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback);
344 xkb_auto_repeat_interval_pref_.Init( 454 xkb_auto_repeat_interval_pref_.Init(
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 default_download_to_drive); 614 default_download_to_drive);
505 else if (reason == REASON_INITIALIZATION) 615 else if (reason == REASON_INITIALIZATION)
506 UMA_HISTOGRAM_BOOLEAN( 616 UMA_HISTOGRAM_BOOLEAN(
507 "FileBrowser.DownloadDestination.IsGoogleDrive.Started", 617 "FileBrowser.DownloadDestination.IsGoogleDrive.Started",
508 default_download_to_drive); 618 default_download_to_drive);
509 } 619 }
510 if (reason != REASON_PREF_CHANGED || 620 if (reason != REASON_PREF_CHANGED ||
511 pref_name == prefs::kTouchHudProjectionEnabled) { 621 pref_name == prefs::kTouchHudProjectionEnabled) {
512 if (user_is_active) { 622 if (user_is_active) {
513 const bool enabled = touch_hud_projection_enabled_.GetValue(); 623 const bool enabled = touch_hud_projection_enabled_.GetValue();
514 ash::Shell::GetInstance()->SetTouchHudProjectionEnabled(enabled); 624 // There may not be a shell, e.g., in some unit tests.
625 if (ash::Shell::HasInstance())
626 ash::Shell::GetInstance()->SetTouchHudProjectionEnabled(enabled);
515 } 627 }
516 } 628 }
517 629
518 if (reason != REASON_PREF_CHANGED || 630 if (reason != REASON_PREF_CHANGED ||
519 pref_name == prefs::kLanguageXkbAutoRepeatEnabled) { 631 pref_name == prefs::kLanguageXkbAutoRepeatEnabled) {
520 if (user_is_active) { 632 if (user_is_active) {
521 const bool enabled = xkb_auto_repeat_enabled_.GetValue(); 633 const bool enabled = xkb_auto_repeat_enabled_.GetValue();
522 input_method::InputMethodManager::Get() 634 input_method::InputMethodManager::Get()
523 ->GetImeKeyboard() 635 ->GetImeKeyboard()
524 ->SetAutoRepeatEnabled(enabled); 636 ->SetAutoRepeatEnabled(enabled);
525 } 637 }
526 } 638 }
527 if (reason != REASON_PREF_CHANGED || 639 if (reason != REASON_PREF_CHANGED ||
528 pref_name == prefs::kLanguageXkbAutoRepeatDelay || 640 pref_name == prefs::kLanguageXkbAutoRepeatDelay ||
529 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { 641 pref_name == prefs::kLanguageXkbAutoRepeatInterval) {
530 if (user_is_active) 642 if (user_is_active)
531 UpdateAutoRepeatRate(); 643 UpdateAutoRepeatRate();
532 } 644 }
533 645
646 if (reason == REASON_PREF_CHANGED &&
647 pref_name == prefs::kLanguagePreferredLanguages)
648 SetSyncableInputMethodPrefs();
649
534 if (reason != REASON_PREF_CHANGED && user_is_active) { 650 if (reason != REASON_PREF_CHANGED && user_is_active) {
535 SetInputMethodList(); 651 SetInputMethodList();
536 } else if (pref_name == prefs::kLanguagePreloadEngines && user_is_active) { 652 } else if (pref_name == prefs::kLanguagePreloadEngines) {
537 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, 653 if (user_is_active) {
538 language_prefs::kPreloadEnginesConfigName, 654 SetLanguageConfigStringListAsCSV(
539 preload_engines_.GetValue()); 655 language_prefs::kGeneralSectionName,
656 language_prefs::kPreloadEnginesConfigName,
657 preload_engines_.GetValue());
658 }
659 SetSyncableInputMethodPrefs();
540 } 660 }
541 661
542 if (reason != REASON_PREF_CHANGED || 662 if (reason != REASON_PREF_CHANGED ||
543 pref_name == prefs::kLanguageEnabledExtensionImes) { 663 pref_name == prefs::kLanguageEnabledExtensionImes) {
544 if (user_is_active) { 664 if (user_is_active)
545 std::string value(enabled_extension_imes_.GetValue()); 665 SetEnabledExtensionImes();
546 666 if (reason == REASON_PREF_CHANGED)
547 std::vector<std::string> split_values; 667 SetSyncableInputMethodPrefs();
548 if (!value.empty())
549 base::SplitString(value, ',', &split_values);
550
551 input_method_manager_->SetEnabledExtensionImes(&split_values);
552 }
553 } 668 }
554 669
555 if (user_is_active) { 670 if (user_is_active) {
556 system::InputDeviceSettings::Get()->UpdateTouchpadSettings( 671 system::InputDeviceSettings::Get()->UpdateTouchpadSettings(
557 touchpad_settings); 672 touchpad_settings);
558 system::InputDeviceSettings::Get()->UpdateMouseSettings(mouse_settings); 673 system::InputDeviceSettings::Get()->UpdateMouseSettings(mouse_settings);
559 } 674 }
560 } 675 }
561 676
562 void Preferences::OnIsSyncingChanged() { 677 void Preferences::OnIsSyncingChanged() {
563 DVLOG(1) << "OnIsSyncingChanged"; 678 DVLOG(1) << "OnIsSyncingChanged";
564 ForceNaturalScrollDefault(); 679 ForceNaturalScrollDefault();
680
681 if (prefs_->GetBoolean(prefs::kLanguageShouldMergeInputMethods) &&
682 prefs_->IsSyncing()) {
683 MergeSyncedInputMethods();
684 prefs_->SetBoolean(prefs::kLanguageShouldMergeInputMethods, false);
685 }
686 }
687
688 void Preferences::MergeSyncedInputMethods() {
689 DCHECK(prefs_->GetBoolean(prefs::kLanguageShouldMergeInputMethods));
690
691 preferred_languages_.SetValue(
692 MergeCSVPrefs(preferred_languages_.GetValue(),
693 preferred_languages_syncable_.GetValue(),
694 prefs::kLanguagePreferredLanguages));
695 preload_engines_.SetValue(
696 MergeCSVPrefs(preload_engines_.GetValue(),
697 preload_engines_syncable_.GetValue(),
698 prefs::kLanguagePreloadEngines));
699 enabled_extension_imes_.SetValue(
700 MergeCSVPrefs(enabled_extension_imes_.GetValue(),
701 enabled_extension_imes_syncable_.GetValue(),
702 prefs::kLanguageEnabledExtensionImes));
703
704 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName,
705 language_prefs::kPreloadEnginesConfigName,
706 preload_engines_.GetValue());
707 SetEnabledExtensionImes();
708 SetSyncableInputMethodPrefs();
565 } 709 }
566 710
567 void Preferences::ForceNaturalScrollDefault() { 711 void Preferences::ForceNaturalScrollDefault() {
568 DVLOG(1) << "ForceNaturalScrollDefault"; 712 DVLOG(1) << "ForceNaturalScrollDefault";
569 if (CommandLine::ForCurrentProcess()->HasSwitch( 713 if (CommandLine::ForCurrentProcess()->HasSwitch(
570 switches::kNaturalScrollDefault) && 714 switches::kNaturalScrollDefault) &&
571 prefs_->IsSyncing() && 715 prefs_->IsSyncing() &&
572 !prefs_->GetUserPrefValue(prefs::kNaturalScroll)) { 716 !prefs_->GetUserPrefValue(prefs::kNaturalScroll)) {
573 DVLOG(1) << "Natural scroll forced to true"; 717 DVLOG(1) << "Natural scroll forced to true";
574 natural_scroll_.SetValue(true); 718 natural_scroll_.SetValue(true);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // might be ignored as an invalid input method ID. The ChangeInputMethod() 758 // might be ignored as an invalid input method ID. The ChangeInputMethod()
615 // calls are also necessary to restore the previous/current input method prefs 759 // calls are also necessary to restore the previous/current input method prefs
616 // which could have been modified by the SetLanguageConfigStringListAsCSV call 760 // which could have been modified by the SetLanguageConfigStringListAsCSV call
617 // above to the original state. 761 // above to the original state.
618 if (!previous_input_method_id.empty()) 762 if (!previous_input_method_id.empty())
619 input_method_manager_->ChangeInputMethod(previous_input_method_id); 763 input_method_manager_->ChangeInputMethod(previous_input_method_id);
620 if (!current_input_method_id.empty()) 764 if (!current_input_method_id.empty())
621 input_method_manager_->ChangeInputMethod(current_input_method_id); 765 input_method_manager_->ChangeInputMethod(current_input_method_id);
622 } 766 }
623 767
768 void Preferences::SetEnabledExtensionImes() {
769 std::string value(enabled_extension_imes_.GetValue());
770 std::vector<std::string> split_values;
771 if (!value.empty())
772 base::SplitString(value, ',', &split_values);
773 input_method_manager_->SetEnabledExtensionImes(&split_values);
774 }
775
776 void Preferences::SetSyncableInputMethodPrefs() {
777 // Set the language and input prefs at the same time. Otherwise, we may,
778 // e.g., use a stale languages setting but push a new preload engines setting.
779 if (!prefs_->GetBoolean(prefs::kLanguageShouldMergeInputMethods)) {
780 preferred_languages_syncable_.SetValue(preferred_languages_.GetValue());
781 enabled_extension_imes_syncable_.SetValue(
782 enabled_extension_imes_.GetValue());
783
784 // For preload engines, use legacy xkb IDs so the preference can sync
785 // across Chrome OS and Chromium OS.
786 std::vector<std::string> engines;
787 base::SplitString(preload_engines_.GetValue(), ',', &engines);
788 std::transform(engines.begin(), engines.end(), engines.begin(),
789 extension_ime_util::MaybeGetLegacyXkbId);
Shu Chen 2014/06/11 03:54:55 extension_ime_util::MaybeGetLegacyXkbId to get eng
michaelpg 2014/06/28 05:25:28 Done.
790 /* for (int i = 0; i < engines.size(); i++)
791 engines[i] = (engines[i]);*/
792 preload_engines_syncable_.SetValue(JoinString(engines, ','));
793 }
794 }
795
624 void Preferences::UpdateAutoRepeatRate() { 796 void Preferences::UpdateAutoRepeatRate() {
625 input_method::AutoRepeatRate rate; 797 input_method::AutoRepeatRate rate;
626 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); 798 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue();
627 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); 799 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue();
628 DCHECK(rate.initial_delay_in_ms > 0); 800 DCHECK(rate.initial_delay_in_ms > 0);
629 DCHECK(rate.repeat_interval_in_ms > 0); 801 DCHECK(rate.repeat_interval_in_ms > 0);
630 input_method::InputMethodManager::Get() 802 input_method::InputMethodManager::Get()
631 ->GetImeKeyboard() 803 ->GetImeKeyboard()
632 ->SetAutoRepeatRate(rate); 804 ->SetAutoRepeatRate(rate);
633 } 805 }
634 806
635 void Preferences::OnTouchHudProjectionToggled(bool enabled) { 807 void Preferences::OnTouchHudProjectionToggled(bool enabled) {
636 if (touch_hud_projection_enabled_.GetValue() == enabled) 808 if (touch_hud_projection_enabled_.GetValue() == enabled)
637 return; 809 return;
638 if (!user_->is_active()) 810 if (!user_->is_active())
639 return; 811 return;
640 touch_hud_projection_enabled_.SetValue(enabled); 812 touch_hud_projection_enabled_.SetValue(enabled);
641 } 813 }
642 814
643 void Preferences::ActiveUserChanged(const User* active_user) { 815 void Preferences::ActiveUserChanged(const User* active_user) {
644 if (active_user != user_) 816 if (active_user != user_)
645 return; 817 return;
646 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); 818 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, "");
647 } 819 }
648 820
649 } // namespace chromeos 821 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | chrome/browser/chromeos/preferences_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698