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

Side by Side Diff: chrome/browser/search/hotword_service_factory.cc

Issue 795393002: [Hotword] Implement IsHotwordHardwareAvailable() using device types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | chromeos/audio/audio_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/search/hotword_service_factory.h" 5 #include "chrome/browser/search/hotword_service_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/hotword_service.h" 10 #include "chrome/browser/search/hotword_service.h"
11 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h" 13 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 #include "components/pref_registry/pref_registry_syncable.h" 14 #include "components/pref_registry/pref_registry_syncable.h"
15 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 17
18 #if defined(OS_CHROMEOS)
19 #include "chromeos/audio/cras_audio_handler.h"
20 #endif
21
18 using content::BrowserContext; 22 using content::BrowserContext;
19 using content::BrowserThread; 23 using content::BrowserThread;
20 24
21 // static 25 // static
22 HotwordService* HotwordServiceFactory::GetForProfile(BrowserContext* context) { 26 HotwordService* HotwordServiceFactory::GetForProfile(BrowserContext* context) {
23 return static_cast<HotwordService*>( 27 return static_cast<HotwordService*>(
24 GetInstance()->GetServiceForBrowserContext(context, true)); 28 GetInstance()->GetServiceForBrowserContext(context, true));
25 } 29 }
26 30
27 // static 31 // static
28 HotwordServiceFactory* HotwordServiceFactory::GetInstance() { 32 HotwordServiceFactory* HotwordServiceFactory::GetInstance() {
29 return Singleton<HotwordServiceFactory>::get(); 33 return Singleton<HotwordServiceFactory>::get();
30 } 34 }
31 35
32 // static 36 // static
33 bool HotwordServiceFactory::IsServiceAvailable(BrowserContext* context) { 37 bool HotwordServiceFactory::IsServiceAvailable(BrowserContext* context) {
34 HotwordService* hotword_service = GetForProfile(context); 38 HotwordService* hotword_service = GetForProfile(context);
35 return hotword_service && hotword_service->IsServiceAvailable(); 39 return hotword_service && hotword_service->IsServiceAvailable();
36 } 40 }
37 41
38 // static 42 // static
39 bool HotwordServiceFactory::IsHotwordAllowed(BrowserContext* context) { 43 bool HotwordServiceFactory::IsHotwordAllowed(BrowserContext* context) {
40 HotwordService* hotword_service = GetForProfile(context); 44 HotwordService* hotword_service = GetForProfile(context);
41 return hotword_service && hotword_service->IsHotwordAllowed(); 45 return hotword_service && hotword_service->IsHotwordAllowed();
42 } 46 }
43 47
44 // static 48 // static
45 bool HotwordServiceFactory::IsHotwordHardwareAvailable() { 49 bool HotwordServiceFactory::IsHotwordHardwareAvailable() {
46 // TODO(rlp, dgreid): return has_hotword_hardware() 50 #if defined(OS_CHROMEOS)
47 // Fill in once the hardware has the correct interface implemented. 51 chromeos::AudioDeviceList devices;
48 // In the meantime, this function can be used to get other parts moving 52 chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices);
49 // based on a flag. 53 for (size_t i = 0; i < devices.size(); ++i) {
54 if (devices[i].type == chromeos::AUDIO_TYPE_AOKR)
jennyz 2014/12/13 00:05:01 By the way, do you know if this device is an input
dgreid 2014/12/13 00:06:11 always input.
jennyz 2014/12/13 00:08:14 How about DCHECK(devices[i].is_input)?
jennyz 2014/12/13 00:17:36 I think it makes more sense to DCHECK it is input
rpetterson 2014/12/13 00:56:27 Ah, got it. I got the lines confused before. Done.
55 return true;
56 }
57 #endif
50 CommandLine* command_line = CommandLine::ForCurrentProcess(); 58 CommandLine* command_line = CommandLine::ForCurrentProcess();
51 return command_line->HasSwitch(switches::kEnableExperimentalHotwordHardware); 59 return command_line->HasSwitch(switches::kEnableExperimentalHotwordHardware);
52 } 60 }
53 61
54 // static 62 // static
55 int HotwordServiceFactory::GetCurrentError(BrowserContext* context) { 63 int HotwordServiceFactory::GetCurrentError(BrowserContext* context) {
56 HotwordService* hotword_service = GetForProfile(context); 64 HotwordService* hotword_service = GetForProfile(context);
57 if (!hotword_service) 65 if (!hotword_service)
58 return 0; 66 return 0;
59 return hotword_service->error_message(); 67 return hotword_service->error_message();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 135 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
128 prefs->RegisterBooleanPref(prefs::kHotwordAlwaysOnNotificationSeen, 136 prefs->RegisterBooleanPref(prefs::kHotwordAlwaysOnNotificationSeen,
129 false, 137 false,
130 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 138 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
131 } 139 }
132 140
133 KeyedService* HotwordServiceFactory::BuildServiceInstanceFor( 141 KeyedService* HotwordServiceFactory::BuildServiceInstanceFor(
134 BrowserContext* context) const { 142 BrowserContext* context) const {
135 return new HotwordService(Profile::FromBrowserContext(context)); 143 return new HotwordService(Profile::FromBrowserContext(context));
136 } 144 }
OLDNEW
« no previous file with comments | « no previous file | chromeos/audio/audio_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698