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

Unified Diff: chrome/browser/extensions/api/hotword_private/hotword_private_api.cc

Issue 267653005: Adds HotwordPrivate API for integrating the hotword feature to AppLauncher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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/extensions/api/hotword_private/hotword_private_api.cc
diff --git a/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc b/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc
index 4dc9218627e22a7cd9b70cc42ba02937fe12e016..42bbe1808d3ca56f0c11b54b67d1d261996876dd 100644
--- a/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc
+++ b/chrome/browser/extensions/api/hotword_private/hotword_private_api.cc
@@ -7,6 +7,7 @@
#include "base/lazy_instance.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search/hotword_client.h"
#include "chrome/browser/search/hotword_service.h"
#include "chrome/browser/search/hotword_service_factory.h"
#include "chrome/common/pref_names.h"
@@ -51,17 +52,23 @@ const char* HotwordPrivateEventService::service_name() {
void HotwordPrivateEventService::OnEnabledChanged(
const std::string& pref_name) {
DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled));
- SignalEvent();
+ SignalEvent(OnEnabledChanged::kEventName);
}
-void HotwordPrivateEventService::SignalEvent() {
- using OnEnabledChanged::kEventName;
+void HotwordPrivateEventService::OnHotwordSessionRequested() {
+ SignalEvent(api::hotword_private::OnHotwordSessionRequested::kEventName);
+}
+
+void HotwordPrivateEventService::OnHotwordSessionStopped() {
+ SignalEvent(api::hotword_private::OnHotwordSessionStopped::kEventName);
+}
+void HotwordPrivateEventService::SignalEvent(const std::string& event_name) {
EventRouter* router = EventRouter::Get(profile_);
- if (!router || !router->HasEventListener(kEventName))
+ if (!router || !router->HasEventListener(event_name))
return;
scoped_ptr<base::ListValue> args(new base::ListValue());
- scoped_ptr<Event> event(new Event(kEventName, args.Pass()));
+ scoped_ptr<Event> event(new Event(event_name, args.Pass()));
router->BroadcastEvent(event.Pass());
}
@@ -106,4 +113,24 @@ bool HotwordPrivateGetStatusFunction::RunSync() {
return true;
}
+bool HotwordPrivateSetHotwordSessionStateFunction::RunSync() {
+ scoped_ptr<api::hotword_private::SetHotwordSessionState::Params> params(
+ api::hotword_private::SetHotwordSessionState::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ HotwordService* hotword_service =
+ HotwordServiceFactory::GetForProfile(GetProfile());
+ if (hotword_service && hotword_service->client())
+ hotword_service->client()->OnHotwordStateChanged(params->started);
+ return true;
+}
+
+bool HotwordPrivateNotifyHotwordRecognitionFunction::RunSync() {
+ HotwordService* hotword_service =
+ HotwordServiceFactory::GetForProfile(GetProfile());
+ if (hotword_service && hotword_service->client())
+ hotword_service->client()->OnHotwordRecognized();
+ return true;
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698