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/ui/webui/chromeos/login/network_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 23 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
24 #include "chrome/browser/chromeos/login/input_events_blocker.h" | 24 #include "chrome/browser/chromeos/login/input_events_blocker.h" |
25 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 25 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
26 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" | 26 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" |
27 #include "chrome/browser/chromeos/system/input_device_settings.h" | 27 #include "chrome/browser/chromeos/system/input_device_settings.h" |
28 #include "chrome/browser/chromeos/system/timezone_util.h" | 28 #include "chrome/browser/chromeos/system/timezone_util.h" |
29 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 29 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
30 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler
.h" | 30 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler
.h" |
31 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
32 #include "chromeos/chromeos_switches.h" | 32 #include "chromeos/chromeos_switches.h" |
| 33 #include "chromeos/ime/extension_ime_util.h" |
33 #include "chromeos/ime/input_method_manager.h" | 34 #include "chromeos/ime/input_method_manager.h" |
34 #include "grit/chromium_strings.h" | 35 #include "grit/chromium_strings.h" |
35 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/gfx/rect.h" | 38 #include "ui/gfx/rect.h" |
38 #include "ui/views/layout/fill_layout.h" | 39 #include "ui/views/layout/fill_layout.h" |
39 #include "ui/views/widget/widget.h" | 40 #include "ui/views/widget/widget.h" |
40 | 41 |
41 namespace { | 42 namespace { |
42 | 43 |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 } | 423 } |
423 | 424 |
424 // static | 425 // static |
425 base::ListValue* NetworkScreenHandler::GetInputMethods() { | 426 base::ListValue* NetworkScreenHandler::GetInputMethods() { |
426 base::ListValue* input_methods_list = new base::ListValue; | 427 base::ListValue* input_methods_list = new base::ListValue; |
427 input_method::InputMethodManager* manager = | 428 input_method::InputMethodManager* manager = |
428 input_method::InputMethodManager::Get(); | 429 input_method::InputMethodManager::Get(); |
429 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); | 430 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); |
430 scoped_ptr<input_method::InputMethodDescriptors> input_methods( | 431 scoped_ptr<input_method::InputMethodDescriptors> input_methods( |
431 manager->GetActiveInputMethods()); | 432 manager->GetActiveInputMethods()); |
432 std::string current_input_method_id = manager->GetCurrentInputMethod().id(); | 433 // Uses extension_ime_util::MaybeGetLegacyXkbId() to make sure the input |
| 434 // method id is in legacy xkb id format (e.g. xkb:us::eng), instead of |
| 435 // extension based xkd id format (e.g. _comp_ime_...xkb:us::eng). |
| 436 // Same for the rests. |
| 437 // TODO(shuchen): support wait for component extension loading, and then show |
| 438 // OOBE window. So that extension_ime_util::MaybeGetLegacyXkbId() can be |
| 439 // removed. |
| 440 std::string current_input_method_id = extension_ime_util::MaybeGetLegacyXkbId( |
| 441 manager->GetCurrentInputMethod().id()); |
433 const std::vector<std::string>& hardware_login_input_methods = | 442 const std::vector<std::string>& hardware_login_input_methods = |
434 util->GetHardwareLoginInputMethodIds(); | 443 util->GetHardwareLoginInputMethodIds(); |
435 std::set<std::string> input_methods_added; | 444 std::set<std::string> input_methods_added; |
436 | 445 |
437 for (std::vector<std::string>::const_iterator i = | 446 for (std::vector<std::string>::const_iterator i = |
438 hardware_login_input_methods.begin(); | 447 hardware_login_input_methods.begin(); |
439 i != hardware_login_input_methods.end(); | 448 i != hardware_login_input_methods.end(); |
440 ++i) { | 449 ++i) { |
441 input_methods_added.insert(*i); | 450 // Makes sure the id is in legacy xkb id format. |
| 451 const std::string id = extension_ime_util::MaybeGetLegacyXkbId(*i); |
| 452 input_methods_added.insert(id); |
442 const input_method::InputMethodDescriptor* ime = | 453 const input_method::InputMethodDescriptor* ime = |
443 util->GetInputMethodDescriptorFromId(*i); | 454 util->GetInputMethodDescriptorFromId(id); |
444 DCHECK(ime != NULL); | 455 DCHECK(ime != NULL); |
445 // Do not crash in case of misconfiguration. | 456 // Do not crash in case of misconfiguration. |
446 if (ime != NULL) { | 457 if (ime != NULL) { |
447 input_methods_list->Append( | 458 input_methods_list->Append( |
448 CreateInputMethodsEntry(*ime, current_input_method_id)); | 459 CreateInputMethodsEntry(*ime, current_input_method_id)); |
449 } | 460 } |
450 } | 461 } |
451 | 462 |
452 bool optgroup_added = false; | 463 bool optgroup_added = false; |
453 for (size_t i = 0; i < input_methods->size(); ++i) { | 464 for (size_t i = 0; i < input_methods->size(); ++i) { |
454 const std::string& ime_id = input_methods->at(i).id(); | 465 // Makes sure the id is in legacy xkb id format. |
| 466 const std::string& ime_id = extension_ime_util::MaybeGetLegacyXkbId( |
| 467 (*input_methods)[i].id()); |
455 if (!InsertString(ime_id, input_methods_added)) | 468 if (!InsertString(ime_id, input_methods_added)) |
456 continue; | 469 continue; |
457 if (!optgroup_added) { | 470 if (!optgroup_added) { |
458 optgroup_added = true; | 471 optgroup_added = true; |
459 AddOptgroupOtherLayouts(input_methods_list); | 472 AddOptgroupOtherLayouts(input_methods_list); |
460 } | 473 } |
461 input_methods_list->Append( | 474 input_methods_list->Append( |
462 CreateInputMethodsEntry(input_methods->at(i), current_input_method_id)); | 475 CreateInputMethodsEntry((*input_methods)[i], current_input_method_id)); |
463 } | 476 } |
464 // "xkb:us::eng" should always be in the list of available layouts. | 477 // "xkb:us::eng" should always be in the list of available layouts. |
465 if (input_methods_added.count(kUSlayout) == 0) { | 478 if (input_methods_added.count(kUSlayout) == 0) { |
466 const input_method::InputMethodDescriptor* us_eng_descriptor = | 479 const input_method::InputMethodDescriptor* us_eng_descriptor = |
467 util->GetInputMethodDescriptorFromId(kUSlayout); | 480 util->GetInputMethodDescriptorFromId(kUSlayout); |
468 DCHECK(us_eng_descriptor != NULL); | 481 DCHECK(us_eng_descriptor != NULL); |
469 if (!optgroup_added) { | 482 if (!optgroup_added) { |
470 optgroup_added = true; | 483 optgroup_added = true; |
471 AddOptgroupOtherLayouts(input_methods_list); | 484 AddOptgroupOtherLayouts(input_methods_list); |
472 } | 485 } |
(...skipping 25 matching lines...) Expand all Loading... |
498 timezone_option->SetString("value", timezone_id); | 511 timezone_option->SetString("value", timezone_id); |
499 timezone_option->SetString("title", timezone_name); | 512 timezone_option->SetString("title", timezone_name); |
500 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); | 513 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); |
501 timezone_list->Append(timezone_option.release()); | 514 timezone_list->Append(timezone_option.release()); |
502 } | 515 } |
503 | 516 |
504 return timezone_list.release(); | 517 return timezone_list.release(); |
505 } | 518 } |
506 | 519 |
507 } // namespace chromeos | 520 } // namespace chromeos |
OLD | NEW |