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

Unified Diff: chrome/browser/chromeos/extensions/input_method_api.cc

Issue 1897913002: Input method functions for chrome.languageSettingsPrivate and chrome.inputMethodPrivate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/input_method_api.cc
diff --git a/chrome/browser/chromeos/extensions/input_method_api.cc b/chrome/browser/chromeos/extensions/input_method_api.cc
index 10d43f2c390921a62ab7a462f63ef432cd1639d8..dc2b7cbd11e9fd76e80c60f485271ecd6e85732a 100644
--- a/chrome/browser/chromeos/extensions/input_method_api.cc
+++ b/chrome/browser/chromeos/extensions/input_method_api.cc
@@ -23,6 +23,8 @@
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/api/input_method_private.h"
#include "chrome/common/pref_names.h"
@@ -43,6 +45,8 @@ namespace AddWordToDictionary =
namespace SetCurrentInputMethod =
extensions::api::input_method_private::SetCurrentInputMethod;
namespace SetXkbLayout = extensions::api::input_method_private::SetXkbLayout;
+namespace OpenOptionsPage =
+ extensions::api::input_method_private::OpenOptionsPage;
namespace OnChanged = extensions::api::input_method_private::OnChanged;
namespace OnDictionaryChanged =
extensions::api::input_method_private::OnDictionaryChanged;
@@ -263,6 +267,34 @@ InputMethodPrivateShowInputViewFunction::Run() {
#endif
}
+ExtensionFunction::ResponseAction
+InputMethodPrivateOpenOptionsPageFunction::Run() {
+#if !defined(OS_CHROMEOS)
+ EXTENSION_FUNCTION_VALIDATE(false);
+#else
+ std::unique_ptr<OpenOptionsPage::Params> params(
+ OpenOptionsPage::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+ scoped_refptr<chromeos::input_method::InputMethodManager::State> ime_state =
+ chromeos::input_method::InputMethodManager::Get()->GetActiveIMEState();
+ const chromeos::input_method::InputMethodDescriptor* ime =
+ ime_state->GetInputMethodFromId(params->input_method_id);
Shu Chen 2016/04/19 02:33:57 A null check for |ime| should be necessary.
michaelpg 2016/04/20 02:41:09 Done.
+
+ content::WebContents* web_contents = GetSenderWebContents();
+ if (web_contents) {
+ const GURL& options_page_url = ime->options_page_url();
+ if (!options_page_url.is_empty()) {
+ Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
+ content::OpenURLParams url_params(options_page_url, content::Referrer(),
+ SINGLETON_TAB, ui::PAGE_TRANSITION_LINK,
+ false);
+ browser->OpenURL(url_params);
Shu Chen 2016/04/19 02:33:57 Can we use chrome::ShowSingletonTabOverwritingNTP(
michaelpg 2016/04/20 02:41:09 This makes the page open in the current tab (Setti
Shu Chen 2016/04/20 06:38:33 ACK.
+ }
+ }
+ return RespondNow(NoArguments());
+#endif
+}
+
InputMethodAPI::InputMethodAPI(content::BrowserContext* context)
: context_(context) {
EventRouter::Get(context_)->RegisterObserver(this, OnChanged::kEventName);
@@ -288,6 +320,7 @@ InputMethodAPI::InputMethodAPI(content::BrowserContext* context)
registry->RegisterFunction<InputMethodPrivateGetEncryptSyncEnabledFunction>();
registry->RegisterFunction<
InputMethodPrivateNotifyImeMenuItemActivatedFunction>();
+ registry->RegisterFunction<InputMethodPrivateOpenOptionsPageFunction>();
}
InputMethodAPI::~InputMethodAPI() {

Powered by Google App Engine
This is Rietveld 408576698