diff options
author | Matt Giuca <mgiuca@chromium.org> | 2015-06-29 11:55:47 +1000 |
---|---|---|
committer | Matt Giuca <mgiuca@chromium.org> | 2015-06-29 01:57:05 +0000 |
commit | ac2b37ff8ca0f3015c0163bc91b456e33b7287f3 (patch) | |
tree | 0cd222ec5aeaaf1c96b0df9bed33c1bbfc79d917 | |
parent | b2a75e324a969284d8e1794dd4f70f165de8f0cc (diff) | |
download | chromium_src-ac2b37ff8ca0f3015c0163bc91b456e33b7287f3.zip chromium_src-ac2b37ff8ca0f3015c0163bc91b456e33b7287f3.tar.gz chromium_src-ac2b37ff8ca0f3015c0163bc91b456e33b7287f3.tar.bz2 |
Add build flag to disable hotwording.
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 f269d3b548203e217e8c0080c2e22e7ae3efb51e)
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)
TBR=thestig@chromium.org,scottmg@chromium.org
Review URL: https://codereview.chromium.org/1218693004.
Cr-Commit-Position: refs/branch-heads/2403@{#412}
Cr-Branched-From: f54b8097a9c45ed4ad308133d49f05325d6c5070-refs/heads/master@{#330231}
-rw-r--r-- | build/common.gypi | 4 | ||||
-rw-r--r-- | chrome/browser/BUILD.gn | 9 | ||||
-rw-r--r-- | chrome/browser/search/hotword_service.cc | 4 | ||||
-rw-r--r-- | chrome/browser/search/hotword_service_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 3 |
5 files changed, 28 insertions, 0 deletions
diff --git a/build/common.gypi b/build/common.gypi index 339cc75..ddb075c 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -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, @@ -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)', diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 5152d83..6ccb079 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -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" @@ -455,6 +460,10 @@ source_set("browser") { } } + if (enable_hotwording) { + defines += [ "ENABLE_HOTWORDING" ] + } + if (is_linux) { deps += [ "//device/media_transfer_protocol", diff --git a/chrome/browser/search/hotword_service.cc b/chrome/browser/search/hotword_service.cc index 0cf3c60..e93789b 100644 --- a/chrome/browser/search/hotword_service.cc +++ b/chrome/browser/search/hotword_service.cc @@ -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 @@ -650,6 +651,9 @@ bool HotwordService::IsHotwordAllowed() { return false; return DoesHotwordSupportLanguage(profile_); +#else + return false; +#endif } bool HotwordService::IsOptedIntoAudioLogging() { diff --git a/chrome/browser/search/hotword_service_unittest.cc b/chrome/browser/search/hotword_service_unittest.cc index a3aef47..e78e2e7 100644 --- a/chrome/browser/search/hotword_service_unittest.cc +++ b/chrome/browser/search/hotword_service_unittest.cc @@ -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(); @@ -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(); @@ -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(); @@ -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) { @@ -302,6 +308,7 @@ TEST_P(HotwordServiceTest, PreviousLanguageSetOnInstall) { } TEST_P(HotwordServiceTest, UninstallReinstallTriggeredCorrectly) { +#if defined(ENABLE_HOTWORDING) InitializeEmptyExtensionService(); service_->Init(); @@ -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) { diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 6d323eb..1aaedba 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -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)' ], }], |