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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 270 |
271 // static | 271 // static |
272 bool HotwordService::IsExperimentalHotwordingEnabled() { | 272 bool HotwordService::IsExperimentalHotwordingEnabled() { |
273 std::string group = base::FieldTrialList::FindFullName( | 273 std::string group = base::FieldTrialList::FindFullName( |
274 hotword_internal::kHotwordFieldTrialName); | 274 hotword_internal::kHotwordFieldTrialName); |
275 if (!group.empty() && | 275 if (!group.empty() && |
276 group == hotword_internal::kHotwordFieldTrialExperimentalGroupName) { | 276 group == hotword_internal::kHotwordFieldTrialExperimentalGroupName) { |
277 return true; | 277 return true; |
278 } | 278 } |
279 | 279 |
280 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 280 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
281 return !command_line->HasSwitch(switches::kDisableExperimentalHotwording); | 281 return !command_line->HasSwitch(switches::kDisableExperimentalHotwording); |
282 } | 282 } |
283 | 283 |
284 #if defined(OS_CHROMEOS) | 284 #if defined(OS_CHROMEOS) |
285 class HotwordService::HotwordUserSessionStateObserver | 285 class HotwordService::HotwordUserSessionStateObserver |
286 : public user_manager::UserManager::UserSessionStateObserver { | 286 : public user_manager::UserManager::UserSessionStateObserver { |
287 public: | 287 public: |
288 explicit HotwordUserSessionStateObserver(HotwordService* service) | 288 explicit HotwordUserSessionStateObserver(HotwordService* service) |
289 : service_(service) {} | 289 : service_(service) {} |
290 | 290 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 348 |
349 SetAudioHistoryHandler(new HotwordAudioHistoryHandler( | 349 SetAudioHistoryHandler(new HotwordAudioHistoryHandler( |
350 profile_, base::MessageLoop::current()->task_runner())); | 350 profile_, base::MessageLoop::current()->task_runner())); |
351 | 351 |
352 if (HotwordServiceFactory::IsHotwordHardwareAvailable() && | 352 if (HotwordServiceFactory::IsHotwordHardwareAvailable() && |
353 IsHotwordAllowed() && | 353 IsHotwordAllowed() && |
354 IsExperimentalHotwordingEnabled()) { | 354 IsExperimentalHotwordingEnabled()) { |
355 // Show the hotword notification in 5 seconds if the experimental flag is | 355 // Show the hotword notification in 5 seconds if the experimental flag is |
356 // on, or in 30 minutes if not. We need to wait at least a few seconds | 356 // on, or in 30 minutes if not. We need to wait at least a few seconds |
357 // for the hotword extension to be installed. | 357 // for the hotword extension to be installed. |
358 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 358 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
359 if (command_line->HasSwitch(switches::kEnableExperimentalHotwordHardware)) { | 359 if (command_line->HasSwitch(switches::kEnableExperimentalHotwordHardware)) { |
360 base::MessageLoop::current()->PostDelayedTask( | 360 base::MessageLoop::current()->PostDelayedTask( |
361 FROM_HERE, | 361 FROM_HERE, |
362 base::Bind(&HotwordService::ShowHotwordNotification, | 362 base::Bind(&HotwordService::ShowHotwordNotification, |
363 weak_factory_.GetWeakPtr()), | 363 weak_factory_.GetWeakPtr()), |
364 base::TimeDelta::FromSeconds(5)); | 364 base::TimeDelta::FromSeconds(5)); |
365 } else if (!profile_->GetPrefs()->GetBoolean( | 365 } else if (!profile_->GetPrefs()->GetBoolean( |
366 prefs::kHotwordAlwaysOnNotificationSeen)) { | 366 prefs::kHotwordAlwaysOnNotificationSeen)) { |
367 base::MessageLoop::current()->PostDelayedTask( | 367 base::MessageLoop::current()->PostDelayedTask( |
368 FROM_HERE, | 368 FROM_HERE, |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 // Only support multiple profiles and profile switching in ChromeOS. | 841 // Only support multiple profiles and profile switching in ChromeOS. |
842 if (user_manager::UserManager::IsInitialized()) { | 842 if (user_manager::UserManager::IsInitialized()) { |
843 user_manager::User* user = | 843 user_manager::User* user = |
844 user_manager::UserManager::Get()->GetActiveUser(); | 844 user_manager::UserManager::Get()->GetActiveUser(); |
845 if (user && user->is_profile_created()) | 845 if (user && user->is_profile_created()) |
846 return profile_ == ProfileManager::GetActiveUserProfile(); | 846 return profile_ == ProfileManager::GetActiveUserProfile(); |
847 } | 847 } |
848 #endif | 848 #endif |
849 return true; | 849 return true; |
850 } | 850 } |
OLD | NEW |