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

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

Issue 1011813006: Make availability of hotword hardware known to hotword component extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 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) 18 #if defined(OS_CHROMEOS)
19 #include "chrome/common/chrome_version_info.h" 19 #include "chrome/common/chrome_version_info.h"
20 #include "chromeos/audio/cras_audio_handler.h"
21 #endif 20 #endif
22 21
23 using content::BrowserContext; 22 using content::BrowserContext;
24 using content::BrowserThread; 23 using content::BrowserThread;
25 24
26 // static 25 // static
27 HotwordService* HotwordServiceFactory::GetForProfile(BrowserContext* context) { 26 HotwordService* HotwordServiceFactory::GetForProfile(BrowserContext* context) {
28 return static_cast<HotwordService*>( 27 return static_cast<HotwordService*>(
29 GetInstance()->GetServiceForBrowserContext(context, true)); 28 GetInstance()->GetServiceForBrowserContext(context, true));
30 } 29 }
(...skipping 15 matching lines...) Expand all
46 return hotword_service && hotword_service->IsHotwordAllowed(); 45 return hotword_service && hotword_service->IsHotwordAllowed();
47 } 46 }
48 47
49 // static 48 // static
50 bool HotwordServiceFactory::IsAlwaysOnAvailable() { 49 bool HotwordServiceFactory::IsAlwaysOnAvailable() {
51 #if defined(OS_CHROMEOS) 50 #if defined(OS_CHROMEOS)
52 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 51 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
53 if ((channel == chrome::VersionInfo::CHANNEL_UNKNOWN || 52 if ((channel == chrome::VersionInfo::CHANNEL_UNKNOWN ||
54 channel == chrome::VersionInfo::CHANNEL_CANARY || 53 channel == chrome::VersionInfo::CHANNEL_CANARY ||
55 channel == chrome::VersionInfo::CHANNEL_DEV) && 54 channel == chrome::VersionInfo::CHANNEL_DEV) &&
56 chromeos::CrasAudioHandler::IsInitialized()) { 55 HotwordService::IsHotwordHardwareAvailable()) {
57 chromeos::AudioDeviceList devices; 56 return true;
58 chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices);
59 for (size_t i = 0; i < devices.size(); ++i) {
60 if (devices[i].type == chromeos::AUDIO_TYPE_AOKR) {
61 DCHECK(devices[i].is_input);
62 return true;
63 }
64 }
65 } 57 }
66 #endif 58 #endif
67 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 59 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
68 return command_line->HasSwitch(switches::kEnableExperimentalHotwordHardware); 60 return command_line->HasSwitch(switches::kEnableExperimentalHotwordHardware);
69 } 61 }
70 62
71 // static 63 // static
72 int HotwordServiceFactory::GetCurrentError(BrowserContext* context) { 64 int HotwordServiceFactory::GetCurrentError(BrowserContext* context) {
73 HotwordService* hotword_service = GetForProfile(context); 65 HotwordService* hotword_service = GetForProfile(context);
74 if (!hotword_service) 66 if (!hotword_service)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 130 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
139 prefs->RegisterBooleanPref(prefs::kHotwordAlwaysOnNotificationSeen, 131 prefs->RegisterBooleanPref(prefs::kHotwordAlwaysOnNotificationSeen,
140 false, 132 false,
141 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 133 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
142 } 134 }
143 135
144 KeyedService* HotwordServiceFactory::BuildServiceInstanceFor( 136 KeyedService* HotwordServiceFactory::BuildServiceInstanceFor(
145 BrowserContext* context) const { 137 BrowserContext* context) const {
146 return new HotwordService(Profile::FromBrowserContext(context)); 138 return new HotwordService(Profile::FromBrowserContext(context));
147 } 139 }
OLDNEW
« no previous file with comments | « chrome/browser/search/hotword_service.cc ('k') | chrome/common/extensions/api/hotword_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698