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/options/chromeos/cros_language_options_handler .h" | 5 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler .h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 | 56 |
57 namespace chromeos { | 57 namespace chromeos { |
58 namespace options { | 58 namespace options { |
59 | 59 |
60 const char kVendorOtherLanguagesListDivider[] = | 60 const char kVendorOtherLanguagesListDivider[] = |
61 "VENDOR_OTHER_LANGUAGES_LIST_DIVIDER"; | 61 "VENDOR_OTHER_LANGUAGES_LIST_DIVIDER"; |
62 | 62 |
63 CrosLanguageOptionsHandler::CrosLanguageOptionsHandler() | 63 CrosLanguageOptionsHandler::CrosLanguageOptionsHandler() |
64 : composition_extension_appended_(false), | 64 : composition_extension_appended_(false), |
65 is_page_initialized_(false) { | 65 is_page_initialized_(false) { |
66 input_method::InputMethodManager::Get()->GetComponentExtensionIMEManager()-> | |
67 AddObserver(this); | |
68 } | 66 } |
69 | 67 |
70 CrosLanguageOptionsHandler::~CrosLanguageOptionsHandler() { | 68 CrosLanguageOptionsHandler::~CrosLanguageOptionsHandler() { |
71 input_method::InputMethodManager::Get()->GetComponentExtensionIMEManager()-> | |
72 RemoveObserver(this); | |
73 } | 69 } |
74 | 70 |
75 void CrosLanguageOptionsHandler::GetLocalizedValues( | 71 void CrosLanguageOptionsHandler::GetLocalizedValues( |
76 base::DictionaryValue* localized_strings) { | 72 base::DictionaryValue* localized_strings) { |
77 ::options::LanguageOptionsHandlerCommon::GetLocalizedValues( | 73 ::options::LanguageOptionsHandlerCommon::GetLocalizedValues( |
78 localized_strings); | 74 localized_strings); |
79 | 75 |
80 RegisterTitle(localized_strings, "languagePage", | 76 RegisterTitle(localized_strings, "languagePage", |
81 IDS_OPTIONS_SETTINGS_LANGUAGES_AND_INPUT_DIALOG_TITLE); | 77 IDS_OPTIONS_SETTINGS_LANGUAGES_AND_INPUT_DIALOG_TITLE); |
82 localized_strings->SetString("okButton", l10n_util::GetStringUTF16(IDS_OK)); | 78 localized_strings->SetString("okButton", l10n_util::GetStringUTF16(IDS_OK)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 manager->GetInputMethodExtensions(&ext_ime_descriptors); | 117 manager->GetInputMethodExtensions(&ext_ime_descriptors); |
122 | 118 |
123 base::ListValue* ext_ime_list = ConvertInputMethodDescriptorsToIMEList( | 119 base::ListValue* ext_ime_list = ConvertInputMethodDescriptorsToIMEList( |
124 ext_ime_descriptors); | 120 ext_ime_descriptors); |
125 AddImeProvider(ext_ime_list); | 121 AddImeProvider(ext_ime_list); |
126 localized_strings->Set("extensionImeList", ext_ime_list); | 122 localized_strings->Set("extensionImeList", ext_ime_list); |
127 | 123 |
128 ComponentExtensionIMEManager* component_extension_manager = | 124 ComponentExtensionIMEManager* component_extension_manager = |
129 input_method::InputMethodManager::Get() | 125 input_method::InputMethodManager::Get() |
130 ->GetComponentExtensionIMEManager(); | 126 ->GetComponentExtensionIMEManager(); |
131 if (component_extension_manager->IsInitialized()) { | 127 localized_strings->Set( |
132 localized_strings->Set( | 128 "componentExtensionImeList", |
133 "componentExtensionImeList", | 129 ConvertInputMethodDescriptorsToIMEList( |
134 ConvertInputMethodDescriptorsToIMEList( | 130 component_extension_manager->GetAllIMEAsInputMethodDescriptor())); |
135 component_extension_manager->GetAllIMEAsInputMethodDescriptor())); | 131 composition_extension_appended_ = true; |
136 composition_extension_appended_ = true; | |
137 } else { | |
138 // If component extension IME manager is not ready for use, it will be | |
139 // added in |InitializePage()|. | |
140 localized_strings->Set("componentExtensionImeList", | |
141 new base::ListValue()); | |
142 } | |
143 } | 132 } |
144 | 133 |
145 void CrosLanguageOptionsHandler::RegisterMessages() { | 134 void CrosLanguageOptionsHandler::RegisterMessages() { |
146 ::options::LanguageOptionsHandlerCommon::RegisterMessages(); | 135 ::options::LanguageOptionsHandlerCommon::RegisterMessages(); |
147 | 136 |
148 web_ui()->RegisterMessageCallback("inputMethodDisable", | 137 web_ui()->RegisterMessageCallback("inputMethodDisable", |
149 base::Bind(&CrosLanguageOptionsHandler::InputMethodDisableCallback, | 138 base::Bind(&CrosLanguageOptionsHandler::InputMethodDisableCallback, |
150 base::Unretained(this))); | 139 base::Unretained(this))); |
151 web_ui()->RegisterMessageCallback("inputMethodEnable", | 140 web_ui()->RegisterMessageCallback("inputMethodEnable", |
152 base::Bind(&CrosLanguageOptionsHandler::InputMethodEnableCallback, | 141 base::Bind(&CrosLanguageOptionsHandler::InputMethodEnableCallback, |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 SINGLETON_TAB, | 491 SINGLETON_TAB, |
503 content::PAGE_TRANSITION_LINK, | 492 content::PAGE_TRANSITION_LINK, |
504 false); | 493 false); |
505 browser->OpenURL(params); | 494 browser->OpenURL(params); |
506 browser->window()->Show(); | 495 browser->window()->Show(); |
507 content::WebContents* web_contents = | 496 content::WebContents* web_contents = |
508 browser->tab_strip_model()->GetActiveWebContents(); | 497 browser->tab_strip_model()->GetActiveWebContents(); |
509 web_contents->GetDelegate()->ActivateContents(web_contents); | 498 web_contents->GetDelegate()->ActivateContents(web_contents); |
510 } | 499 } |
511 | 500 |
512 void CrosLanguageOptionsHandler::OnImeComponentExtensionInitialized() { | |
513 if (composition_extension_appended_ || !is_page_initialized_) { | |
514 // If an option page is not ready to call JavaScript, appending component | |
515 // extension IMEs will be done in InitializePage function later. | |
516 return; | |
517 } | |
518 | |
519 ComponentExtensionIMEManager* manager = | |
520 input_method::InputMethodManager::Get() | |
521 ->GetComponentExtensionIMEManager(); | |
522 | |
523 DCHECK(manager->IsInitialized()); | |
524 scoped_ptr<base::ListValue> ime_list( | |
525 ConvertInputMethodDescriptorsToIMEList( | |
526 manager->GetAllIMEAsInputMethodDescriptor())); | |
527 web_ui()->CallJavascriptFunction( | |
528 "options.LanguageOptions.onComponentManagerInitialized", | |
529 *ime_list); | |
530 composition_extension_appended_ = true; | |
531 } | |
532 | |
533 void CrosLanguageOptionsHandler::InitializePage() { | 501 void CrosLanguageOptionsHandler::InitializePage() { |
534 is_page_initialized_ = true; | 502 is_page_initialized_ = true; |
535 if (composition_extension_appended_) | 503 if (composition_extension_appended_) |
Alexander Alekseev
2014/07/14 14:07:29
It seems that IME is now accessed in GetLocalizedV
Shu Chen
2014/07/14 15:07:21
Done.
| |
536 return; | 504 return; |
537 | 505 |
538 ComponentExtensionIMEManager* component_extension_manager = | 506 ComponentExtensionIMEManager* component_extension_manager = |
539 input_method::InputMethodManager::Get() | 507 input_method::InputMethodManager::Get() |
540 ->GetComponentExtensionIMEManager(); | 508 ->GetComponentExtensionIMEManager(); |
541 if (!component_extension_manager->IsInitialized()) { | |
542 // If the component extension IME manager is not available yet, append the | |
543 // component extension list in |OnInitialized()|. | |
544 return; | |
545 } | |
546 | 509 |
547 scoped_ptr<base::ListValue> ime_list( | 510 scoped_ptr<base::ListValue> ime_list( |
548 ConvertInputMethodDescriptorsToIMEList( | 511 ConvertInputMethodDescriptorsToIMEList( |
549 component_extension_manager->GetAllIMEAsInputMethodDescriptor())); | 512 component_extension_manager->GetAllIMEAsInputMethodDescriptor())); |
550 web_ui()->CallJavascriptFunction( | 513 web_ui()->CallJavascriptFunction( |
551 "options.LanguageOptions.onComponentManagerInitialized", | 514 "options.LanguageOptions.onComponentManagerInitialized", |
552 *ime_list); | 515 *ime_list); |
553 composition_extension_appended_ = true; | 516 composition_extension_appended_ = true; |
554 } | 517 } |
555 | 518 |
(...skipping 12 matching lines...) Expand all Loading... | |
568 extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id); | 531 extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id); |
569 const extensions::Extension* extension = | 532 const extensions::Extension* extension = |
570 enabled_extensions.GetByID(extension_id); | 533 enabled_extensions.GetByID(extension_id); |
571 if (extension) | 534 if (extension) |
572 entry->SetString("extensionName", extension->name()); | 535 entry->SetString("extensionName", extension->name()); |
573 } | 536 } |
574 } | 537 } |
575 | 538 |
576 } // namespace options | 539 } // namespace options |
577 } // namespace chromeos | 540 } // namespace chromeos |
OLD | NEW |