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

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

Issue 419293002: IME refactoring: ChromeOS introduce input methods State. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
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 <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
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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 ->SetAutoRepeatEnabled(enabled); 532 ->SetAutoRepeatEnabled(enabled);
531 } 533 }
532 } 534 }
533 if (reason != REASON_PREF_CHANGED || 535 if (reason != REASON_PREF_CHANGED ||
534 pref_name == prefs::kLanguageXkbAutoRepeatDelay || 536 pref_name == prefs::kLanguageXkbAutoRepeatDelay ||
535 pref_name == prefs::kLanguageXkbAutoRepeatInterval) { 537 pref_name == prefs::kLanguageXkbAutoRepeatInterval) {
536 if (user_is_active) 538 if (user_is_active)
537 UpdateAutoRepeatRate(); 539 UpdateAutoRepeatRate();
538 } 540 }
539 541
540 if (reason != REASON_PREF_CHANGED && user_is_active) { 542 if (pref_name == prefs::kLanguagePreloadEngines) {
541 SetInputMethodList(); 543 if (reason == REASON_PREF_CHANGED && user_is_active) {
542 } else if (pref_name == prefs::kLanguagePreloadEngines && user_is_active) { 544 SetLanguageConfigStringListAsCSV(
543 SetLanguageConfigStringListAsCSV(language_prefs::kGeneralSectionName, 545 language_prefs::kGeneralSectionName,
544 language_prefs::kPreloadEnginesConfigName, 546 language_prefs::kPreloadEnginesConfigName,
545 preload_engines_.GetValue()); 547 preload_engines_.GetValue());
548 } else {
549 ime_state_outdated_ = true;
550 }
546 } 551 }
547 552
548 if (reason != REASON_PREF_CHANGED || 553 if (reason != REASON_PREF_CHANGED ||
549 pref_name == prefs::kLanguageEnabledExtensionImes) { 554 pref_name == prefs::kLanguageEnabledExtensionImes) {
550 if (user_is_active) { 555 if (user_is_active) {
551 std::string value(enabled_extension_imes_.GetValue()); 556 std::string value(enabled_extension_imes_.GetValue());
552 557
553 std::vector<std::string> split_values; 558 std::vector<std::string> split_values;
554 if (!value.empty()) 559 if (!value.empty())
555 base::SplitString(value, ',', &split_values); 560 base::SplitString(value, ',', &split_values);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 } 644 }
640 645
641 void Preferences::OnTouchHudProjectionToggled(bool enabled) { 646 void Preferences::OnTouchHudProjectionToggled(bool enabled) {
642 if (touch_hud_projection_enabled_.GetValue() == enabled) 647 if (touch_hud_projection_enabled_.GetValue() == enabled)
643 return; 648 return;
644 if (!user_->is_active()) 649 if (!user_->is_active())
645 return; 650 return;
646 touch_hud_projection_enabled_.SetValue(enabled); 651 touch_hud_projection_enabled_.SetValue(enabled);
647 } 652 }
648 653
654 void Preferences::ActivateInputMethods(const User* active_user) {
655 bool just_created = false;
656 if (!ime_state_) {
Shu Chen 2014/08/04 14:55:24 I don't understand. Will there be single InputMeth
Alexander Alekseev 2014/08/06 23:39:45 No. Preferences belong to particular user, so this
657 ime_state_ = input_method::InputMethodManager::Get()->CreateNewState(
658 active_user->email());
659 just_created = true;
660 }
661 input_method::InputMethodManager::Get()->SetState(ime_state_);
662 if (just_created || ime_state_outdated_) {
663 SetInputMethodList();
664 ime_state_outdated_ = false;
665 }
666 }
667
649 void Preferences::ActiveUserChanged(const User* active_user) { 668 void Preferences::ActiveUserChanged(const User* active_user) {
650 if (active_user != user_) 669 if (active_user != user_)
651 return; 670 return;
671
672 ActivateInputMethods(active_user);
673
652 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); 674 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, "");
653 } 675 }
654 676
655 } // namespace chromeos 677 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698