summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-26 21:23:26 +0000
committernona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-26 21:23:26 +0000
commit6eb5bd873295e8c8de13924e1332b7be23b38d47 (patch)
tree117de5500977c9f8a330eeac5cbe0564f33d4666
parent62e6cd5981f8a3e5ebba91a78bf4d83e9bd96bf6 (diff)
downloadchromium_src-6eb5bd873295e8c8de13924e1332b7be23b38d47.zip
chromium_src-6eb5bd873295e8c8de13924e1332b7be23b38d47.tar.gz
chromium_src-6eb5bd873295e8c8de13924e1332b7be23b38d47.tar.bz2
Introduce IsMemberOfExtension function into ExtensionIMEUtil.
This function returns if the |input_method_id| is a member of |extension_id|. BUG=164377 TEST=ran chromeos_unittests Review URL: https://chromiumcodereview.appspot.com/12583012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190769 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chromeos/ime/extension_ime_util.cc7
-rw-r--r--chromeos/ime/extension_ime_util.h5
-rw-r--r--chromeos/ime/extension_ime_util_unittest.cc21
3 files changed, 33 insertions, 0 deletions
diff --git a/chromeos/ime/extension_ime_util.cc b/chromeos/ime/extension_ime_util.cc
index 7e6d3ac..3c95751 100644
--- a/chromeos/ime/extension_ime_util.cc
+++ b/chromeos/ime/extension_ime_util.cc
@@ -25,5 +25,12 @@ bool IsExtensionIME(const std::string& input_method_id) {
true); // Case sensitive.
}
+bool IsMemberOfExtension(const std::string& input_method_id,
+ const std::string& extension_id) {
+ return StartsWithASCII(input_method_id,
+ kExtensionIMEPrefix + extension_id,
+ true); // Case sensitive.
+}
+
} // namespace extension_ime_util
} // namespace chromeos
diff --git a/chromeos/ime/extension_ime_util.h b/chromeos/ime/extension_ime_util.h
index fd8505c..f439ec4 100644
--- a/chromeos/ime/extension_ime_util.h
+++ b/chromeos/ime/extension_ime_util.h
@@ -21,6 +21,11 @@ std::string CHROMEOS_EXPORT GetInputMethodID(const std::string& extension_id,
// Returns true if the |input_method_id| is extension ime.
bool CHROMEOS_EXPORT IsExtensionIME(const std::string& input_method_id);
+// Returns true if the |input_method| is member of |extension_id|, otherwise
+// return false.
+bool CHROMEOS_EXPORT IsMemberOfExtension(const std::string& input_method_id,
+ const std::string& extension_id);
+
} // extension_ime_util
} // namespace chromeos
diff --git a/chromeos/ime/extension_ime_util_unittest.cc b/chromeos/ime/extension_ime_util_unittest.cc
index a25c1a1..468a725 100644
--- a/chromeos/ime/extension_ime_util_unittest.cc
+++ b/chromeos/ime/extension_ime_util_unittest.cc
@@ -22,4 +22,25 @@ TEST(ExtensionIMEUtilTest, IsExtensionIMETest) {
EXPECT_FALSE(extension_ime_util::IsExtensionIME("mozc"));
}
+TEST(ExtensionIMEUtilTest, IsMemberOfExtension) {
+ const char* extention1 = "abcdefg";
+ const char* extention2 = "hijklmn";
+ const char* engine_id1 = "12345";
+ const char* engine_id2 = "67890";
+
+ const std::string extention_1_engine_1 =
+ extension_ime_util::GetInputMethodID(extention1, engine_id1);
+ const std::string extention_1_engine_2 =
+ extension_ime_util::GetInputMethodID(extention1, engine_id2);
+
+ EXPECT_TRUE(extension_ime_util::IsMemberOfExtension(extention_1_engine_1,
+ extention1));
+ EXPECT_TRUE(extension_ime_util::IsMemberOfExtension(extention_1_engine_2,
+ extention1));
+ EXPECT_FALSE(extension_ime_util::IsMemberOfExtension(extention_1_engine_1,
+ extention2));
+ EXPECT_FALSE(extension_ime_util::IsMemberOfExtension(extention_1_engine_2,
+ extention2));
+}
+
} // namespace chromeos