| 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
|
| +}
|
|
|