Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Add build flag to disable hotwording.
Browse files Browse the repository at this point in the history
Hotwording downloads a shared module from the web store containing a NaCl module. There is a desire to build and distribute Chromium without this happening. This change adds an "enable_hotwording" build flag that is enabled by default, but can be disabled at compile time.

BUG=491435

Review URL: https://codereview.chromium.org/1160243004

Cr-Commit-Position: refs/heads/master@{#333548}
(cherry picked from commit f269d3b)

Resolved merge conflict: Remove the body of
IsHotwordAllowedDisabledFieldTrial and IsHotwordAllowedInvalidFieldTrial
when ENABLE_HOTWORDING is false. These tests were deleted before the
upstream patch landed.

(Merge approval on http://crbug.com/500922#c69)
[email protected],[email protected]

Review URL: https://codereview.chromium.org/1218693004.

Cr-Commit-Position: refs/branch-heads/2403@{#412}
Cr-Branched-From: f54b809-refs/heads/master@{#330231}
  • Loading branch information
mgiuca committed Jun 29, 2015
1 parent b2a75e3 commit ac2b37f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@
# Web speech is enabled by default. Set to 0 to disable.
'enable_web_speech%': 1,

# 'Ok Google' hotwording is enabled by default. Set to 0 to disable.
'enable_hotwording%': 1,

# Notifications are compiled in by default. Set to 0 to disable.
'notifications%' : 1,

Expand Down Expand Up @@ -1134,6 +1137,7 @@
'configuration_policy%': '<(configuration_policy)',
'safe_browsing%': '<(safe_browsing)',
'enable_web_speech%': '<(enable_web_speech)',
'enable_hotwording%': '<(enable_hotwording)',
'notifications%': '<(notifications)',
'clang_use_chrome_plugins%': '<(clang_use_chrome_plugins)',
'mac_want_real_dsym%': '<(mac_want_real_dsym)',
Expand Down
9 changes: 9 additions & 0 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ if (is_desktop_linux) {
import("//build/config/linux/pkg_config.gni")
}

declare_args() {
# 'Ok Google' hotwording is enabled.
enable_hotwording = true
}

about_credits_file = "$target_gen_dir/about_credits.html"
additional_modules_list_file =
"$root_gen_dir/chrome/browser/internal/additional_modules_list.txt"
Expand Down Expand Up @@ -455,6 +460,10 @@ source_set("browser") {
}
}

if (enable_hotwording) {
defines += [ "ENABLE_HOTWORDING" ]
}

if (is_linux) {
deps += [
"//device/media_transfer_protocol",
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/search/hotword_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ bool HotwordService::IsServiceAvailable() {
}

bool HotwordService::IsHotwordAllowed() {
#if defined(ENABLE_HOTWORDING)
std::string group = base::FieldTrialList::FindFullName(
hotword_internal::kHotwordFieldTrialName);
// Allow hotwording by default, and only disable if the field trial has been
Expand All @@ -650,6 +651,9 @@ bool HotwordService::IsHotwordAllowed() {
return false;

return DoesHotwordSupportLanguage(profile_);
#else
return false;
#endif
}

bool HotwordService::IsOptedIntoAudioLogging() {
Expand Down
8 changes: 8 additions & 0 deletions chrome/browser/search/hotword_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ INSTANTIATE_TEST_CASE_P(HotwordServiceTests,
extension_misc::kHotwordSharedModuleId));

TEST_P(HotwordServiceTest, IsHotwordAllowedDisabledFieldTrial) {
#if defined(ENABLE_HOTWORDING)
TestingProfile::Builder profile_builder;
scoped_ptr<TestingProfile> profile = profile_builder.Build();

Expand Down Expand Up @@ -190,9 +191,11 @@ TEST_P(HotwordServiceTest, IsHotwordAllowedDisabledFieldTrial) {
// Test that incognito returns false as well.
EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(
profile->GetOffTheRecordProfile()));
#endif
}

TEST_P(HotwordServiceTest, IsHotwordAllowedInvalidFieldTrial) {
#if defined(ENABLE_HOTWORDING)
TestingProfile::Builder profile_builder;
scoped_ptr<TestingProfile> profile = profile_builder.Build();

Expand All @@ -213,9 +216,11 @@ TEST_P(HotwordServiceTest, IsHotwordAllowedInvalidFieldTrial) {
// Test that incognito returns false as well.
EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(
profile->GetOffTheRecordProfile()));
#endif
}

TEST_P(HotwordServiceTest, IsHotwordAllowedLocale) {
#if defined(ENABLE_HOTWORDING)
TestingProfile::Builder profile_builder;
scoped_ptr<TestingProfile> profile = profile_builder.Build();

Expand Down Expand Up @@ -246,6 +251,7 @@ TEST_P(HotwordServiceTest, IsHotwordAllowedLocale) {
Profile* otr_profile = profile->GetOffTheRecordProfile();
SetApplicationLocale(otr_profile, "en");
EXPECT_FALSE(HotwordServiceFactory::IsHotwordAllowed(otr_profile));
#endif // defined(ENABLE_HOTWORDING)
}

TEST_P(HotwordServiceTest, ShouldReinstallExtension) {
Expand Down Expand Up @@ -302,6 +308,7 @@ TEST_P(HotwordServiceTest, PreviousLanguageSetOnInstall) {
}

TEST_P(HotwordServiceTest, UninstallReinstallTriggeredCorrectly) {
#if defined(ENABLE_HOTWORDING)
InitializeEmptyExtensionService();
service_->Init();

Expand Down Expand Up @@ -372,6 +379,7 @@ TEST_P(HotwordServiceTest, UninstallReinstallTriggeredCorrectly) {
EXPECT_TRUE(HotwordServiceFactory::IsHotwordAllowed(profile()));
EXPECT_FALSE(hotword_service->MaybeReinstallHotwordExtension());
EXPECT_EQ(1, hotword_service->uninstall_count()); // no change
#endif // defined(ENABLE_HOTWORDING)
}

TEST_P(HotwordServiceTest, DisableAlwaysOnOnLanguageChange) {
Expand Down
3 changes: 3 additions & 0 deletions chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -3529,6 +3529,9 @@
['enable_session_service==1', {
'sources': [ '<@(chrome_browser_session_service_sources)' ],
}],
['enable_hotwording==1', {
'defines': [ 'ENABLE_HOTWORDING' ],
}],
['OS!="android" and OS!="ios" and chromeos==0', {
'sources': [ '<@(chrome_browser_desktop_sources)' ],
}],
Expand Down

0 comments on commit ac2b37f

Please sign in to comment.