| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 302   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 
| 299   return !command_line->HasSwitch(switches::kDisableExperimentalHotwording); | 303   return !command_line->HasSwitch(switches::kDisableExperimentalHotwording); | 
| 300 } | 304 } | 
| 301 | 305 | 
|  | 306 // static | 
|  | 307 bool HotwordService::IsHotwordHardwareAvailable() { | 
|  | 308 #if defined(OS_CHROMEOS) | 
|  | 309   if (chromeos::CrasAudioHandler::IsInitialized()) { | 
|  | 310     chromeos::AudioDeviceList devices; | 
|  | 311     chromeos::CrasAudioHandler::Get()->GetAudioDevices(&devices); | 
|  | 312     for (size_t i = 0; i < devices.size(); ++i) { | 
|  | 313       if (devices[i].type == chromeos::AUDIO_TYPE_AOKR) { | 
|  | 314         DCHECK(devices[i].is_input); | 
|  | 315         return true; | 
|  | 316       } | 
|  | 317     } | 
|  | 318   } | 
|  | 319 #endif | 
|  | 320   return false; | 
|  | 321 } | 
|  | 322 | 
| 302 #if defined(OS_CHROMEOS) | 323 #if defined(OS_CHROMEOS) | 
| 303 class HotwordService::HotwordUserSessionStateObserver | 324 class HotwordService::HotwordUserSessionStateObserver | 
| 304     : public user_manager::UserManager::UserSessionStateObserver { | 325     : public user_manager::UserManager::UserSessionStateObserver { | 
| 305  public: | 326  public: | 
| 306   explicit HotwordUserSessionStateObserver(HotwordService* service) | 327   explicit HotwordUserSessionStateObserver(HotwordService* service) | 
| 307       : service_(service) {} | 328       : service_(service) {} | 
| 308 | 329 | 
| 309   // Overridden from UserSessionStateObserver: | 330   // Overridden from UserSessionStateObserver: | 
| 310   void ActiveUserChanged(const user_manager::User* active_user) override { | 331   void ActiveUserChanged(const user_manager::User* active_user) override { | 
| 311     service_->ActiveUserChanged(); | 332     service_->ActiveUserChanged(); | 
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 888   // Only support multiple profiles and profile switching in ChromeOS. | 909   // Only support multiple profiles and profile switching in ChromeOS. | 
| 889   if (user_manager::UserManager::IsInitialized()) { | 910   if (user_manager::UserManager::IsInitialized()) { | 
| 890     user_manager::User* user = | 911     user_manager::User* user = | 
| 891         user_manager::UserManager::Get()->GetActiveUser(); | 912         user_manager::UserManager::Get()->GetActiveUser(); | 
| 892     if (user && user->is_profile_created()) | 913     if (user && user->is_profile_created()) | 
| 893       return profile_ == ProfileManager::GetActiveUserProfile(); | 914       return profile_ == ProfileManager::GetActiveUserProfile(); | 
| 894   } | 915   } | 
| 895 #endif | 916 #endif | 
| 896   return true; | 917   return true; | 
| 897 } | 918 } | 
| OLD | NEW | 
|---|