| OLD | NEW |
| 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 <vector> |
| 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" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "url/gurl.h" | 44 #include "url/gurl.h" |
| 45 | 45 |
| 46 namespace chromeos { | 46 namespace chromeos { |
| 47 | 47 |
| 48 static const char kFallbackInputMethodLocale[] = "en-US"; | 48 static const char kFallbackInputMethodLocale[] = "en-US"; |
| 49 | 49 |
| 50 Preferences::Preferences() | 50 Preferences::Preferences() |
| 51 : prefs_(NULL), | 51 : prefs_(NULL), |
| 52 input_method_manager_(input_method::InputMethodManager::Get()), | 52 input_method_manager_(input_method::InputMethodManager::Get()), |
| 53 user_(NULL), | 53 user_(NULL), |
| 54 user_is_primary_(false) { | 54 user_is_primary_(false), |
| 55 ime_state_outdated_(true) { |
| 55 // Do not observe shell, if there is no shell instance; e.g., in some unit | 56 // Do not observe shell, if there is no shell instance; e.g., in some unit |
| 56 // tests. | 57 // tests. |
| 57 if (ash::Shell::HasInstance()) | 58 if (ash::Shell::HasInstance()) |
| 58 ash::Shell::GetInstance()->AddShellObserver(this); | 59 ash::Shell::GetInstance()->AddShellObserver(this); |
| 59 } | 60 } |
| 60 | 61 |
| 61 Preferences::Preferences(input_method::InputMethodManager* input_method_manager) | 62 Preferences::Preferences(input_method::InputMethodManager* input_method_manager) |
| 62 : prefs_(NULL), | 63 : prefs_(NULL), |
| 63 input_method_manager_(input_method_manager), | 64 input_method_manager_(input_method_manager), |
| 64 user_(NULL), | 65 user_(NULL), |
| 65 user_is_primary_(false) { | 66 user_is_primary_(false), |
| 67 ime_state_outdated_(true) { |
| 66 // Do not observe shell, if there is no shell instance; e.g., in some unit | 68 // Do not observe shell, if there is no shell instance; e.g., in some unit |
| 67 // tests. | 69 // tests. |
| 68 if (ash::Shell::HasInstance()) | 70 if (ash::Shell::HasInstance()) |
| 69 ash::Shell::GetInstance()->AddShellObserver(this); | 71 ash::Shell::GetInstance()->AddShellObserver(this); |
| 70 } | 72 } |
| 71 | 73 |
| 72 Preferences::~Preferences() { | 74 Preferences::~Preferences() { |
| 73 prefs_->RemoveObserver(this); | 75 prefs_->RemoveObserver(this); |
| 74 UserManager::Get()->RemoveSessionStateObserver(this); | 76 UserManager::Get()->RemoveSessionStateObserver(this); |
| 75 // If shell instance is destoryed before this preferences instance, there is | 77 // If shell instance is destoryed before this preferences instance, there is |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 ->SetAutoRepeatEnabled(enabled); | 531 ->SetAutoRepeatEnabled(enabled); |
| 530 } | 532 } |
| 531 } | 533 } |
| 532 if (reason != REASON_PREF_CHANGED || | 534 if (reason != REASON_PREF_CHANGED || |
| 533 pref_name == prefs::kLanguageXkbAutoRepeatDelay || | 535 pref_name == prefs::kLanguageXkbAutoRepeatDelay || |
| 534 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { | 536 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { |
| 535 if (user_is_active) | 537 if (user_is_active) |
| 536 UpdateAutoRepeatRate(); | 538 UpdateAutoRepeatRate(); |
| 537 } | 539 } |
| 538 | 540 |
| 539 if (reason != REASON_PREF_CHANGED && user_is_active) { | 541 if (pref_name == prefs::kLanguagePreloadEngines) { |
| 540 SetInputMethodList(); | 542 if (reason == REASON_PREF_CHANGED && user_is_active) { |
| 541 } else if (pref_name == prefs::kLanguagePreloadEngines && user_is_active) { | 543 SetLanguageConfigStringListAsCSV( |
| 542 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, | 544 language_prefs::kGeneralSectionName, |
| 543 language_prefs::kPreloadEnginesConfigName, | 545 language_prefs::kPreloadEnginesConfigName, |
| 544 preload_engines_.GetValue()); | 546 preload_engines_.GetValue()); |
| 547 } else { |
| 548 ime_state_outdated_ = true; |
| 549 } |
| 545 } | 550 } |
| 546 | 551 |
| 547 if (reason != REASON_PREF_CHANGED || | 552 if (reason != REASON_PREF_CHANGED || |
| 548 pref_name == prefs::kLanguageEnabledExtensionImes) { | 553 pref_name == prefs::kLanguageEnabledExtensionImes) { |
| 549 if (user_is_active) { | 554 if (user_is_active) { |
| 550 std::string value(enabled_extension_imes_.GetValue()); | 555 std::string value(enabled_extension_imes_.GetValue()); |
| 551 | 556 |
| 552 std::vector<std::string> split_values; | 557 std::vector<std::string> split_values; |
| 553 if (!value.empty()) | 558 if (!value.empty()) |
| 554 base::SplitString(value, ',', &split_values); | 559 base::SplitString(value, ',', &split_values); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 } | 643 } |
| 639 | 644 |
| 640 void Preferences::OnTouchHudProjectionToggled(bool enabled) { | 645 void Preferences::OnTouchHudProjectionToggled(bool enabled) { |
| 641 if (touch_hud_projection_enabled_.GetValue() == enabled) | 646 if (touch_hud_projection_enabled_.GetValue() == enabled) |
| 642 return; | 647 return; |
| 643 if (!user_->is_active()) | 648 if (!user_->is_active()) |
| 644 return; | 649 return; |
| 645 touch_hud_projection_enabled_.SetValue(enabled); | 650 touch_hud_projection_enabled_.SetValue(enabled); |
| 646 } | 651 } |
| 647 | 652 |
| 653 void Preferences::ActivateInputMethods(const user_manager::User* active_user) { |
| 654 bool just_created = false; |
| 655 if (!ime_state_) { |
| 656 ime_state_ = input_method::InputMethodManager::Get()->CreateNewState( |
| 657 active_user->email()); |
| 658 just_created = true; |
| 659 } |
| 660 input_method::InputMethodManager::Get()->SetState(ime_state_); |
| 661 if (just_created || ime_state_outdated_) { |
| 662 SetInputMethodList(); |
| 663 ime_state_outdated_ = false; |
| 664 } |
| 665 } |
| 666 |
| 648 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { | 667 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
| 649 if (active_user != user_) | 668 if (active_user != user_) |
| 650 return; | 669 return; |
| 670 |
| 671 ActivateInputMethods(active_user); |
| 672 |
| 651 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 673 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
| 652 } | 674 } |
| 653 | 675 |
| 654 } // namespace chromeos | 676 } // namespace chromeos |
| OLD | NEW |