| OLD | NEW |
| 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 "chromeos/audio/cras_audio_handler.h" | 20 #include "chromeos/audio/cras_audio_handler.h" |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 using content::BrowserContext; | 23 using content::BrowserContext; |
| 23 using content::BrowserThread; | 24 using content::BrowserThread; |
| 24 | 25 |
| 25 // static | 26 // static |
| 26 HotwordService* HotwordServiceFactory::GetForProfile(BrowserContext* context) { | 27 HotwordService* HotwordServiceFactory::GetForProfile(BrowserContext* context) { |
| 27 return static_cast<HotwordService*>( | 28 return static_cast<HotwordService*>( |
| 28 GetInstance()->GetServiceForBrowserContext(context, true)); | 29 GetInstance()->GetServiceForBrowserContext(context, true)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 40 } | 41 } |
| 41 | 42 |
| 42 // static | 43 // static |
| 43 bool HotwordServiceFactory::IsHotwordAllowed(BrowserContext* context) { | 44 bool HotwordServiceFactory::IsHotwordAllowed(BrowserContext* context) { |
| 44 HotwordService* hotword_service = GetForProfile(context); | 45 HotwordService* hotword_service = GetForProfile(context); |
| 45 return hotword_service && hotword_service->IsHotwordAllowed(); | 46 return hotword_service && hotword_service->IsHotwordAllowed(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 // static | 49 // static |
| 49 bool HotwordServiceFactory::IsAlwaysOnAvailable() { | 50 bool HotwordServiceFactory::IsAlwaysOnAvailable() { |
| 50 // Temporarily disabling hotword hardware check for M42. Will be | |
| 51 // re-enabled for M43. | |
| 52 #if 0 | |
| 53 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
| 54 if (chromeos::CrasAudioHandler::IsInitialized()) { | 52 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 53 if ((channel == chrome::VersionInfo::CHANNEL_UNKNOWN || |
| 54 channel == chrome::VersionInfo::CHANNEL_CANARY || |
| 55 channel == chrome::VersionInfo::CHANNEL_DEV) && |
| 56 chromeos::CrasAudioHandler::IsInitialized()) { |
| 55 chromeos::AudioDeviceList devices; | 57 chromeos::AudioDeviceList devices; |
| 56 chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices); | 58 chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices); |
| 57 for (size_t i = 0; i < devices.size(); ++i) { | 59 for (size_t i = 0; i < devices.size(); ++i) { |
| 58 if (devices[i].type == chromeos::AUDIO_TYPE_AOKR) { | 60 if (devices[i].type == chromeos::AUDIO_TYPE_AOKR) { |
| 59 DCHECK(devices[i].is_input); | 61 DCHECK(devices[i].is_input); |
| 60 return true; | 62 return true; |
| 61 } | 63 } |
| 62 } | 64 } |
| 63 } | 65 } |
| 64 #endif | 66 #endif |
| 65 #endif // 0 | |
| 66 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 67 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 67 return command_line->HasSwitch(switches::kEnableExperimentalHotwordHardware); | 68 return command_line->HasSwitch(switches::kEnableExperimentalHotwordHardware); |
| 68 } | 69 } |
| 69 | 70 |
| 70 // static | 71 // static |
| 71 int HotwordServiceFactory::GetCurrentError(BrowserContext* context) { | 72 int HotwordServiceFactory::GetCurrentError(BrowserContext* context) { |
| 72 HotwordService* hotword_service = GetForProfile(context); | 73 HotwordService* hotword_service = GetForProfile(context); |
| 73 if (!hotword_service) | 74 if (!hotword_service) |
| 74 return 0; | 75 return 0; |
| 75 return hotword_service->error_message(); | 76 return hotword_service->error_message(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 138 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 138 prefs->RegisterBooleanPref(prefs::kHotwordAlwaysOnNotificationSeen, | 139 prefs->RegisterBooleanPref(prefs::kHotwordAlwaysOnNotificationSeen, |
| 139 false, | 140 false, |
| 140 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 141 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 141 } | 142 } |
| 142 | 143 |
| 143 KeyedService* HotwordServiceFactory::BuildServiceInstanceFor( | 144 KeyedService* HotwordServiceFactory::BuildServiceInstanceFor( |
| 144 BrowserContext* context) const { | 145 BrowserContext* context) const { |
| 145 return new HotwordService(Profile::FromBrowserContext(context)); | 146 return new HotwordService(Profile::FromBrowserContext(context)); |
| 146 } | 147 } |
| OLD | NEW |