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

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: Upload remaining test files 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 459
456 void HotwordPrivateGetAudioHistoryEnabledFunction::SetResultAndSendResponse( 460 void HotwordPrivateGetAudioHistoryEnabledFunction::SetResultAndSendResponse(
457 bool success, bool new_enabled_value) { 461 bool success, bool new_enabled_value) {
458 api::hotword_private::AudioHistoryState result; 462 api::hotword_private::AudioHistoryState result;
459 result.success = success; 463 result.success = success;
460 result.enabled = new_enabled_value; 464 result.enabled = new_enabled_value;
461 SetResult(result.ToValue().release()); 465 SetResult(result.ToValue().release());
462 SendResponse(true); 466 SendResponse(true);
463 } 467 }
464 468
469 bool HotwordPrivateSpeakerModelExistsResultFunction::RunSync() {
470 scoped_ptr<api::hotword_private::SpeakerModelExistsResult::Params> params(
471 api::hotword_private::SpeakerModelExistsResult::Params::Create(*args_));
472 EXTENSION_FUNCTION_VALIDATE(params.get());
473
474 HotwordService* hotword_service =
475 HotwordServiceFactory::GetForProfile(GetProfile());
476 if (!hotword_service)
477 return false;
478
479 hotword_service->SpeakerModelExistsComplete(params->exists);
480 return true;
481 }
482
465 } // namespace extensions 483 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698