summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl.cc13
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl.h2
-rw-r--r--chrome/browser/chromeos/input_method/mock_input_method_manager.cc12
-rw-r--r--chrome/browser/chromeos/input_method/mock_input_method_manager.h2
-rw-r--r--chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc29
-rw-r--r--chrome/common/extensions/api/input_ime/input_components_handler.cc20
-rw-r--r--chromeos/ime/input_method_manager.h5
-rw-r--r--extensions/common/manifest_constants.cc1
-rw-r--r--extensions/common/manifest_constants.h1
9 files changed, 74 insertions, 11 deletions
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
index 0b71019..762aaf4 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
@@ -146,6 +146,19 @@ size_t InputMethodManagerImpl::GetNumActiveInputMethods() const {
return active_input_method_ids_.size();
}
+const InputMethodDescriptor* InputMethodManagerImpl::GetInputMethodFromId(
+ const std::string& input_method_id) const {
+ const InputMethodDescriptor* ime = util_.GetInputMethodDescriptorFromId(
+ input_method_id);
+ if (!ime) {
+ std::map<std::string, InputMethodDescriptor>::const_iterator ix =
+ extra_input_methods_.find(input_method_id);
+ if (ix != extra_input_methods_.end())
+ ime = &ix->second;
+ }
+ return ime;
+}
+
void InputMethodManagerImpl::EnableLayouts(const std::string& language_code,
const std::string& initial_layout) {
if (state_ == STATE_TERMINATING)
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.h b/chrome/browser/chromeos/input_method/input_method_manager_impl.h
index 392e519..b3b2d68 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.h
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.h
@@ -57,6 +57,8 @@ class InputMethodManagerImpl : public InputMethodManager,
virtual const std::vector<std::string>& GetActiveInputMethodIds() const
OVERRIDE;
virtual size_t GetNumActiveInputMethods() const OVERRIDE;
+ virtual const InputMethodDescriptor* GetInputMethodFromId(
+ const std::string& input_method_id) const OVERRIDE;
virtual void EnableLayouts(const std::string& language_code,
const std::string& initial_layout) OVERRIDE;
virtual bool EnableInputMethods(
diff --git a/chrome/browser/chromeos/input_method/mock_input_method_manager.cc b/chrome/browser/chromeos/input_method/mock_input_method_manager.cc
index 4bc6077..d1d4bfc 100644
--- a/chrome/browser/chromeos/input_method/mock_input_method_manager.cc
+++ b/chrome/browser/chromeos/input_method/mock_input_method_manager.cc
@@ -60,6 +60,18 @@ size_t MockInputMethodManager::GetNumActiveInputMethods() const {
return 1;
}
+const InputMethodDescriptor* MockInputMethodManager::GetInputMethodFromId(
+ const std::string& input_method_id) const {
+ static const InputMethodDescriptor defaultInputMethod =
+ InputMethodUtil::GetFallbackInputMethodDescriptor();
+ for (size_t i = 0; i < active_input_method_ids_.size(); i++) {
+ if (input_method_id == active_input_method_ids_[i]) {
+ return &defaultInputMethod;
+ }
+ }
+ return NULL;
+}
+
void MockInputMethodManager::EnableLayouts(const std::string& language_code,
const std::string& initial_layout) {
}
diff --git a/chrome/browser/chromeos/input_method/mock_input_method_manager.h b/chrome/browser/chromeos/input_method/mock_input_method_manager.h
index f304e90..bc0710e 100644
--- a/chrome/browser/chromeos/input_method/mock_input_method_manager.h
+++ b/chrome/browser/chromeos/input_method/mock_input_method_manager.h
@@ -34,6 +34,8 @@ class MockInputMethodManager : public InputMethodManager {
virtual const std::vector<std::string>& GetActiveInputMethodIds() const
OVERRIDE;
virtual size_t GetNumActiveInputMethods() const OVERRIDE;
+ virtual const InputMethodDescriptor* GetInputMethodFromId(
+ const std::string& input_method_id) const OVERRIDE;
virtual void EnableLayouts(const std::string& language_code,
const std::string& initial_layout) OVERRIDE;
virtual bool EnableInputMethods(
diff --git a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
index 8bbcbb6..fb23688 100644
--- a/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc
@@ -24,6 +24,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chromeos/ime/component_extension_ime_manager.h"
#include "chromeos/ime/extension_ime_util.h"
@@ -354,16 +356,25 @@ void CrosLanguageOptionsHandler::InputMethodOptionsOpenCallback(
extension_ime_util::GetExtensionIDFromInputMethodID(input_method_id);
if (extension_id.empty())
return;
- const extensions::Extension* extension =
- extensions::ExtensionSystem::Get(Profile::FromWebUI(web_ui()))->
- extension_service()->extensions()->GetByID(extension_id);
- if (!extension ||
- extensions::ManifestURL::GetOptionsPage(extension).is_empty()) {
+
+ const input_method::InputMethodDescriptor* ime =
+ input_method::InputMethodManager::Get()->GetInputMethodFromId(
+ input_method_id);
+ if (!ime)
return;
- }
- extensions::ExtensionTabUtil::OpenOptionsPage(
- extension,
- chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()));
+
+ Browser* browser = chrome::FindBrowserWithWebContents(
+ web_ui()->GetWebContents());
+ content::OpenURLParams params(ime->options_page_url(),
+ content::Referrer(),
+ SINGLETON_TAB,
+ content::PAGE_TRANSITION_LINK,
+ false);
+ browser->OpenURL(params);
+ browser->window()->Show();
+ content::WebContents* web_contents =
+ browser->tab_strip_model()->GetActiveWebContents();
+ web_contents->GetDelegate()->ActivateContents(web_contents);
}
void CrosLanguageOptionsHandler::OnInitialized() {
diff --git a/chrome/common/extensions/api/input_ime/input_components_handler.cc b/chrome/common/extensions/api/input_ime/input_components_handler.cc
index 67a1c95..2fe6bf0 100644
--- a/chrome/common/extensions/api/input_ime/input_components_handler.cc
+++ b/chrome/common/extensions/api/input_ime/input_components_handler.cc
@@ -64,6 +64,7 @@ bool InputComponentsHandler::Parse(Extension* extension,
std::set<std::string> layouts;
std::string shortcut_keycode_str;
GURL input_view_url;
+ GURL options_page_url;
bool shortcut_alt = false;
bool shortcut_ctrl = false;
bool shortcut_shift = false;
@@ -194,6 +195,22 @@ bool InputComponentsHandler::Parse(Extension* extension,
}
}
+ // Get input_components[i].options_page_url.
+ // Note: 'options_page' is optional in manifest.
+ std::string options_page_str;
+ if (module_value->GetString(keys::kImeOptionsPage, &options_page_str)) {
+ options_page_url = extension->GetResourceURL(options_page_str);
+ if (!options_page_url.is_valid()) {
+ *error = ErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidOptionsPage,
+ base::IntToString(i));
+ return false;
+ }
+ } else {
+ // Fall back to extension's options page for backward compatibility.
+ options_page_url = extensions::ManifestURL::GetOptionsPage(extension);
+ }
+
info->input_components.push_back(InputComponentInfo());
info->input_components.back().name = name_str;
info->input_components.back().type = type;
@@ -206,8 +223,7 @@ bool InputComponentsHandler::Parse(Extension* extension,
info->input_components.back().shortcut_alt = shortcut_alt;
info->input_components.back().shortcut_ctrl = shortcut_ctrl;
info->input_components.back().shortcut_shift = shortcut_shift;
- info->input_components.back().options_page_url =
- extensions::ManifestURL::GetOptionsPage(extension);
+ info->input_components.back().options_page_url = options_page_url;
info->input_components.back().input_view_url = input_view_url;
}
extension->SetManifestData(keys::kInputComponents, info.release());
diff --git a/chromeos/ime/input_method_manager.h b/chromeos/ime/input_method_manager.h
index f293882..bbd5212 100644
--- a/chromeos/ime/input_method_manager.h
+++ b/chromeos/ime/input_method_manager.h
@@ -105,6 +105,11 @@ class CHROMEOS_EXPORT InputMethodManager {
// methods.
virtual size_t GetNumActiveInputMethods() const = 0;
+ // Returns the input method descriptor from the given input method id string.
+ // If the given input method id is invalid, returns NULL.
+ virtual const InputMethodDescriptor* GetInputMethodFromId(
+ const std::string& input_method_id) const = 0;
+
// Changes the current input method to |input_method_id|. If |input_method_id|
// is not active, switch to the first one in the active input method list.
virtual void ChangeInputMethod(const std::string& input_method_id) = 0;
diff --git a/extensions/common/manifest_constants.cc b/extensions/common/manifest_constants.cc
index b9db598..9e59b44 100644
--- a/extensions/common/manifest_constants.cc
+++ b/extensions/common/manifest_constants.cc
@@ -51,6 +51,7 @@ const char kHideBookmarkButton[] = "hide_bookmark_button";
const char kHomepageURL[] = "homepage_url";
const char kIcons[] = "icons";
const char kId[] = "id";
+const char kImeOptionsPage[] = "options_page";
const char kImport[] = "import";
const char kIncognito[] = "incognito";
const char kIncludeGlobs[] = "include_globs";
diff --git a/extensions/common/manifest_constants.h b/extensions/common/manifest_constants.h
index 595a54b..5552b1f 100644
--- a/extensions/common/manifest_constants.h
+++ b/extensions/common/manifest_constants.h
@@ -53,6 +53,7 @@ extern const char kHideBookmarkButton[];
extern const char kHomepageURL[];
extern const char kIcons[];
extern const char kId[];
+extern const char kImeOptionsPage[];
extern const char kImport[];
extern const char kIncognito[];
extern const char kIncludeGlobs[];