Commit 324cddef authored by nona@chromium.org's avatar nona@chromium.org

Move GetFallbackInputMethodDescriptor function to InputMethodUtil.

I think this function should be in InputMethodUtil rather than in InputMethodDescriptors.
Let me clean up InputMethodDescriptor before starting refactoring.

BUG=164375
TEST=None, ran unit_tests.

Review URL: https://chromiumcodereview.appspot.com/13954012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195121 0039d316-1c4b-4281-b951-d872f2087c98
parent 429b5716
...@@ -130,7 +130,7 @@ InputMethodManagerImpl::GetActiveInputMethods() const { ...@@ -130,7 +130,7 @@ InputMethodManagerImpl::GetActiveInputMethods() const {
// Initially |active_input_method_ids_| is empty. browser_tests might take // Initially |active_input_method_ids_| is empty. browser_tests might take
// this path. // this path.
result->push_back( result->push_back(
InputMethodDescriptor::GetFallbackInputMethodDescriptor()); InputMethodUtil::GetFallbackInputMethodDescriptor());
} }
return result.Pass(); return result.Pass();
} }
...@@ -612,7 +612,7 @@ void InputMethodManagerImpl::SwitchToNextInputMethodInternal( ...@@ -612,7 +612,7 @@ void InputMethodManagerImpl::SwitchToNextInputMethodInternal(
InputMethodDescriptor InputMethodManagerImpl::GetCurrentInputMethod() const { InputMethodDescriptor InputMethodManagerImpl::GetCurrentInputMethod() const {
if (current_input_method_.id().empty()) if (current_input_method_.id().empty())
return InputMethodDescriptor::GetFallbackInputMethodDescriptor(); return InputMethodUtil::GetFallbackInputMethodDescriptor();
return current_input_method_; return current_input_method_;
} }
......
...@@ -601,7 +601,7 @@ std::string InputMethodUtil::GetHardwareInputMethodId() const { ...@@ -601,7 +601,7 @@ std::string InputMethodUtil::GetHardwareInputMethodId() const {
// This is totally fine if it's empty. The hardware keyboard layout is // This is totally fine if it's empty. The hardware keyboard layout is
// not stored if startup_manifest.json (OEM customization data) is not // not stored if startup_manifest.json (OEM customization data) is not
// present (ex. Cr48 doen't have that file). // present (ex. Cr48 doen't have that file).
return InputMethodDescriptor::GetFallbackInputMethodDescriptor().id(); return GetFallbackInputMethodDescriptor().id();
} }
return input_method_id; return input_method_id;
} }
...@@ -619,6 +619,15 @@ void InputMethodUtil::SetComponentExtensions( ...@@ -619,6 +619,15 @@ void InputMethodUtil::SetComponentExtensions(
} }
} }
InputMethodDescriptor InputMethodUtil::GetFallbackInputMethodDescriptor() {
return InputMethodDescriptor("xkb:us::eng",
"",
"us",
"en-US",
"", // options page, not available.
false);
}
void InputMethodUtil::ReloadInternalMaps() { void InputMethodUtil::ReloadInternalMaps() {
if (supported_input_methods_->size() <= 1) { if (supported_input_methods_->size() <= 1) {
DVLOG(1) << "GetSupportedInputMethods returned a fallback ID"; DVLOG(1) << "GetSupportedInputMethods returned a fallback ID";
......
...@@ -114,6 +114,11 @@ class InputMethodUtil { ...@@ -114,6 +114,11 @@ class InputMethodUtil {
// Sets the list of component extension IMEs. // Sets the list of component extension IMEs.
void SetComponentExtensions(const InputMethodDescriptors& imes); void SetComponentExtensions(const InputMethodDescriptors& imes);
// Returns the fallback input method descriptor (the very basic US
// keyboard). This function is mostly used for testing, but may be used
// as the fallback, when there is no other choice.
static InputMethodDescriptor GetFallbackInputMethodDescriptor();
protected: protected:
// protected: for unit testing as well. // protected: for unit testing as well.
bool GetInputMethodIdsFromLanguageCodeInternal( bool GetInputMethodIdsFromLanguageCodeInternal(
......
...@@ -38,7 +38,7 @@ scoped_ptr<InputMethodDescriptors> ...@@ -38,7 +38,7 @@ scoped_ptr<InputMethodDescriptors>
MockInputMethodManager::GetSupportedInputMethods() const { MockInputMethodManager::GetSupportedInputMethods() const {
scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
result->push_back( result->push_back(
InputMethodDescriptor::GetFallbackInputMethodDescriptor()); InputMethodUtil::GetFallbackInputMethodDescriptor());
return result.Pass(); return result.Pass();
} }
...@@ -46,7 +46,7 @@ scoped_ptr<InputMethodDescriptors> ...@@ -46,7 +46,7 @@ scoped_ptr<InputMethodDescriptors>
MockInputMethodManager::GetActiveInputMethods() const { MockInputMethodManager::GetActiveInputMethods() const {
scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
result->push_back( result->push_back(
InputMethodDescriptor::GetFallbackInputMethodDescriptor()); InputMethodUtil::GetFallbackInputMethodDescriptor());
return result.Pass(); return result.Pass();
} }
...@@ -112,7 +112,7 @@ bool MockInputMethodManager::SwitchInputMethod( ...@@ -112,7 +112,7 @@ bool MockInputMethodManager::SwitchInputMethod(
InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const { InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
InputMethodDescriptor descriptor = InputMethodDescriptor descriptor =
InputMethodDescriptor::GetFallbackInputMethodDescriptor(); InputMethodUtil::GetFallbackInputMethodDescriptor();
if (!current_input_method_id_.empty()) { if (!current_input_method_id_.empty()) {
return InputMethodDescriptor(current_input_method_id_, return InputMethodDescriptor(current_input_method_id_,
descriptor.name(), descriptor.name(),
......
...@@ -12,10 +12,6 @@ ...@@ -12,10 +12,6 @@
namespace chromeos { namespace chromeos {
namespace input_method { namespace input_method {
namespace {
const char kFallbackLayout[] = "us";
} // namespace
InputMethodDescriptor::InputMethodDescriptor( InputMethodDescriptor::InputMethodDescriptor(
const std::string& id, const std::string& id,
const std::string& name, const std::string& name,
...@@ -47,27 +43,5 @@ bool InputMethodDescriptor::operator!=( ...@@ -47,27 +43,5 @@ bool InputMethodDescriptor::operator!=(
return !(*this == other); return !(*this == other);
} }
// static
InputMethodDescriptor
InputMethodDescriptor::GetFallbackInputMethodDescriptor() {
return InputMethodDescriptor("xkb:us::eng",
"",
kFallbackLayout,
"en-US",
"", // options page, not available.
false);
}
std::string InputMethodDescriptor::ToString() const {
std::stringstream stream;
stream << "id=" << id()
<< ", name=" << name()
<< ", keyboard_layout=" << keyboard_layout()
<< ", language_code=" << language_code()
<< ", options_page_url=" << options_page_url()
<< ", third_party=" << third_party();
return stream.str();
}
} // namespace input_method } // namespace input_method
} // namespace chromeos } // namespace chromeos
...@@ -31,9 +31,6 @@ class CHROMEOS_EXPORT InputMethodDescriptor { ...@@ -31,9 +31,6 @@ class CHROMEOS_EXPORT InputMethodDescriptor {
bool operator==(const InputMethodDescriptor& other) const; bool operator==(const InputMethodDescriptor& other) const;
bool operator!=(const InputMethodDescriptor& other) const; bool operator!=(const InputMethodDescriptor& other) const;
// Debug print function.
std::string ToString() const;
const std::string& id() const { return id_; } const std::string& id() const { return id_; }
const std::string& name() const { return name_; } const std::string& name() const { return name_; }
const std::string& keyboard_layout() const { return keyboard_layout_; } const std::string& keyboard_layout() const { return keyboard_layout_; }
...@@ -41,11 +38,6 @@ class CHROMEOS_EXPORT InputMethodDescriptor { ...@@ -41,11 +38,6 @@ class CHROMEOS_EXPORT InputMethodDescriptor {
const std::string& options_page_url() const { return options_page_url_; } const std::string& options_page_url() const { return options_page_url_; }
bool third_party() const { return third_party_; } bool third_party() const { return third_party_; }
// Returns the fallback input method descriptor (the very basic US
// keyboard). This function is mostly used for testing, but may be used
// as the fallback, when there is no other choice.
static InputMethodDescriptor GetFallbackInputMethodDescriptor();
private: private:
// An ID that identifies an input method engine (e.g., "t:latn-post", // An ID that identifies an input method engine (e.g., "t:latn-post",
// "pinyin", "hangul"). // "pinyin", "hangul").
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment