# ----------------------------------------------------------------------------- # Taken from https://chromium.googlesource.com/chromium/src/+/f269d3b548203e217e8c0080c2e22e7ae3efb51e%5E%21 # ----------------------------------------------------------------------------- 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 diff -uarN chromium-43.0.2357.125.orig/build/common.gypi chromium-43.0.2357.125/build/common.gypi --- chromium-43.0.2357.125.orig/build/common.gypi 2015-06-11 23:05:27.000000000 +0200 +++ chromium-43.0.2357.125/build/common.gypi 2015-06-19 15:55:37.939788479 +0200 @@ -372,6 +372,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, @@ -1150,6 +1153,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 -uarN chromium-43.0.2357.125.orig/chrome/browser/BUILD.gn chromium-43.0.2357.125/chrome/browser/BUILD.gn --- chromium-43.0.2357.125.orig/chrome/browser/BUILD.gn 2015-06-11 23:05:27.000000000 +0200 +++ chromium-43.0.2357.125/chrome/browser/BUILD.gn 2015-06-19 15:55:37.940788645 +0200 @@ -17,6 +17,11 @@ 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" @@ -439,6 +444,10 @@ } } + if (enable_hotwording) { + defines += [ "ENABLE_HOTWORDING" ] + } + if (is_linux) { deps += [ "//device/media_transfer_protocol", diff -uarN chromium-43.0.2357.125.orig/chrome/browser/search/hotword_service.cc chromium-43.0.2357.125/chrome/browser/search/hotword_service.cc --- chromium-43.0.2357.125.orig/chrome/browser/search/hotword_service.cc 2015-06-11 23:05:28.000000000 +0200 +++ chromium-43.0.2357.125/chrome/browser/search/hotword_service.cc 2015-06-19 15:58:08.413736872 +0200 @@ -639,7 +639,11 @@ if (group == hotword_internal::kHotwordFieldTrialDisabledGroupName) return false; +#if defined(ENABLE_HOTWORDING) return DoesHotwordSupportLanguage(profile_); +#else + return false; +#endif } bool HotwordService::IsOptedIntoAudioLogging() { diff -uarN chromium-43.0.2357.125.orig/chrome/browser/search/hotword_service_unittest.cc chromium-43.0.2357.125/chrome/browser/search/hotword_service_unittest.cc --- chromium-43.0.2357.125.orig/chrome/browser/search/hotword_service_unittest.cc 2015-06-11 22:44:26.000000000 +0200 +++ chromium-43.0.2357.125/chrome/browser/search/hotword_service_unittest.cc 2015-06-19 15:55:37.941788810 +0200 @@ -216,6 +216,7 @@ } TEST_P(HotwordServiceTest, IsHotwordAllowedLocale) { +#if defined(ENABLE_HOTWORDING) TestingProfile::Builder profile_builder; scoped_ptr profile = profile_builder.Build(); @@ -246,6 +247,7 @@ 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 +304,7 @@ } TEST_P(HotwordServiceTest, UninstallReinstallTriggeredCorrectly) { +#if defined(ENABLE_HOTWORDING) InitializeEmptyExtensionService(); service_->Init(); @@ -372,6 +375,7 @@ 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 -uarN chromium-43.0.2357.125.orig/chrome/chrome_browser.gypi chromium-43.0.2357.125/chrome/chrome_browser.gypi --- chromium-43.0.2357.125.orig/chrome/chrome_browser.gypi 2015-06-11 23:05:28.000000000 +0200 +++ chromium-43.0.2357.125/chrome/chrome_browser.gypi 2015-06-19 15:55:37.963792459 +0200 @@ -3450,6 +3450,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)' ], }],