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..78a0face9a478066b0a6b7cd45d4fbbf6b2c0e6f 100644 |
--- a/chrome/browser/search/hotword_service.cc |
+++ b/chrome/browser/search/hotword_service.cc |
@@ -10,6 +10,7 @@ |
#include "base/prefs/pref_service.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chrome_notification_types.h" |
+#include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" |
#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/common/extensions/extension_constants.h" |
@@ -20,6 +21,9 @@ |
#include "extensions/common/extension.h" |
#include "ui/base/l10n/l10n_util.h" |
+using extensions::BrowserContextKeyedAPIFactory; |
+using extensions::HotwordPrivateEventService; |
+ |
namespace { |
const int kMaxTimesToShowOptInPopup = 10; |
@@ -122,7 +126,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 +280,28 @@ void HotwordService::OnHotwordSearchEnabledChanged( |
else |
DisableHotwordExtension(extension_service); |
} |
+ |
+void HotwordService::RequestHotwordSession(HotwordClient* client) { |
+ if (!IsServiceAvailable() || client_) |
+ return; |
+ |
+ client_ = client; |
+ |
+ HotwordPrivateEventService* event_service = |
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_); |
+ if (event_service) |
+ event_service->OnHotwordSessionRequested(); |
+} |
+ |
+void HotwordService::StopHotwordSession(HotwordClient* client) { |
+ if (!IsServiceAvailable()) |
+ return; |
+ |
+ DCHECK(client_ == client); |
+ |
+ client_ = NULL; |
+ HotwordPrivateEventService* event_service = |
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_); |
+ if (event_service) |
+ event_service->OnHotwordSessionStopped(); |
+} |