Chromium Code Reviews| 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 EventRouter* router = EventRouter::Get(profile_); | |
|
kcarattini
2015/03/31 23:31:46
check for a null return value (like the function b
calamity
2015/04/01 02:36:10
Made an overload for SignalEvent.
kcarattini
2015/04/01 05:04:36
Even better.
| |
| 111 | |
| 112 scoped_ptr<base::ListValue> args(new base::ListValue()); | |
| 113 args->AppendBoolean(enabled); | |
| 114 scoped_ptr<Event> event(new Event( | |
| 115 api::hotword_private::OnMicrophoneStateChanged::kEventName, args.Pass())); | |
| 116 router->BroadcastEvent(event.Pass()); | |
| 117 } | |
| 118 | |
| 109 void HotwordPrivateEventService::SignalEvent(const std::string& event_name) { | 119 void HotwordPrivateEventService::SignalEvent(const std::string& event_name) { |
| 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 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 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() { |
| (...skipping 354 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 |