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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 hotword_audio_verification_launch_mode_ = launch_mode; | 482 hotword_audio_verification_launch_mode_ = launch_mode; |
481 | 483 |
482 ExtensionService* extension_service = GetExtensionService(profile_); | 484 ExtensionService* extension_service = GetExtensionService(profile_); |
483 if (!extension_service) | 485 if (!extension_service) |
484 return; | 486 return; |
485 const extensions::Extension* extension = extension_service->GetExtensionById( | 487 const extensions::Extension* extension = extension_service->GetExtensionById( |
486 extension_misc::kHotwordAudioVerificationAppId, true); | 488 extension_misc::kHotwordAudioVerificationAppId, true); |
487 if (!extension) | 489 if (!extension) |
488 return; | 490 return; |
489 | 491 |
490 OpenApplication(AppLaunchParams( | 492 OpenApplication( |
491 profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); | 493 AppLaunchParams(profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, |
| 494 NEW_WINDOW, extensions::SOURCE_CHROME_INTERNAL)); |
492 } | 495 } |
493 | 496 |
494 HotwordService::LaunchMode | 497 HotwordService::LaunchMode |
495 HotwordService::GetHotwordAudioVerificationLaunchMode() { | 498 HotwordService::GetHotwordAudioVerificationLaunchMode() { |
496 return hotword_audio_verification_launch_mode_; | 499 return hotword_audio_verification_launch_mode_; |
497 } | 500 } |
498 | 501 |
499 void HotwordService::StartTraining() { | 502 void HotwordService::StartTraining() { |
500 training_ = true; | 503 training_ = true; |
501 | 504 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 return false; | 598 return false; |
596 | 599 |
597 std::string previous_locale = | 600 std::string previous_locale = |
598 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); | 601 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); |
599 std::string locale = GetCurrentLocale(profile_); | 602 std::string locale = GetCurrentLocale(profile_); |
600 | 603 |
601 // If it's a new locale, then the old extension should be uninstalled. | 604 // If it's a new locale, then the old extension should be uninstalled. |
602 return locale != previous_locale && | 605 return locale != previous_locale && |
603 HotwordService::DoesHotwordSupportLanguage(profile_); | 606 HotwordService::DoesHotwordSupportLanguage(profile_); |
604 } | 607 } |
OLD | NEW |