Skip to content

Commit

Permalink
Fix IsCros1pKorean() to properly distinguish Chrome OS vs Chromium OS.
Browse files Browse the repository at this point in the history
This is meant for b/302255943, so intended to only return "true"
when it's 1P Korean input method on (Google-flavoured) Chrome OS
(i.e. not 3P, not even 1P but open-source Chromium OS). It was
an oversight to miss out the Chrome OS preprocessor guards. This
will soon be used for b/298907146 with the exact same intention.

CQ_INCLUDE_TRYBOTS=luci.chrome.try:chromeos-betty-pi-arc-chrome

Bug: b/302255943, b/298907146
Change-Id: I41f98b9332cadf6e3015f8cfbcc08da4a3facbb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5075905
Reviewed-by: Darren Shen <shend@chromium.org>
Commit-Queue: Bao-Duy Tran <tranbaoduy@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1232558}
  • Loading branch information
Bao-Duy Tran authored and Chromium LUCI CQ committed Dec 4, 2023
1 parent bafd484 commit 3b27ff9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ui/base/ime/ash/extension_ime_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,17 @@ bool IsExperimentalMultilingual(const std::string& input_method_id) {
}

bool IsCros1pKorean(const std::string& input_method_id) {
// TODO(crbug.com/1162211): Input method IDs are tuples of extension type,
// extension ID, and extension-local input method ID. However, currently
// they're just concats of the three constituent pieces of info, hence StrCat
// here. Replace StrCat once they're no longer unstructured string concats.

#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
return input_method_id == base::StrCat({kComponentExtensionIMEPrefix,
kXkbExtensionId, "ko-t-i0-und"});
#else
return false;
#endif
}

} // namespace extension_ime_util
Expand Down
26 changes: 26 additions & 0 deletions ui/base/ime/ash/extension_ime_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,30 @@ TEST(ExtensionIMEUtilTest, IsExperimentalMultilingualTest) {
"experimental_hello_world"})));
}

TEST(ExtensionIMEUtilTest, IsCros1pKoreanTest) {
// TODO(crbug.com/1162211): Input method IDs are tuples of extension type,
// extension ID, and extension-local input method ID. However, currently
// they're just concats of the three constituent pieces of info, hence StrCat
// here. Replace StrCat once they're no longer unstructured string concats.

EXPECT_FALSE(extension_ime_util::IsCros1pKorean(
base::StrCat({"some_extension_type", "some_extension_id",
"some_local_input_method_id"})));

EXPECT_FALSE(extension_ime_util::IsCros1pKorean(base::StrCat(
{"_comp_ime_", "some_extension_id", "some_local_input_method_id"})));

EXPECT_FALSE(extension_ime_util::IsCros1pKorean(
base::StrCat({"_comp_ime_", "jkghodnilhceideoidjikpgommlajknk",
"some_local_input_method_id"})));

#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
EXPECT_TRUE(
#else
EXPECT_FALSE(
#endif
extension_ime_util::IsCros1pKorean(base::StrCat(
{"_comp_ime_", "jkghodnilhceideoidjikpgommlajknk", "ko-t-i0-und"})));
}

} // namespace ash

0 comments on commit 3b27ff9

Please sign in to comment.