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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 if (extension_service) { | 446 if (extension_service) { |
447 extension_service->DisableExtension( | 447 extension_service->DisableExtension( |
448 extension_misc::kHotwordExtensionId, | 448 extension_misc::kHotwordExtensionId, |
449 extensions::Extension::DISABLE_USER_ACTION); | 449 extensions::Extension::DISABLE_USER_ACTION); |
450 } | 450 } |
451 } | 451 } |
452 | 452 |
453 void HotwordService::OnHotwordAlwaysOnSearchEnabledChanged( | 453 void HotwordService::OnHotwordAlwaysOnSearchEnabledChanged( |
454 const std::string& pref_name) { | 454 const std::string& pref_name) { |
455 DCHECK_EQ(pref_name, std::string(prefs::kHotwordAlwaysOnSearchEnabled)); | 455 DCHECK_EQ(pref_name, std::string(prefs::kHotwordAlwaysOnSearchEnabled)); |
456 // TODO(kcarattini): Launch in the appropriate mode given the state of | |
457 // the account-level Audio History setting. | |
458 LaunchHotwordAudioVerificationApp(HOTWORD_AND_AUDIO_HISTORY); | |
459 } | |
460 | |
461 void HotwordService::LaunchHotwordAudioVerificationApp( | |
462 const LaunchMode& launch_mode) { | |
463 hotword_audio_verification_launch_mode_ = launch_mode; | |
456 | 464 |
457 ExtensionService* extension_service = GetExtensionService(profile_); | 465 ExtensionService* extension_service = GetExtensionService(profile_); |
458 if (!extension_service) | 466 if (!extension_service) |
459 return; | 467 return; |
460 | |
461 const extensions::Extension* extension = extension_service->GetExtensionById( | 468 const extensions::Extension* extension = extension_service->GetExtensionById( |
462 extension_misc::kHotwordAudioVerificationAppId, true); | 469 extension_misc::kHotwordAudioVerificationAppId, true); |
463 if (!extension) | 470 if (!extension) |
464 return; | 471 return; |
465 | 472 |
466 if (profile_->GetPrefs()->GetBoolean(prefs::kHotwordAlwaysOnSearchEnabled)) { | 473 OpenApplication(AppLaunchParams( |
rpetterson
2014/09/10 23:04:23
Why don't you check if the pref is enabled any mor
kcarattini
2014/09/11 00:08:30
I don't think this is the final behaviour we want
rpetterson
2014/09/11 17:43:54
Got it. So only enable it if they've done the veri
kcarattini
2014/09/11 23:32:50
Yes, that's the idea.
| |
467 OpenApplication(AppLaunchParams( | 474 profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); |
468 profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); | 475 } |
469 } | 476 |
477 HotwordService::LaunchMode | |
478 HotwordService::GetHotwordAudioVerificationLaunchMode() { | |
479 return hotword_audio_verification_launch_mode_; | |
470 } | 480 } |
471 | 481 |
472 void HotwordService::OnHotwordSearchEnabledChanged( | 482 void HotwordService::OnHotwordSearchEnabledChanged( |
473 const std::string& pref_name) { | 483 const std::string& pref_name) { |
474 DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); | 484 DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); |
475 | 485 |
476 ExtensionService* extension_service = GetExtensionService(profile_); | 486 ExtensionService* extension_service = GetExtensionService(profile_); |
477 if (profile_->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)) | 487 if (profile_->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)) |
478 EnableHotwordExtension(extension_service); | 488 EnableHotwordExtension(extension_service); |
479 else | 489 else |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 return false; | 527 return false; |
518 | 528 |
519 std::string previous_locale = | 529 std::string previous_locale = |
520 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); | 530 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); |
521 std::string locale = GetCurrentLocale(profile_); | 531 std::string locale = GetCurrentLocale(profile_); |
522 | 532 |
523 // If it's a new locale, then the old extension should be uninstalled. | 533 // If it's a new locale, then the old extension should be uninstalled. |
524 return locale != previous_locale && | 534 return locale != previous_locale && |
525 HotwordService::DoesHotwordSupportLanguage(profile_); | 535 HotwordService::DoesHotwordSupportLanguage(profile_); |
526 } | 536 } |
OLD | NEW |