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

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

Issue 528113003: Hotword Audio Verification App: Adds to hotwordPrivate API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@page-one
Patch Set: Review comments Created 6 years, 3 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/search/hotword_client.h" 11 #include "chrome/browser/search/hotword_client.h"
12 #include "chrome/browser/search/hotword_service.h" 12 #include "chrome/browser/search/hotword_service.h"
13 #include "chrome/browser/search/hotword_service_factory.h" 13 #include "chrome/browser/search/hotword_service_factory.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "extensions/browser/event_router.h" 16 #include "extensions/browser/event_router.h"
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 namespace hotword_private_constants {
21 const char kHotwordServiceUnavailable[] = "Hotword Service is unavailable.";
22 } // hotword_private_constants
23
20 namespace OnEnabledChanged = 24 namespace OnEnabledChanged =
21 api::hotword_private::OnEnabledChanged; 25 api::hotword_private::OnEnabledChanged;
22 26
23 static base::LazyInstance< 27 static base::LazyInstance<
24 BrowserContextKeyedAPIFactory<HotwordPrivateEventService> > g_factory = 28 BrowserContextKeyedAPIFactory<HotwordPrivateEventService> > g_factory =
25 LAZY_INSTANCE_INITIALIZER; 29 LAZY_INSTANCE_INITIALIZER;
26 30
27 HotwordPrivateEventService::HotwordPrivateEventService( 31 HotwordPrivateEventService::HotwordPrivateEventService(
28 content::BrowserContext* context) 32 content::BrowserContext* context)
29 : profile_(Profile::FromBrowserContext(context)) { 33 : profile_(Profile::FromBrowserContext(context)) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 135 }
132 136
133 bool HotwordPrivateNotifyHotwordRecognitionFunction::RunSync() { 137 bool HotwordPrivateNotifyHotwordRecognitionFunction::RunSync() {
134 HotwordService* hotword_service = 138 HotwordService* hotword_service =
135 HotwordServiceFactory::GetForProfile(GetProfile()); 139 HotwordServiceFactory::GetForProfile(GetProfile());
136 if (hotword_service && hotword_service->client()) 140 if (hotword_service && hotword_service->client())
137 hotword_service->client()->OnHotwordRecognized(); 141 hotword_service->client()->OnHotwordRecognized();
138 return true; 142 return true;
139 } 143 }
140 144
145 bool HotwordPrivateGetLaunchStateFunction::RunSync() {
146 api::hotword_private::LaunchState result;
147
148 HotwordService* hotword_service =
149 HotwordServiceFactory::GetForProfile(GetProfile());
150 if (!hotword_service) {
151 error_ = hotword_private_constants::kHotwordServiceUnavailable;
rpetterson 2014/09/10 23:04:22 This should probably be defined in resources.grd r
kcarattini 2014/09/11 00:08:29 Does this get exposed to the user? I thought it wa
benwells 2014/09/11 19:27:40 That's basically right - these are developer facin
rpetterson 2014/09/11 19:33:32 Good to know, thanks!
152 return false;
153 } else {
154 result.launch_mode =
155 hotword_service->GetHotwordAudioVerificationLaunchMode();
156 }
157
158 SetResult(result.ToValue().release());
159 return true;
160 }
161
141 } // namespace extensions 162 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698