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

Unified Diff: chrome/browser/search/hotword_service.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
« no previous file with comments | « chrome/browser/search/hotword_service.h ('k') | chrome/browser/ui/app_list/app_list_view_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/hotword_service.cc
diff --git a/chrome/browser/search/hotword_service.cc b/chrome/browser/search/hotword_service.cc
index 86dfc68be170775d0dbb83da29fd69911fa476a4..69366717d4033b22db897fdaed2de5ac042d4389 100644
--- a/chrome/browser/search/hotword_service.cc
+++ b/chrome/browser/search/hotword_service.cc
@@ -20,6 +20,19 @@
#include "extensions/common/extension.h"
#include "ui/base/l10n/l10n_util.h"
+// The whole file relies on the extension systems but this file is built on
+// some non-extension supported platforms and including an API header will cause
+// a compile error since it depends on header files generated by .idl.
+// TODO(mukai): clean up file dependencies and remove this clause.
+#if defined(ENABLE_EXTENSIONS)
+#include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h"
+#endif
+
+#if defined(ENABLE_EXTENSIONS)
+using extensions::BrowserContextKeyedAPIFactory;
+using extensions::HotwordPrivateEventService;
+#endif
+
namespace {
const int kMaxTimesToShowOptInPopup = 10;
@@ -122,7 +135,8 @@ bool HotwordService::DoesHotwordSupportLanguage(Profile* profile) {
}
HotwordService::HotwordService(Profile* profile)
- : profile_(profile) {
+ : profile_(profile),
+ client_(NULL) {
// This will be called during profile initialization which is a good time
// to check the user's hotword state.
HotwordEnabled enabled_state = UNSET;
@@ -275,3 +289,32 @@ void HotwordService::OnHotwordSearchEnabledChanged(
else
DisableHotwordExtension(extension_service);
}
+
+void HotwordService::RequestHotwordSession(HotwordClient* client) {
+#if defined(ENABLE_EXTENSIONS)
+ if (!IsServiceAvailable() || client_)
+ return;
+
+ client_ = client;
+
+ HotwordPrivateEventService* event_service =
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_);
+ if (event_service)
+ event_service->OnHotwordSessionRequested();
+#endif
+}
+
+void HotwordService::StopHotwordSession(HotwordClient* client) {
+#if defined(ENABLE_EXTENSIONS)
+ if (!IsServiceAvailable())
+ return;
+
+ DCHECK(client_ == client);
+
+ client_ = NULL;
+ HotwordPrivateEventService* event_service =
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_);
+ if (event_service)
+ event_service->OnHotwordSessionStopped();
+#endif
+}
« no previous file with comments | « chrome/browser/search/hotword_service.h ('k') | chrome/browser/ui/app_list/app_list_view_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698