Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: chrome/browser/extensions/api/hotword_private/hotword_private_api.cc

Issue 1027683002: Hotword Private API: Add function and event to query the existence of a speaker model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 96
97 void HotwordPrivateEventService::OnHotwordTriggered() { 97 void HotwordPrivateEventService::OnHotwordTriggered() {
98 SignalEvent(api::hotword_private::OnHotwordTriggered::kEventName); 98 SignalEvent(api::hotword_private::OnHotwordTriggered::kEventName);
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() {
106 SignalEvent(api::hotword_private::OnSpeakerModelExists::kEventName);
107 }
108
105 void HotwordPrivateEventService::SignalEvent(const std::string& event_name) { 109 void HotwordPrivateEventService::SignalEvent(const std::string& event_name) {
106 EventRouter* router = EventRouter::Get(profile_); 110 EventRouter* router = EventRouter::Get(profile_);
107 if (!router || !router->HasEventListener(event_name)) 111 if (!router || !router->HasEventListener(event_name))
108 return; 112 return;
109 scoped_ptr<base::ListValue> args(new base::ListValue()); 113 scoped_ptr<base::ListValue> args(new base::ListValue());
110 scoped_ptr<Event> event(new Event(event_name, args.Pass())); 114 scoped_ptr<Event> event(new Event(event_name, args.Pass()));
111 router->BroadcastEvent(event.Pass()); 115 router->BroadcastEvent(event.Pass());
112 } 116 }
113 117
114 bool HotwordPrivateSetEnabledFunction::RunSync() { 118 bool HotwordPrivateSetEnabledFunction::RunSync() {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 450
447 void HotwordPrivateGetAudioHistoryEnabledFunction::SetResultAndSendResponse( 451 void HotwordPrivateGetAudioHistoryEnabledFunction::SetResultAndSendResponse(
448 bool success, bool new_enabled_value) { 452 bool success, bool new_enabled_value) {
449 api::hotword_private::AudioHistoryState result; 453 api::hotword_private::AudioHistoryState result;
450 result.success = success; 454 result.success = success;
451 result.enabled = new_enabled_value; 455 result.enabled = new_enabled_value;
452 SetResult(result.ToValue().release()); 456 SetResult(result.ToValue().release());
453 SendResponse(true); 457 SendResponse(true);
454 } 458 }
455 459
460 bool HotwordPrivateSpeakerModelExistsResultFunction::RunSync() {
461 scoped_ptr<api::hotword_private::SpeakerModelExistsResult::Params> params(
462 api::hotword_private::SpeakerModelExistsResult::Params::Create(*args_));
463 EXTENSION_FUNCTION_VALIDATE(params.get());
464
465 HotwordService* hotword_service =
466 HotwordServiceFactory::GetForProfile(GetProfile());
467 if (!hotword_service)
468 return false;
469
470 hotword_service->SpeakerModelExistsComplete(params->exists);
471 return true;
472 }
473
456 } // namespace extensions 474 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698