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

Side by Side Diff: chrome/browser/chromeos/cros/input_method_library.cc

Issue 3132023: Add language_prefs namespace to language_preferences.h. (Closed)
Patch Set: address comments Created 10 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/dom_ui/language_chewing_options_handler.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cros/input_method_library.h" 5 #include "chrome/browser/chromeos/cros/input_method_library.h"
6 6
7 #include <glib.h> 7 #include <glib.h>
8 #include <signal.h> 8 #include <signal.h>
9 9
10 #include "unicode/uloc.h" 10 #include "unicode/uloc.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 class InputMethodLibraryImpl : public InputMethodLibrary { 44 class InputMethodLibraryImpl : public InputMethodLibrary {
45 public: 45 public:
46 InputMethodLibraryImpl() 46 InputMethodLibraryImpl()
47 : input_method_status_connection_(NULL), 47 : input_method_status_connection_(NULL),
48 previous_input_method_("", "", "", ""), 48 previous_input_method_("", "", "", ""),
49 current_input_method_("", "", "", ""), 49 current_input_method_("", "", "", ""),
50 ime_running_(false), 50 ime_running_(false),
51 ime_connected_(false), 51 ime_connected_(false),
52 defer_ime_startup_(false), 52 defer_ime_startup_(false),
53 active_input_method_(kHardwareKeyboardLayout), 53 active_input_method_(language_prefs::kHardwareKeyboardLayout),
54 need_input_method_set_(false), 54 need_input_method_set_(false),
55 ime_handle_(0), 55 ime_handle_(0),
56 candidate_window_handle_(0), 56 candidate_window_handle_(0),
57 failure_count_(0) { 57 failure_count_(0) {
58 scoped_ptr<InputMethodDescriptors> input_method_descriptors( 58 scoped_ptr<InputMethodDescriptors> input_method_descriptors(
59 CreateFallbackInputMethodDescriptors()); 59 CreateFallbackInputMethodDescriptors());
60 current_input_method_ = input_method_descriptors->at(0); 60 current_input_method_ = input_method_descriptors->at(0);
61 } 61 }
62 62
63 ~InputMethodLibraryImpl() { 63 ~InputMethodLibraryImpl() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 if (!result || result->empty()) { 99 if (!result || result->empty()) {
100 result = CreateFallbackInputMethodDescriptors(); 100 result = CreateFallbackInputMethodDescriptors();
101 } 101 }
102 return result; 102 return result;
103 } 103 }
104 104
105 void ChangeInputMethod(const std::string& input_method_id) { 105 void ChangeInputMethod(const std::string& input_method_id) {
106 active_input_method_ = input_method_id; 106 active_input_method_ = input_method_id;
107 if (EnsureLoadedAndStarted()) { 107 if (EnsureLoadedAndStarted()) {
108 if (input_method_id != kHardwareKeyboardLayout) { 108 if (input_method_id != language_prefs::kHardwareKeyboardLayout) {
109 StartInputMethodProcesses(); 109 StartInputMethodProcesses();
110 } 110 }
111 chromeos::ChangeInputMethod( 111 chromeos::ChangeInputMethod(
112 input_method_status_connection_, input_method_id.c_str()); 112 input_method_status_connection_, input_method_id.c_str());
113 } 113 }
114 } 114 }
115 115
116 void SetImePropertyActivated(const std::string& key, bool activated) { 116 void SetImePropertyActivated(const std::string& key, bool activated) {
117 DCHECK(!key.empty()); 117 DCHECK(!key.empty());
118 if (EnsureLoadedAndStarted()) { 118 if (EnsureLoadedAndStarted()) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 virtual const ImePropertyList& current_ime_properties() const { 165 virtual const ImePropertyList& current_ime_properties() const {
166 return current_ime_properties_; 166 return current_ime_properties_;
167 } 167 }
168 168
169 private: 169 private:
170 void MaybeUpdateImeState( 170 void MaybeUpdateImeState(
171 const char* section, 171 const char* section,
172 const char* config_name, 172 const char* config_name,
173 const ImeConfigValue& value) { 173 const ImeConfigValue& value) {
174 if (!strcmp(kGeneralSectionName, section) && 174 if (!strcmp(language_prefs::kGeneralSectionName, section) &&
175 !strcmp(kPreloadEnginesConfigName, config_name)) { 175 !strcmp(language_prefs::kPreloadEnginesConfigName, config_name)) {
176 if (EnsureLoadedAndStarted()) { 176 if (EnsureLoadedAndStarted()) {
177 if (value.type == ImeConfigValue::kValueTypeStringList && 177 if (value.type == ImeConfigValue::kValueTypeStringList &&
178 value.string_list_value.size() == 1 && 178 value.string_list_value.size() == 1 &&
179 value.string_list_value[0] == kHardwareKeyboardLayout) { 179 value.string_list_value[0] ==
180 language_prefs::kHardwareKeyboardLayout) {
180 StopInputMethodProcesses(); 181 StopInputMethodProcesses();
181 } else if (!defer_ime_startup_) { 182 } else if (!defer_ime_startup_) {
182 StartInputMethodProcesses(); 183 StartInputMethodProcesses();
183 } 184 }
184 chromeos::SetActiveInputMethods(input_method_status_connection_, value); 185 chromeos::SetActiveInputMethods(input_method_status_connection_, value);
185 } 186 }
186 } 187 }
187 } 188 }
188 189
189 void FlushImeConfig() { 190 void FlushImeConfig() {
190 bool active_input_methods_are_changed = false; 191 bool active_input_methods_are_changed = false;
191 bool completed = false; 192 bool completed = false;
192 if (EnsureLoadedAndStarted()) { 193 if (EnsureLoadedAndStarted()) {
193 InputMethodConfigRequests::iterator iter = 194 InputMethodConfigRequests::iterator iter =
194 pending_config_requests_.begin(); 195 pending_config_requests_.begin();
195 while (iter != pending_config_requests_.end()) { 196 while (iter != pending_config_requests_.end()) {
196 const std::string& section = iter->first.first; 197 const std::string& section = iter->first.first;
197 const std::string& config_name = iter->first.second; 198 const std::string& config_name = iter->first.second;
198 const ImeConfigValue& value = iter->second; 199 const ImeConfigValue& value = iter->second;
199 if (chromeos::SetImeConfig(input_method_status_connection_, 200 if (chromeos::SetImeConfig(input_method_status_connection_,
200 section.c_str(), 201 section.c_str(),
201 config_name.c_str(), 202 config_name.c_str(),
202 value)) { 203 value)) {
203 // Check if it's a change in active input methods. 204 // Check if it's a change in active input methods.
204 if (config_name == kPreloadEnginesConfigName) { 205 if (config_name == language_prefs::kPreloadEnginesConfigName) {
205 active_input_methods_are_changed = true; 206 active_input_methods_are_changed = true;
206 } 207 }
207 // Successfully sent. Remove the command and proceed to the next one. 208 // Successfully sent. Remove the command and proceed to the next one.
208 pending_config_requests_.erase(iter++); 209 pending_config_requests_.erase(iter++);
209 } else { 210 } else {
210 // If SetImeConfig() fails, subsequent calls will likely fail. 211 // If SetImeConfig() fails, subsequent calls will likely fail.
211 break; 212 break;
212 } 213 }
213 } 214 }
214 if (pending_config_requests_.empty()) { 215 if (pending_config_requests_.empty()) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 library->candidate_window_handle_ = 0; 444 library->candidate_window_handle_ = 0;
444 } 445 }
445 446
446 library->MaybeLaunchIme(); 447 library->MaybeLaunchIme();
447 } 448 }
448 449
449 void StopInputMethodProcesses() { 450 void StopInputMethodProcesses() {
450 ime_running_ = false; 451 ime_running_ = false;
451 if (ime_handle_) { 452 if (ime_handle_) {
452 chromeos::ChangeInputMethod(input_method_status_connection_, 453 chromeos::ChangeInputMethod(input_method_status_connection_,
453 kHardwareKeyboardLayout); 454 language_prefs::kHardwareKeyboardLayout);
454 kill(ime_handle_, SIGTERM); 455 kill(ime_handle_, SIGTERM);
455 ime_handle_ = 0; 456 ime_handle_ = 0;
456 } 457 }
457 if (candidate_window_handle_) { 458 if (candidate_window_handle_) {
458 kill(candidate_window_handle_, SIGTERM); 459 kill(candidate_window_handle_, SIGTERM);
459 candidate_window_handle_ = 0; 460 candidate_window_handle_ = 0;
460 } 461 }
461 } 462 }
462 463
463 void SetDeferImeStartup(bool defer) { 464 void SetDeferImeStartup(bool defer) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 return new InputMethodLibraryStubImpl(); 714 return new InputMethodLibraryStubImpl();
714 else 715 else
715 return new InputMethodLibraryImpl(); 716 return new InputMethodLibraryImpl();
716 } 717 }
717 718
718 } // namespace chromeos 719 } // namespace chromeos
719 720
720 // Allows InvokeLater without adding refcounting. This class is a Singleton and 721 // Allows InvokeLater without adding refcounting. This class is a Singleton and
721 // won't be deleted until it's last InvokeLater is run. 722 // won't be deleted until it's last InvokeLater is run.
722 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::InputMethodLibraryImpl); 723 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::InputMethodLibraryImpl);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/dom_ui/language_chewing_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698