Commit 6f678f49 authored by Leo Zhang's avatar Leo Zhang Committed by Commit Bot

Replace build flag with feature flag.

Prepare for dogfooding in the canary/dev channels.

Bug: 888885
Change-Id: I757fd28d4d11d10f521a038fcdd2179a18311ea4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763647Reviewed-by: default avatarShu Chen <shuchen@chromium.org>
Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarLeo Zhang <googleo@chromium.org>
Commit-Queue: Leo Zhang <googleo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690279}
parent e6f2aafd
......@@ -9,8 +9,8 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/services/ime/constants.h"
#include "chromeos/services/ime/public/cpp/buildflags.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "content/public/browser/service_process_host.h"
#include "net/base/load_flags.h"
......@@ -25,12 +25,6 @@ namespace input_method {
namespace {
#if BUILDFLAG(ENABLE_CROS_IME_DECODER)
constexpr auto kImeServiceSandboxType = service_manager::SANDBOX_TYPE_IME;
#else
constexpr auto kImeServiceSandboxType = service_manager::SANDBOX_TYPE_UTILITY;
#endif
constexpr net::NetworkTrafficAnnotationTag traffic_annotation =
net::DefineNetworkTrafficAnnotation("ime_url_downloader", R"(
semantics {
......@@ -114,6 +108,10 @@ void ImeServiceConnector::DownloadImeFileTo(
void ImeServiceConnector::SetupImeService(
mojo::PendingReceiver<chromeos::ime::mojom::InputEngineManager> receiver) {
if (!remote_service_) {
auto kImeServiceSandboxType =
chromeos::features::IsImeDecoderWithSandboxEnabled()
? service_manager::SANDBOX_TYPE_IME
: service_manager::SANDBOX_TYPE_UTILITY;
content::ServiceProcessHost::Launch(
remote_service_.BindNewPipeAndPassReceiver(),
content::ServiceProcessHost::Options()
......
......@@ -144,6 +144,10 @@ const base::Feature kImeInputLogicFst{"ImeInputLogicFst",
const base::Feature kImeInputLogicFstNonEnglish{
"ImeInputLogicFstNonEnglish", base::FEATURE_DISABLED_BY_DEFAULT};
// Enable or disable IME service decoder engine and 'ime' sandbox on Chrome OS.
const base::Feature kImeDecoderWithSandbox{"ImeDecoderWithSandbox",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enables or disables Instant Tethering on Chrome OS.
const base::Feature kInstantTethering{"InstantTethering",
base::FEATURE_DISABLED_BY_DEFAULT};
......@@ -219,6 +223,10 @@ bool IsAssistantEnabled() {
return base::FeatureList::IsEnabled(kAssistantFeature);
}
bool IsImeDecoderWithSandboxEnabled() {
return base::FeatureList::IsEnabled(kImeDecoderWithSandbox);
}
bool IsInstantTetheringBackgroundAdvertisingSupported() {
return base::FeatureList::IsEnabled(
kInstantTetheringBackgroundAdvertisementSupport);
......
......@@ -69,6 +69,8 @@ extern const base::Feature kImeInputLogicFst;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kImeInputLogicFstNonEnglish;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kImeDecoderWithSandbox;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kInstantTethering;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kParentalControlsSettings;
......@@ -100,6 +102,7 @@ extern const base::Feature kVideoPlayerNativeControls;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsAccountManagerEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsAmbientModeEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsAssistantEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsImeDecoderWithSandboxEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
bool IsInstantTetheringBackgroundAdvertisingSupported();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsParentalControlsSettingsEnabled();
......
......@@ -2,8 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//chromeos/services/ime/public/features.gni")
assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos")
component("constants") {
......@@ -21,6 +19,10 @@ component("constants") {
source_set("lib") {
sources = [
"decoder/decoder_engine.cc",
"decoder/decoder_engine.h",
"decoder/downloader_impl.cc",
"decoder/downloader_impl.h",
"ime_service.cc",
"ime_service.h",
"input_engine.cc",
......@@ -30,20 +32,12 @@ source_set("lib") {
deps = [
":constants",
"//base",
"//chromeos/constants",
"//chromeos/services/ime/public/cpp:buildflags",
"//chromeos/services/ime/public/cpp:rulebased",
"//chromeos/services/ime/public/cpp/shared_lib:interfaces",
"//chromeos/services/ime/public/mojom",
]
if (enable_cros_ime_decoder) {
sources += [
"decoder/decoder_engine.cc",
"decoder/decoder_engine.h",
"decoder/downloader_impl.cc",
"decoder/downloader_impl.h",
]
}
}
source_set("sandbox_hook") {
......
......@@ -14,12 +14,10 @@
#include "base/location.h"
#include "base/sequenced_task_runner.h"
#include "build/buildflag.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/services/ime/constants.h"
#include "chromeos/services/ime/public/cpp/buildflags.h"
#if BUILDFLAG(ENABLE_CROS_IME_DECODER)
#include "chromeos/services/ime/decoder/decoder_engine.h"
#endif
#include "chromeos/services/ime/public/cpp/buildflags.h"
namespace chromeos {
namespace ime {
......@@ -36,11 +34,9 @@ enum SimpleDownloadError {
ImeService::ImeService(mojo::PendingReceiver<mojom::ImeService> receiver)
: receiver_(this, std::move(receiver)) {
#if BUILDFLAG(ENABLE_CROS_IME_DECODER)
input_engine_ = std::make_unique<DecoderEngine>(this);
#else
input_engine_ = std::make_unique<InputEngine>();
#endif
input_engine_ = chromeos::features::IsImeDecoderWithSandboxEnabled()
? std::make_unique<DecoderEngine>(this)
: std::make_unique<InputEngine>();
}
ImeService::~ImeService() = default;
......
......@@ -9,7 +9,6 @@ buildflag_header("buildflags") {
header = "buildflags.h"
flags = [
"ENABLE_CROS_IME_DECODER=$enable_cros_ime_decoder",
"ENABLE_CROS_IME_SHARED_DATA=$enable_cros_ime_shared_data",
"ENABLE_CROS_IME_SANITY_TEST_SO=$enable_cros_ime_sanity_test_so",
]
......
......@@ -3,9 +3,6 @@
# found in the LICENSE file.
declare_args() {
# Enable a full featured IME implementation with decoders.
enable_cros_ime_decoder = false
# Enable share language modules between IME services.
enable_cros_ime_shared_data = false
......
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