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 {
// Initially |active_input_method_ids_| is empty. browser_tests might take
// this path.
result->push_back(
InputMethodDescriptor::GetFallbackInputMethodDescriptor());
InputMethodUtil::GetFallbackInputMethodDescriptor());
}
return result.Pass();
}
......@@ -612,7 +612,7 @@ void InputMethodManagerImpl::SwitchToNextInputMethodInternal(
InputMethodDescriptor InputMethodManagerImpl::GetCurrentInputMethod() const {
if (current_input_method_.id().empty())
return InputMethodDescriptor::GetFallbackInputMethodDescriptor();
return InputMethodUtil::GetFallbackInputMethodDescriptor();
return current_input_method_;
}
......
......@@ -601,7 +601,7 @@ std::string InputMethodUtil::GetHardwareInputMethodId() const {
// This is totally fine if it's empty. The hardware keyboard layout is
// not stored if startup_manifest.json (OEM customization data) is not
// present (ex. Cr48 doen't have that file).
return InputMethodDescriptor::GetFallbackInputMethodDescriptor().id();
return GetFallbackInputMethodDescriptor().id();
}
return input_method_id;
}
......@@ -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() {
if (supported_input_methods_->size() <= 1) {
DVLOG(1) << "GetSupportedInputMethods returned a fallback ID";
......
......@@ -114,6 +114,11 @@ class InputMethodUtil {
// Sets the list of component extension 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: for unit testing as well.
bool GetInputMethodIdsFromLanguageCodeInternal(
......
......@@ -38,7 +38,7 @@ scoped_ptr<InputMethodDescriptors>
MockInputMethodManager::GetSupportedInputMethods() const {
scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
result->push_back(
InputMethodDescriptor::GetFallbackInputMethodDescriptor());
InputMethodUtil::GetFallbackInputMethodDescriptor());
return result.Pass();
}
......@@ -46,7 +46,7 @@ scoped_ptr<InputMethodDescriptors>
MockInputMethodManager::GetActiveInputMethods() const {
scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
result->push_back(
InputMethodDescriptor::GetFallbackInputMethodDescriptor());
InputMethodUtil::GetFallbackInputMethodDescriptor());
return result.Pass();
}
......@@ -112,7 +112,7 @@ bool MockInputMethodManager::SwitchInputMethod(
InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
InputMethodDescriptor descriptor =
InputMethodDescriptor::GetFallbackInputMethodDescriptor();
InputMethodUtil::GetFallbackInputMethodDescriptor();
if (!current_input_method_id_.empty()) {
return InputMethodDescriptor(current_input_method_id_,
descriptor.name(),
......
......@@ -12,10 +12,6 @@
namespace chromeos {
namespace input_method {
namespace {
const char kFallbackLayout[] = "us";
} // namespace
InputMethodDescriptor::InputMethodDescriptor(
const std::string& id,
const std::string& name,
......@@ -47,27 +43,5 @@ bool InputMethodDescriptor::operator!=(
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 chromeos
......@@ -31,9 +31,6 @@ class CHROMEOS_EXPORT InputMethodDescriptor {
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& name() const { return name_; }
const std::string& keyboard_layout() const { return keyboard_layout_; }
......@@ -41,11 +38,6 @@ class CHROMEOS_EXPORT InputMethodDescriptor {
const std::string& options_page_url() const { return options_page_url_; }
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:
// An ID that identifies an input method engine (e.g., "t:latn-post",
// "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