Index: chrome/browser/search/hotword_service.cc |
diff --git a/chrome/browser/search/hotword_service.cc b/chrome/browser/search/hotword_service.cc |
index ac25512d2f273ca8f27672a3e8413ef7b6059c4a..d2b104870019a1187515dc147f6967e1bd002e27 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; |
@@ -120,7 +124,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; |
@@ -273,3 +278,33 @@ void HotwordService::OnHotwordSearchEnabledChanged( |
else |
DisableHotwordExtension(extension_service); |
} |
+ |
+void HotwordService::RequestHotwordSession( |
+ HotwordClient* client) { |
rpetterson
2014/05/02 19:13:16
move to line above
Jun Mukai
2014/05/02 22:18:57
Done.
|
+ if (!IsServiceAvailable()) |
+ return; |
+ |
+ if (client_) |
rpetterson
2014/05/02 19:13:16
combine with the line above:
if (!IsServiceAvailab
Jun Mukai
2014/05/02 22:18:57
Done.
|
+ return; |
+ |
+ client_ = client; |
+ |
+ HotwordPrivateEventService* event_service = |
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_); |
+ if (event_service) |
+ event_service->OnHotwordSessionRequested(); |
+} |
+ |
+void HotwordService::StopHotwordSession( |
+ HotwordClient* client) { |
rpetterson
2014/05/02 19:13:16
move to line above
Jun Mukai
2014/05/02 22:18:57
Done.
|
+ if (!IsServiceAvailable()) |
+ return; |
+ |
+ DCHECK(client_ == client); |
+ |
+ client_ = NULL; |
+ HotwordPrivateEventService* event_service = |
+ BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_); |
+ if (event_service) |
+ event_service->OnHotwordSessionStopped(); |
+} |