Index: chrome/browser/search/hotword_service.cc |
diff --git a/chrome/browser/search/hotword_service.cc b/chrome/browser/search/hotword_service.cc |
index 738eced6cc9566699d2c82bcb33de32ce21a8801..f12ef059c4b7384b4f1a159e0a961b94ac319364 100644 |
--- a/chrome/browser/search/hotword_service.cc |
+++ b/chrome/browser/search/hotword_service.cc |
@@ -20,6 +20,7 @@ |
#include "chrome/browser/plugins/plugin_prefs.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/search/hotword_service_factory.h" |
+#include "chrome/browser/ui/extensions/application_launch.h" |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/extensions/extension_constants.h" |
@@ -214,6 +215,11 @@ HotwordService::HotwordService(Profile* profile) |
base::Bind(&HotwordService::OnHotwordSearchEnabledChanged, |
base::Unretained(this))); |
+ pref_registrar_.Add( |
+ prefs::kHotwordAlwaysOnSearchEnabled, |
+ base::Bind(&HotwordService::OnHotwordAlwaysOnSearchEnabledChanged, |
+ base::Unretained(this))); |
+ |
registrar_.Add(this, |
chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
content::NotificationService::AllSources()); |
@@ -444,6 +450,25 @@ void HotwordService::DisableHotwordExtension( |
} |
} |
+void HotwordService::OnHotwordAlwaysOnSearchEnabledChanged( |
+ const std::string& pref_name) { |
+ DCHECK_EQ(pref_name, std::string(prefs::kHotwordAlwaysOnSearchEnabled)); |
+ |
+ ExtensionService* extension_service = GetExtensionService(profile_); |
+ if (!extension_service) |
+ return; |
+ |
+ const extensions::Extension* extension = extension_service->GetExtensionById( |
+ extension_misc::kHotwordAudioVerificationAppId, true); |
+ if (!extension) |
+ return; |
+ |
+ if (profile_->GetPrefs()->GetBoolean(prefs::kHotwordAlwaysOnSearchEnabled)) { |
+ OpenApplication(AppLaunchParams( |
+ profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); |
+ } |
+} |
+ |
void HotwordService::OnHotwordSearchEnabledChanged( |
const std::string& pref_name) { |
DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); |