OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" | 5 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 99 } |
100 | 100 |
101 void HotwordPrivateEventService::OnDeleteSpeakerModel() { | 101 void HotwordPrivateEventService::OnDeleteSpeakerModel() { |
102 SignalEvent(api::hotword_private::OnDeleteSpeakerModel::kEventName); | 102 SignalEvent(api::hotword_private::OnDeleteSpeakerModel::kEventName); |
103 } | 103 } |
104 | 104 |
105 void HotwordPrivateEventService::OnSpeakerModelExists() { | 105 void HotwordPrivateEventService::OnSpeakerModelExists() { |
106 SignalEvent(api::hotword_private::OnSpeakerModelExists::kEventName); | 106 SignalEvent(api::hotword_private::OnSpeakerModelExists::kEventName); |
107 } | 107 } |
108 | 108 |
| 109 void HotwordPrivateEventService::OnMicrophoneStateChanged(bool enabled) { |
| 110 SignalEvent(api::hotword_private::OnMicrophoneStateChanged::kEventName, |
| 111 api::hotword_private::OnMicrophoneStateChanged::Create(enabled)); |
| 112 } |
| 113 |
109 void HotwordPrivateEventService::SignalEvent(const std::string& event_name) { | 114 void HotwordPrivateEventService::SignalEvent(const std::string& event_name) { |
| 115 SignalEvent(event_name, make_scoped_ptr(new base::ListValue())); |
| 116 } |
| 117 |
| 118 void HotwordPrivateEventService::SignalEvent(const std::string& event_name, |
| 119 scoped_ptr<base::ListValue> args) { |
110 EventRouter* router = EventRouter::Get(profile_); | 120 EventRouter* router = EventRouter::Get(profile_); |
111 if (!router || !router->HasEventListener(event_name)) | 121 if (!router || !router->HasEventListener(event_name)) |
112 return; | 122 return; |
113 scoped_ptr<base::ListValue> args(new base::ListValue()); | 123 |
114 scoped_ptr<Event> event(new Event(event_name, args.Pass())); | 124 scoped_ptr<Event> event(new Event(event_name, args.Pass())); |
115 router->BroadcastEvent(event.Pass()); | 125 router->BroadcastEvent(event.Pass()); |
116 } | 126 } |
117 | 127 |
118 bool HotwordPrivateSetEnabledFunction::RunSync() { | 128 bool HotwordPrivateSetEnabledFunction::RunSync() { |
119 scoped_ptr<api::hotword_private::SetEnabled::Params> params( | 129 scoped_ptr<api::hotword_private::SetEnabled::Params> params( |
120 api::hotword_private::SetEnabled::Params::Create(*args_)); | 130 api::hotword_private::SetEnabled::Params::Create(*args_)); |
121 EXTENSION_FUNCTION_VALIDATE(params.get()); | 131 EXTENSION_FUNCTION_VALIDATE(params.get()); |
122 | 132 |
123 PrefService* prefs = GetProfile()->GetPrefs(); | 133 PrefService* prefs = GetProfile()->GetPrefs(); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 HotwordService* hotword_service = | 483 HotwordService* hotword_service = |
474 HotwordServiceFactory::GetForProfile(GetProfile()); | 484 HotwordServiceFactory::GetForProfile(GetProfile()); |
475 if (!hotword_service) | 485 if (!hotword_service) |
476 return false; | 486 return false; |
477 | 487 |
478 hotword_service->SpeakerModelExistsComplete(params->exists); | 488 hotword_service->SpeakerModelExistsComplete(params->exists); |
479 return true; | 489 return true; |
480 } | 490 } |
481 | 491 |
482 } // namespace extensions | 492 } // namespace extensions |
OLD | NEW |