Commit 10329e74 authored by evliu's avatar evliu Committed by Commit Bot

Disable the Live Caption feature if the feature flag is disabled.

This CL disables the Live Caption feature if the kLiveCaption feature
flag is disabled. Previously, the Live Caption feature would only be
enabled if the kLiveCaptionEnabled user pref is enabled, which can
only be enabled if the kLiveCaption feature is enabled. The feature
should be completely off if the kLiveCaption feature is disabled,
even if the feature and pref were previously enabled.

Bug: 1121296
Change-Id: I6f642f025d69b411223cc137e999d7980d5d4917
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2372734Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Evan Liu <evliu@google.com>
Cr-Commit-Position: refs/heads/master@{#801424}
parent bcaa2b03
......@@ -126,6 +126,7 @@
#include "chrome/browser/ui/webui/tab_search/tab_search_ui.h"
#include "chrome/common/caption.mojom.h"
#include "chrome/common/webui_url_constants.h"
#include "media/base/media_switches.h"
#include "media/mojo/mojom/speech_recognition_service.mojom.h"
#endif
......@@ -372,7 +373,8 @@ void BindSpeechRecognitionContextHandler(
Profile* profile = Profile::FromBrowserContext(
frame_host->GetProcess()->GetBrowserContext());
PrefService* profile_prefs = profile->GetPrefs();
if (profile_prefs->GetBoolean(prefs::kLiveCaptionEnabled)) {
if (profile_prefs->GetBoolean(prefs::kLiveCaptionEnabled) &&
base::FeatureList::IsEnabled(media::kLiveCaption)) {
SpeechRecognitionServiceFactory::GetForProfile(profile)->Create(
std::move(receiver));
}
......@@ -384,7 +386,8 @@ void BindCaptionContextHandler(
Profile* profile = Profile::FromBrowserContext(
frame_host->GetProcess()->GetBrowserContext());
PrefService* profile_prefs = profile->GetPrefs();
if (profile_prefs->GetBoolean(prefs::kLiveCaptionEnabled)) {
if (profile_prefs->GetBoolean(prefs::kLiveCaptionEnabled) &&
base::FeatureList::IsEnabled(media::kLiveCaption)) {
captions::CaptionHostImpl::Create(frame_host, std::move(receiver));
}
}
......
......@@ -19,6 +19,7 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "crypto/sha2.h"
#include "media/base/media_switches.h"
using content::BrowserThread;
......@@ -133,17 +134,18 @@ void RegisterSODAComponent(ComponentUpdateService* cus,
PrefService* prefs,
base::OnceClosure callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!base::FeatureList::IsEnabled(media::kLiveCaption))
return;
#if BUILDFLAG(ENABLE_SODA)
auto installer = base::MakeRefCounted<ComponentInstaller>(
std::make_unique<SODAComponentInstallerPolicy>(base::BindRepeating(
[](ComponentUpdateService* cus, PrefService* prefs,
const base::FilePath& install_dir) {
if (prefs->GetBoolean(prefs::kLiveCaptionEnabled)) {
content::GetUIThreadTaskRunner({base::TaskPriority::BEST_EFFORT})
->PostTask(FROM_HERE,
base::BindOnce(&UpdateSODAInstallDirPref, prefs,
install_dir));
}
},
cus, prefs)));
......
......@@ -17,6 +17,7 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "crypto/sha2.h"
#include "media/base/media_switches.h"
using content::BrowserThread;
......@@ -137,19 +138,19 @@ void RegisterSodaEnUsComponent(ComponentUpdateService* cus,
base::OnceClosure callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
#if BUILDFLAG(ENABLE_SODA)
if (!prefs->GetBoolean(prefs::kLiveCaptionEnabled))
if (!prefs->GetBoolean(prefs::kLiveCaptionEnabled) ||
!base::FeatureList::IsEnabled(media::kLiveCaption)) {
return;
}
auto installer = base::MakeRefCounted<ComponentInstaller>(
std::make_unique<SodaEnUsComponentInstallerPolicy>(base::BindRepeating(
[](ComponentUpdateService* cus, PrefService* prefs,
const base::FilePath& install_dir) {
if (prefs->GetBoolean(prefs::kLiveCaptionEnabled)) {
content::GetUIThreadTaskRunner({base::TaskPriority::BEST_EFFORT})
->PostTask(FROM_HERE,
base::BindOnce(&UpdateSodaEnUsInstallDirPref,
prefs, install_dir));
}
},
cus, prefs)));
......
......@@ -17,6 +17,7 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "crypto/sha2.h"
#include "media/base/media_switches.h"
using content::BrowserThread;
......@@ -137,19 +138,19 @@ void RegisterSodaJaJpComponent(ComponentUpdateService* cus,
base::OnceClosure callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
#if BUILDFLAG(ENABLE_SODA)
if (!prefs->GetBoolean(prefs::kLiveCaptionEnabled))
if (!prefs->GetBoolean(prefs::kLiveCaptionEnabled) ||
!base::FeatureList::IsEnabled(media::kLiveCaption)) {
return;
}
auto installer = base::MakeRefCounted<ComponentInstaller>(
std::make_unique<SodaJaJpComponentInstallerPolicy>(base::BindRepeating(
[](ComponentUpdateService* cus, PrefService* prefs,
const base::FilePath& install_dir) {
if (prefs->GetBoolean(prefs::kLiveCaptionEnabled)) {
content::GetUIThreadTaskRunner({base::TaskPriority::BEST_EFFORT})
->PostTask(FROM_HERE,
base::BindOnce(&UpdateSodaJaJpInstallDirPref,
prefs, install_dir));
}
},
cus, prefs)));
......
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