Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(983)

Unified Diff: chrome/browser/search/hotword_service.cc

Issue 467113004: Adds a skeleton component app for Always-On Hotwording opt-in flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Copyright Year Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search/hotword_service.cc
diff --git a/chrome/browser/search/hotword_service.cc b/chrome/browser/search/hotword_service.cc
index e29a08ff4fa424dd9e944fc2a24f96fd567e1172..4ed522bd2ccdef15f4b3cfb65fe16ae393c48afb 100644
--- a/chrome/browser/search/hotword_service.cc
+++ b/chrome/browser/search/hotword_service.cc
@@ -19,6 +19,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/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
@@ -205,6 +206,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());
@@ -435,6 +441,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));

Powered by Google App Engine
This is Rietveld 408576698