| 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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" | 15 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/pending_extension_manager.h" | 17 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 18 #include "chrome/browser/extensions/updater/extension_updater.h" | 18 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 19 #include "chrome/browser/extensions/webstore_startup_installer.h" | 19 #include "chrome/browser/extensions/webstore_startup_installer.h" |
| 20 #include "chrome/browser/plugins/plugin_prefs.h" | 20 #include "chrome/browser/plugins/plugin_prefs.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/search/hotword_audio_history_handler.h" | 22 #include "chrome/browser/search/hotword_audio_history_handler.h" |
| 23 #include "chrome/browser/search/hotword_service_factory.h" | 23 #include "chrome/browser/search/hotword_service_factory.h" |
| 24 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 24 #include "chrome/browser/ui/extensions/application_launch.h" | 25 #include "chrome/browser/ui/extensions/application_launch.h" |
| 25 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
| 26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/extensions/extension_constants.h" | 28 #include "chrome/common/extensions/extension_constants.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/grit/generated_resources.h" | 30 #include "chrome/grit/generated_resources.h" |
| 30 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/plugin_service.h" | 33 #include "content/public/browser/plugin_service.h" |
| 33 #include "content/public/common/webplugininfo.h" | 34 #include "content/public/common/webplugininfo.h" |
| 34 #include "extensions/browser/extension_system.h" | 35 #include "extensions/browser/extension_system.h" |
| 35 #include "extensions/browser/uninstall_reason.h" | 36 #include "extensions/browser/uninstall_reason.h" |
| 37 #include "extensions/common/constants.h" |
| 36 #include "extensions/common/extension.h" | 38 #include "extensions/common/extension.h" |
| 37 #include "extensions/common/one_shot_event.h" | 39 #include "extensions/common/one_shot_event.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
| 39 | 41 |
| 40 using extensions::BrowserContextKeyedAPIFactory; | 42 using extensions::BrowserContextKeyedAPIFactory; |
| 41 using extensions::HotwordPrivateEventService; | 43 using extensions::HotwordPrivateEventService; |
| 42 | 44 |
| 43 namespace { | 45 namespace { |
| 44 | 46 |
| 45 // Allowed languages for hotwording. | 47 // Allowed languages for hotwording. |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 hotword_audio_verification_launch_mode_ = launch_mode; | 481 hotword_audio_verification_launch_mode_ = launch_mode; |
| 480 | 482 |
| 481 ExtensionService* extension_service = GetExtensionService(profile_); | 483 ExtensionService* extension_service = GetExtensionService(profile_); |
| 482 if (!extension_service) | 484 if (!extension_service) |
| 483 return; | 485 return; |
| 484 const extensions::Extension* extension = extension_service->GetExtensionById( | 486 const extensions::Extension* extension = extension_service->GetExtensionById( |
| 485 extension_misc::kHotwordAudioVerificationAppId, true); | 487 extension_misc::kHotwordAudioVerificationAppId, true); |
| 486 if (!extension) | 488 if (!extension) |
| 487 return; | 489 return; |
| 488 | 490 |
| 489 OpenApplication(AppLaunchParams( | 491 OpenApplication( |
| 490 profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); | 492 AppLaunchParams(profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, |
| 493 NEW_WINDOW, extensions::SOURCE_CHROME_INTERNAL)); |
| 491 } | 494 } |
| 492 | 495 |
| 493 HotwordService::LaunchMode | 496 HotwordService::LaunchMode |
| 494 HotwordService::GetHotwordAudioVerificationLaunchMode() { | 497 HotwordService::GetHotwordAudioVerificationLaunchMode() { |
| 495 return hotword_audio_verification_launch_mode_; | 498 return hotword_audio_verification_launch_mode_; |
| 496 } | 499 } |
| 497 | 500 |
| 498 void HotwordService::StartTraining() { | 501 void HotwordService::StartTraining() { |
| 499 training_ = true; | 502 training_ = true; |
| 500 | 503 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 return false; | 597 return false; |
| 595 | 598 |
| 596 std::string previous_locale = | 599 std::string previous_locale = |
| 597 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); | 600 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); |
| 598 std::string locale = GetCurrentLocale(profile_); | 601 std::string locale = GetCurrentLocale(profile_); |
| 599 | 602 |
| 600 // If it's a new locale, then the old extension should be uninstalled. | 603 // If it's a new locale, then the old extension should be uninstalled. |
| 601 return locale != previous_locale && | 604 return locale != previous_locale && |
| 602 HotwordService::DoesHotwordSupportLanguage(profile_); | 605 HotwordService::DoesHotwordSupportLanguage(profile_); |
| 603 } | 606 } |
| OLD | NEW |