| 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.h" | 5 #include "chrome/browser/search/hotword_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "content/public/common/webplugininfo.h" | 43 #include "content/public/common/webplugininfo.h" |
| 44 #include "extensions/browser/extension_system.h" | 44 #include "extensions/browser/extension_system.h" |
| 45 #include "extensions/browser/uninstall_reason.h" | 45 #include "extensions/browser/uninstall_reason.h" |
| 46 #include "extensions/common/constants.h" | 46 #include "extensions/common/constants.h" |
| 47 #include "extensions/common/extension.h" | 47 #include "extensions/common/extension.h" |
| 48 #include "extensions/common/one_shot_event.h" | 48 #include "extensions/common/one_shot_event.h" |
| 49 #include "grit/theme_resources.h" | 49 #include "grit/theme_resources.h" |
| 50 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
| 51 #include "ui/base/resource/resource_bundle.h" | 51 #include "ui/base/resource/resource_bundle.h" |
| 52 | 52 |
| 53 #if defined(OS_CHROMEOS) |
| 54 #include "chromeos/audio/cras_audio_handler.h" |
| 55 #endif |
| 56 |
| 53 using extensions::BrowserContextKeyedAPIFactory; | 57 using extensions::BrowserContextKeyedAPIFactory; |
| 54 using extensions::HotwordPrivateEventService; | 58 using extensions::HotwordPrivateEventService; |
| 55 | 59 |
| 56 namespace { | 60 namespace { |
| 57 | 61 |
| 58 // Allowed locales for hotwording. Note that Chrome does not support all of | 62 // Allowed locales for hotwording. Note that Chrome does not support all of |
| 59 // these locales, condensing them to their 2-letter equivalent, but the full | 63 // these locales, condensing them to their 2-letter equivalent, but the full |
| 60 // list is here for completeness and testing. | 64 // list is here for completeness and testing. |
| 61 static const char* kSupportedLocales[] = { | 65 static const char* kSupportedLocales[] = { |
| 62 "en", | 66 "en", |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 return true; | 295 return true; |
| 292 } | 296 } |
| 293 return false; | 297 return false; |
| 294 } | 298 } |
| 295 | 299 |
| 296 // static | 300 // static |
| 297 bool HotwordService::IsExperimentalHotwordingEnabled() { | 301 bool HotwordService::IsExperimentalHotwordingEnabled() { |
| 298 return true; | 302 return true; |
| 299 } | 303 } |
| 300 | 304 |
| 305 // static |
| 306 bool HotwordService::IsHotwordHardwareAvailable() { |
| 307 #if defined(OS_CHROMEOS) |
| 308 if (chromeos::CrasAudioHandler::IsInitialized()) { |
| 309 chromeos::AudioDeviceList devices; |
| 310 chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices); |
| 311 for (size_t i = 0; i < devices.size(); ++i) { |
| 312 if (devices[i].type == chromeos::AUDIO_TYPE_AOKR) { |
| 313 DCHECK(devices[i].is_input); |
| 314 return true; |
| 315 } |
| 316 } |
| 317 } |
| 318 #endif |
| 319 return false; |
| 320 } |
| 321 |
| 301 #if defined(OS_CHROMEOS) | 322 #if defined(OS_CHROMEOS) |
| 302 class HotwordService::HotwordUserSessionStateObserver | 323 class HotwordService::HotwordUserSessionStateObserver |
| 303 : public user_manager::UserManager::UserSessionStateObserver { | 324 : public user_manager::UserManager::UserSessionStateObserver { |
| 304 public: | 325 public: |
| 305 explicit HotwordUserSessionStateObserver(HotwordService* service) | 326 explicit HotwordUserSessionStateObserver(HotwordService* service) |
| 306 : service_(service) {} | 327 : service_(service) {} |
| 307 | 328 |
| 308 // Overridden from UserSessionStateObserver: | 329 // Overridden from UserSessionStateObserver: |
| 309 void ActiveUserChanged(const user_manager::User* active_user) override { | 330 void ActiveUserChanged(const user_manager::User* active_user) override { |
| 310 service_->ActiveUserChanged(); | 331 service_->ActiveUserChanged(); |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 // Only support multiple profiles and profile switching in ChromeOS. | 905 // Only support multiple profiles and profile switching in ChromeOS. |
| 885 if (user_manager::UserManager::IsInitialized()) { | 906 if (user_manager::UserManager::IsInitialized()) { |
| 886 user_manager::User* user = | 907 user_manager::User* user = |
| 887 user_manager::UserManager::Get()->GetActiveUser(); | 908 user_manager::UserManager::Get()->GetActiveUser(); |
| 888 if (user && user->is_profile_created()) | 909 if (user && user->is_profile_created()) |
| 889 return profile_ == ProfileManager::GetActiveUserProfile(); | 910 return profile_ == ProfileManager::GetActiveUserProfile(); |
| 890 } | 911 } |
| 891 #endif | 912 #endif |
| 892 return true; | 913 return true; |
| 893 } | 914 } |
| OLD | NEW |