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" | |
25 #include "chrome/browser/ui/extensions/application_launch.h" | 24 #include "chrome/browser/ui/extensions/application_launch.h" |
26 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
27 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/extensions/extension_constants.h" | 27 #include "chrome/common/extensions/extension_constants.h" |
29 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
30 #include "chrome/grit/generated_resources.h" | 29 #include "chrome/grit/generated_resources.h" |
31 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/plugin_service.h" | 32 #include "content/public/browser/plugin_service.h" |
34 #include "content/public/common/webplugininfo.h" | 33 #include "content/public/common/webplugininfo.h" |
35 #include "extensions/browser/extension_system.h" | 34 #include "extensions/browser/extension_system.h" |
36 #include "extensions/browser/uninstall_reason.h" | 35 #include "extensions/browser/uninstall_reason.h" |
37 #include "extensions/common/constants.h" | |
38 #include "extensions/common/extension.h" | 36 #include "extensions/common/extension.h" |
39 #include "extensions/common/one_shot_event.h" | 37 #include "extensions/common/one_shot_event.h" |
40 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
41 | 39 |
42 using extensions::BrowserContextKeyedAPIFactory; | 40 using extensions::BrowserContextKeyedAPIFactory; |
43 using extensions::HotwordPrivateEventService; | 41 using extensions::HotwordPrivateEventService; |
44 | 42 |
45 namespace { | 43 namespace { |
46 | 44 |
47 // Allowed languages for hotwording. | 45 // Allowed languages for hotwording. |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 hotword_audio_verification_launch_mode_ = launch_mode; | 490 hotword_audio_verification_launch_mode_ = launch_mode; |
493 | 491 |
494 ExtensionService* extension_service = GetExtensionService(profile_); | 492 ExtensionService* extension_service = GetExtensionService(profile_); |
495 if (!extension_service) | 493 if (!extension_service) |
496 return; | 494 return; |
497 const extensions::Extension* extension = extension_service->GetExtensionById( | 495 const extensions::Extension* extension = extension_service->GetExtensionById( |
498 extension_misc::kHotwordAudioVerificationAppId, true); | 496 extension_misc::kHotwordAudioVerificationAppId, true); |
499 if (!extension) | 497 if (!extension) |
500 return; | 498 return; |
501 | 499 |
502 OpenApplication( | 500 OpenApplication(AppLaunchParams( |
503 AppLaunchParams(profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, | 501 profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); |
504 NEW_WINDOW, extensions::SOURCE_CHROME_INTERNAL)); | |
505 } | 502 } |
506 | 503 |
507 HotwordService::LaunchMode | 504 HotwordService::LaunchMode |
508 HotwordService::GetHotwordAudioVerificationLaunchMode() { | 505 HotwordService::GetHotwordAudioVerificationLaunchMode() { |
509 return hotword_audio_verification_launch_mode_; | 506 return hotword_audio_verification_launch_mode_; |
510 } | 507 } |
511 | 508 |
512 void HotwordService::StartTraining() { | 509 void HotwordService::StartTraining() { |
513 training_ = true; | 510 training_ = true; |
514 | 511 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 return false; | 605 return false; |
609 | 606 |
610 std::string previous_locale = | 607 std::string previous_locale = |
611 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); | 608 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); |
612 std::string locale = GetCurrentLocale(profile_); | 609 std::string locale = GetCurrentLocale(profile_); |
613 | 610 |
614 // If it's a new locale, then the old extension should be uninstalled. | 611 // If it's a new locale, then the old extension should be uninstalled. |
615 return locale != previous_locale && | 612 return locale != previous_locale && |
616 HotwordService::DoesHotwordSupportLanguage(profile_); | 613 HotwordService::DoesHotwordSupportLanguage(profile_); |
617 } | 614 } |
OLD | NEW |