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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc

Issue 136693012: [IME] Supports options page for each IME instead of single options page for each IME extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 11 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
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/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
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 base::string16 options_page_str16;
not at google - send to devlin 2014/01/16 01:04:26 I'd feel more comfortable if we didn't trust what
Shu Chen 2014/01/16 05:52:15 Done.
359 extension_service()->extensions()->GetByID(extension_id); 361 if (!args->GetString(1, &options_page_str16))
360 if (!extension ||
361 extensions::ManifestURL::GetOptionsPage(extension).is_empty()) {
362 return; 362 return;
363 } 363
364 extensions::ExtensionTabUtil::OpenOptionsPage( 364 Browser* browser = chrome::FindBrowserWithWebContents(
365 extension, 365 web_ui()->GetWebContents());
366 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())); 366 content::OpenURLParams params(GURL(options_page_str16),
367 content::Referrer(),
368 SINGLETON_TAB,
369 content::PAGE_TRANSITION_LINK,
370 false);
371 browser->OpenURL(params);
372 browser->window()->Show();
373 content::WebContents* web_contents =
374 browser->tab_strip_model()->GetActiveWebContents();
375 web_contents->GetDelegate()->ActivateContents(web_contents);
367 } 376 }
368 377
369 void CrosLanguageOptionsHandler::OnInitialized() { 378 void CrosLanguageOptionsHandler::OnInitialized() {
370 if (composition_extension_appended_ || !is_page_initialized_) { 379 if (composition_extension_appended_ || !is_page_initialized_) {
371 // If an option page is not ready to call JavaScript, appending component 380 // If an option page is not ready to call JavaScript, appending component
372 // extension IMEs will be done in InitializePage function later. 381 // extension IMEs will be done in InitializePage function later.
373 return; 382 return;
374 } 383 }
375 384
376 ComponentExtensionIMEManager* manager = 385 ComponentExtensionIMEManager* manager =
(...skipping 28 matching lines...) Expand all
405 ConvertInputMethodDescriptosToIMEList( 414 ConvertInputMethodDescriptosToIMEList(
406 component_extension_manager->GetAllIMEAsInputMethodDescriptor())); 415 component_extension_manager->GetAllIMEAsInputMethodDescriptor()));
407 web_ui()->CallJavascriptFunction( 416 web_ui()->CallJavascriptFunction(
408 "options.LanguageOptions.onComponentManagerInitialized", 417 "options.LanguageOptions.onComponentManagerInitialized",
409 *ime_list); 418 *ime_list);
410 composition_extension_appended_ = true; 419 composition_extension_appended_ = true;
411 } 420 }
412 421
413 } // namespace options 422 } // namespace options
414 } // namespace chromeos 423 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698