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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc

Issue 178343005: [IME] migrate the xkb ID to extension based xkb ID. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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
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/ui/webui/chromeos/login/network_screen_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/chromeos/input_method/input_method_util.h" 21 #include "chrome/browser/chromeos/input_method/input_method_util.h"
22 #include "chrome/browser/chromeos/login/input_events_blocker.h" 22 #include "chrome/browser/chromeos/login/input_events_blocker.h"
23 #include "chrome/browser/chromeos/login/login_display_host_impl.h" 23 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
24 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h" 24 #include "chrome/browser/chromeos/login/screens/core_oobe_actor.h"
25 #include "chrome/browser/chromeos/system/input_device_settings.h" 25 #include "chrome/browser/chromeos/system/input_device_settings.h"
26 #include "chrome/browser/chromeos/system/timezone_util.h" 26 #include "chrome/browser/chromeos/system/timezone_util.h"
27 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 27 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
28 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler .h" 28 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler .h"
29 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
30 #include "chromeos/chromeos_switches.h" 30 #include "chromeos/chromeos_switches.h"
31 #include "chromeos/ime/extension_ime_util.h"
31 #include "chromeos/ime/input_method_manager.h" 32 #include "chromeos/ime/input_method_manager.h"
32 #include "grit/chromium_strings.h" 33 #include "grit/chromium_strings.h"
33 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
34 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/gfx/rect.h" 36 #include "ui/gfx/rect.h"
36 #include "ui/views/layout/fill_layout.h" 37 #include "ui/views/layout/fill_layout.h"
37 #include "ui/views/widget/widget.h" 38 #include "ui/views/widget/widget.h"
38 39
39 namespace { 40 namespace {
40 41
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 385 }
385 386
386 // static 387 // static
387 base::ListValue* NetworkScreenHandler::GetInputMethods() { 388 base::ListValue* NetworkScreenHandler::GetInputMethods() {
388 base::ListValue* input_methods_list = new base::ListValue; 389 base::ListValue* input_methods_list = new base::ListValue;
389 input_method::InputMethodManager* manager = 390 input_method::InputMethodManager* manager =
390 input_method::InputMethodManager::Get(); 391 input_method::InputMethodManager::Get();
391 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); 392 input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
392 scoped_ptr<input_method::InputMethodDescriptors> input_methods( 393 scoped_ptr<input_method::InputMethodDescriptors> input_methods(
393 manager->GetActiveInputMethods()); 394 manager->GetActiveInputMethods());
394 std::string current_input_method_id = manager->GetCurrentInputMethod().id(); 395 // Uses extension_ime_util::MaybeGetLegacyXkbId() to make sure the input
396 // method id is in legacy xkb id format (e.g. xkb:us::eng), instead of
397 // extension based xkd id format (e.g. _comp_ime_...xkb:us::eng).
398 // Same for the rests.
399 // TODO(shuchen): support wait for component extension loading, and then show
400 // OOBE window. So that extension_ime_util::MaybeGetLegacyXkbId() can be
401 // removed.
402 std::string current_input_method_id = extension_ime_util::MaybeGetLegacyXkbId(
403 manager->GetCurrentInputMethod().id());
395 const std::vector<std::string>& hardware_login_input_methods = 404 const std::vector<std::string>& hardware_login_input_methods =
396 util->GetHardwareLoginInputMethodIds(); 405 util->GetHardwareLoginInputMethodIds();
397 std::set<std::string> input_methods_added; 406 std::set<std::string> input_methods_added;
398 407
399 for (std::vector<std::string>::const_iterator i = 408 for (std::vector<std::string>::const_iterator i =
400 hardware_login_input_methods.begin(); 409 hardware_login_input_methods.begin();
401 i != hardware_login_input_methods.end(); 410 i != hardware_login_input_methods.end();
402 ++i) { 411 ++i) {
403 input_methods_added.insert(*i); 412 // Makes sure the id is in legacy xkb id format.
413 const std::string id = extension_ime_util::MaybeGetLegacyXkbId(*i);
414 input_methods_added.insert(id);
404 const input_method::InputMethodDescriptor* ime = 415 const input_method::InputMethodDescriptor* ime =
405 util->GetInputMethodDescriptorFromId(*i); 416 util->GetInputMethodDescriptorFromId(id);
406 DCHECK(ime != NULL); 417 DCHECK(ime != NULL);
407 // Do not crash in case of misconfiguration. 418 // Do not crash in case of misconfiguration.
408 if (ime != NULL) { 419 if (ime != NULL) {
409 input_methods_list->Append( 420 input_methods_list->Append(
410 CreateInputMethodsEntry(*ime, current_input_method_id)); 421 CreateInputMethodsEntry(*ime, current_input_method_id));
411 } 422 }
412 } 423 }
413 424
414 bool optgroup_added = false; 425 bool optgroup_added = false;
415 for (size_t i = 0; i < input_methods->size(); ++i) { 426 for (size_t i = 0; i < input_methods->size(); ++i) {
416 const std::string& ime_id = input_methods->at(i).id(); 427 // Makes sure the id is in legacy xkb id format.
428 const std::string& ime_id = extension_ime_util::MaybeGetLegacyXkbId(
429 input_methods->at(i).id());
Yuki 2014/03/04 04:04:45 Please do not use std::vector::at() even though th
Shu Chen 2014/03/04 04:45:02 Done.
417 if (!InsertString(ime_id, input_methods_added)) 430 if (!InsertString(ime_id, input_methods_added))
418 continue; 431 continue;
419 if (!optgroup_added) { 432 if (!optgroup_added) {
420 optgroup_added = true; 433 optgroup_added = true;
421 AddOptgroupOtherLayouts(input_methods_list); 434 AddOptgroupOtherLayouts(input_methods_list);
422 } 435 }
423 input_methods_list->Append( 436 input_methods_list->Append(
424 CreateInputMethodsEntry(input_methods->at(i), current_input_method_id)); 437 CreateInputMethodsEntry(input_methods->at(i), current_input_method_id));
Yuki 2014/03/04 04:04:45 Please change this line, too. Using std::vector::
Shu Chen 2014/03/04 04:45:02 Done.
425 } 438 }
426 // "xkb:us::eng" should always be in the list of available layouts. 439 // "xkb:us::eng" should always be in the list of available layouts.
427 if (input_methods_added.count(kUSlayout) == 0) { 440 if (input_methods_added.count(kUSlayout) == 0) {
428 const input_method::InputMethodDescriptor* us_eng_descriptor = 441 const input_method::InputMethodDescriptor* us_eng_descriptor =
429 util->GetInputMethodDescriptorFromId(kUSlayout); 442 util->GetInputMethodDescriptorFromId(kUSlayout);
430 DCHECK(us_eng_descriptor != NULL); 443 DCHECK(us_eng_descriptor != NULL);
431 if (!optgroup_added) { 444 if (!optgroup_added) {
432 optgroup_added = true; 445 optgroup_added = true;
433 AddOptgroupOtherLayouts(input_methods_list); 446 AddOptgroupOtherLayouts(input_methods_list);
434 } 447 }
(...skipping 25 matching lines...) Expand all
460 timezone_option->SetString("value", timezone_id); 473 timezone_option->SetString("value", timezone_id);
461 timezone_option->SetString("title", timezone_name); 474 timezone_option->SetString("title", timezone_name);
462 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id); 475 timezone_option->SetBoolean("selected", timezone_id == current_timezone_id);
463 timezone_list->Append(timezone_option.release()); 476 timezone_list->Append(timezone_option.release());
464 } 477 }
465 478
466 return timezone_list.release(); 479 return timezone_list.release();
467 } 480 }
468 481
469 } // namespace chromeos 482 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698