Commit 0c6b25ab authored by Bao-Duy Tran's avatar Bao-Duy Tran Committed by Commit Bot

InputMethodAllowList: Remove unused code then de-OO-ify stateless class.

Besides being general cleanup, this also reduces usage of kInputMethods,
global const autogen'd from deprecated input_methods.txt config file.

Bug: 1134526,1134465
Change-Id: If6b9cf19944bb622bb58d56580b229c0bed530d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2444673Reviewed-by: default avatarKeith Lee <keithlee@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarMy Nguyen <myy@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Commit-Queue: Bao-Duy Tran <tranbaoduy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814445}
parent bb2e7e34
......@@ -63,8 +63,7 @@ class TestListener : public content::NotificationObserver {
// background.
InputMethodManager* manager = InputMethodManager::Get();
manager->GetInputMethodUtil()->InitXkbInputMethodsForTesting(
*chromeos::input_method::InputMethodAllowlist()
.GetSupportedInputMethods());
*chromeos::input_method::allowlist::GetSupportedInputMethods());
std::vector<std::string> keyboard_layouts;
keyboard_layouts.push_back(
......
......@@ -128,7 +128,7 @@ class MyMockInputMethodManager : public MockInputMethodManagerImpl {
std::unique_ptr<InputMethodDescriptors> GetSupportedInputMethods()
const override {
return allowlist_.GetSupportedInputMethods();
return allowlist::GetSupportedInputMethods();
}
std::string last_input_method_id_;
......@@ -136,7 +136,6 @@ class MyMockInputMethodManager : public MockInputMethodManagerImpl {
private:
StringPrefMember* previous_;
StringPrefMember* current_;
InputMethodAllowlist allowlist_;
};
} // anonymous namespace
......
......@@ -17,24 +17,11 @@
namespace chromeos {
namespace input_method {
namespace allowlist {
const char kLanguageDelimiter[] = ",";
InputMethodAllowlist::InputMethodAllowlist() {
for (const auto& input_method : kInputMethods) {
supported_input_methods_.insert(input_method.input_method_id);
}
}
InputMethodAllowlist::~InputMethodAllowlist() = default;
bool InputMethodAllowlist::InputMethodIdIsAllowlisted(
const std::string& input_method_id) const {
return supported_input_methods_.count(input_method_id) > 0;
}
std::unique_ptr<InputMethodDescriptors>
InputMethodAllowlist::GetSupportedInputMethods() const {
std::unique_ptr<InputMethodDescriptors> GetSupportedInputMethods() {
std::unique_ptr<InputMethodDescriptors> input_methods(
new InputMethodDescriptors);
input_methods->reserve(base::size(kInputMethods));
......@@ -59,5 +46,6 @@ InputMethodAllowlist::GetSupportedInputMethods() const {
return input_methods;
}
} // namespace allowlist
} // namespace input_method
} // namespace chromeos
......@@ -5,9 +5,6 @@
#ifndef UI_BASE_IME_CHROMEOS_INPUT_METHOD_ALLOWLIST_H_
#define UI_BASE_IME_CHROMEOS_INPUT_METHOD_ALLOWLIST_H_
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/component_export.h"
......@@ -19,27 +16,16 @@ namespace input_method {
class InputMethodDescriptor;
typedef std::vector<InputMethodDescriptor> InputMethodDescriptors;
// A class which has allow listed input method list. The list is generated by
// gen_input_methods.py from input_methods.txt.
class COMPONENT_EXPORT(UI_BASE_IME_CHROMEOS) InputMethodAllowlist {
public:
InputMethodAllowlist();
~InputMethodAllowlist();
namespace allowlist {
// Returns true if |input_method_id| is allowlisted.
bool InputMethodIdIsAllowlisted(const std::string& input_method_id) const;
// Returns all input methods that are supported, including ones not active.
// This function never returns NULL. Note that input method extensions are not
// included in the result.
std::unique_ptr<InputMethodDescriptors> GetSupportedInputMethods() const;
private:
std::set<std::string> supported_input_methods_;
DISALLOW_COPY_AND_ASSIGN(InputMethodAllowlist);
};
// Returns all input methods that are supported, including ones not active.
// Based on the list generated by gen_input_methods.py from input_methods.txt.
// This function never returns nullptr. Note that input method extensions are
// not included in the result.
std::unique_ptr<InputMethodDescriptors> COMPONENT_EXPORT(UI_BASE_IME_CHROMEOS)
GetSupportedInputMethods();
} // namespace allowlist
} // namespace input_method
} // namespace chromeos
......
......@@ -48,7 +48,7 @@ class TestableInputMethodUtil : public InputMethodUtil {
class InputMethodUtilTest : public testing::Test {
public:
InputMethodUtilTest()
: util_(&delegate_, allowlist_.GetSupportedInputMethods()) {
: util_(&delegate_, allowlist::GetSupportedInputMethods()) {
delegate_.set_get_localized_string_callback(
base::BindRepeating(&l10n_util::GetStringUTF16));
delegate_.set_get_display_language_name_callback(
......@@ -85,7 +85,7 @@ class InputMethodUtilTest : public testing::Test {
GURL(""));
input_methods.push_back(zhuyin_ime);
util_.InitXkbInputMethodsForTesting(*allowlist_.GetSupportedInputMethods());
util_.InitXkbInputMethodsForTesting(*allowlist::GetSupportedInputMethods());
util_.AppendInputMethods(input_methods);
}
......@@ -117,7 +117,6 @@ class InputMethodUtilTest : public testing::Test {
}
FakeInputMethodDelegate delegate_;
InputMethodAllowlist allowlist_;
TestableInputMethodUtil util_;
};
......
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