Chromium Code Reviews| 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 19 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/extensions/extension_system.h" | 21 #include "chrome/browser/extensions/extension_system.h" |
| 22 #include "chrome/browser/extensions/extension_tab_util.h" | 22 #include "chrome/browser/extensions/extension_tab_util.h" |
| 23 #include "chrome/browser/lifetime/application_lifetime.h" | 23 #include "chrome/browser/lifetime/application_lifetime.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_finder.h" | 26 #include "chrome/browser/ui/browser_finder.h" |
| 27 #include "chrome/browser/ui/browser_window.h" | |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 27 #include "chrome/common/extensions/manifest_url_handler.h" | 29 #include "chrome/common/extensions/manifest_url_handler.h" |
| 28 #include "chromeos/ime/component_extension_ime_manager.h" | 30 #include "chromeos/ime/component_extension_ime_manager.h" |
| 29 #include "chromeos/ime/extension_ime_util.h" | 31 #include "chromeos/ime/extension_ime_util.h" |
| 30 #include "chromeos/ime/input_method_manager.h" | 32 #include "chromeos/ime/input_method_manager.h" |
| 31 #include "content/public/browser/navigation_controller.h" | 33 #include "content/public/browser/navigation_controller.h" |
| 32 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
| 33 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| 34 #include "extensions/common/extension.h" | 36 #include "extensions/common/extension.h" |
| 35 #include "grit/chromium_strings.h" | 37 #include "grit/chromium_strings.h" |
| 36 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 const base::ListValue* args) { | 349 const base::ListValue* args) { |
| 348 const std::string input_method_id = UTF16ToASCII(ExtractStringValue(args)); | 350 const std::string input_method_id = UTF16ToASCII(ExtractStringValue(args)); |
| 349 const std::string action = base::StringPrintf( | 351 const std::string action = base::StringPrintf( |
| 350 "InputMethodOptions_Open_%s", input_method_id.c_str()); | 352 "InputMethodOptions_Open_%s", input_method_id.c_str()); |
| 351 content::RecordComputedAction(action); | 353 content::RecordComputedAction(action); |
| 352 | 354 |
| 353 const std::string extension_id = | 355 const std::string extension_id = |
| 354 extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id); | 356 extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id); |
| 355 if (extension_id.empty()) | 357 if (extension_id.empty()) |
| 356 return; | 358 return; |
| 357 const extensions::Extension* extension = | 359 |
| 358 extensions::ExtensionSystem::Get(Profile::FromWebUI(web_ui()))-> | 360 const input_method::InputMethodDescriptor* ime = |
| 359 extension_service()->extensions()->GetByID(extension_id); | 361 input_method::InputMethodManager::Get()->GetInputMethodFromId( |
| 360 if (!extension || | 362 input_method_id); |
| 361 extensions::ManifestURL::GetOptionsPage(extension).is_empty()) { | 363 if (!ime) { |
| 362 return; | 364 return; |
| 363 } | 365 } |
| 364 extensions::ExtensionTabUtil::OpenOptionsPage( | 366 |
| 365 extension, | 367 Browser* browser = chrome::FindBrowserWithWebContents( |
| 366 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())); | 368 web_ui()->GetWebContents()); |
| 369 content::OpenURLParams params(ime->options_page_url(), | |
| 370 content::Referrer(), | |
| 371 SINGLETON_TAB, | |
| 372 content::PAGE_TRANSITION_LINK, | |
| 373 false); | |
| 374 browser->OpenURL(params); | |
| 375 browser->window()->Show(); | |
| 376 content::WebContents* web_contents = | |
| 377 browser->tab_strip_model()->GetActiveWebContents(); | |
|
not at google - send to devlin
2014/01/16 17:51:14
indent += 2
Shu Chen
2014/01/17 02:52:36
Done.
| |
| 378 web_contents->GetDelegate()->ActivateContents(web_contents); | |
| 367 } | 379 } |
| 368 | 380 |
| 369 void CrosLanguageOptionsHandler::OnInitialized() { | 381 void CrosLanguageOptionsHandler::OnInitialized() { |
| 370 if (composition_extension_appended_ || !is_page_initialized_) { | 382 if (composition_extension_appended_ || !is_page_initialized_) { |
| 371 // If an option page is not ready to call JavaScript, appending component | 383 // If an option page is not ready to call JavaScript, appending component |
| 372 // extension IMEs will be done in InitializePage function later. | 384 // extension IMEs will be done in InitializePage function later. |
| 373 return; | 385 return; |
| 374 } | 386 } |
| 375 | 387 |
| 376 ComponentExtensionIMEManager* manager = | 388 ComponentExtensionIMEManager* manager = |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 405 ConvertInputMethodDescriptosToIMEList( | 417 ConvertInputMethodDescriptosToIMEList( |
| 406 component_extension_manager->GetAllIMEAsInputMethodDescriptor())); | 418 component_extension_manager->GetAllIMEAsInputMethodDescriptor())); |
| 407 web_ui()->CallJavascriptFunction( | 419 web_ui()->CallJavascriptFunction( |
| 408 "options.LanguageOptions.onComponentManagerInitialized", | 420 "options.LanguageOptions.onComponentManagerInitialized", |
| 409 *ime_list); | 421 *ime_list); |
| 410 composition_extension_appended_ = true; | 422 composition_extension_appended_ = true; |
| 411 } | 423 } |
| 412 | 424 |
| 413 } // namespace options | 425 } // namespace options |
| 414 } // namespace chromeos | 426 } // namespace chromeos |
| OLD | NEW |