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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 382 |
383 bool HotwordService::IsServiceAvailable() { | 383 bool HotwordService::IsServiceAvailable() { |
384 error_message_ = 0; | 384 error_message_ = 0; |
385 | 385 |
386 // Determine if the extension is available. | 386 // Determine if the extension is available. |
387 extensions::ExtensionSystem* system = | 387 extensions::ExtensionSystem* system = |
388 extensions::ExtensionSystem::Get(profile_); | 388 extensions::ExtensionSystem::Get(profile_); |
389 ExtensionService* service = system->extension_service(); | 389 ExtensionService* service = system->extension_service(); |
390 // Include disabled extensions (true parameter) since it may not be enabled | 390 // Include disabled extensions (true parameter) since it may not be enabled |
391 // if the user opted out. | 391 // if the user opted out. |
| 392 std::string extensionId; |
| 393 if (IsExperimentalHotwordingEnabled()) { |
| 394 // TODO(amistry): Handle reloading on language change as the old extension |
| 395 // does. |
| 396 extensionId = extension_misc::kHotwordSharedModuleId; |
| 397 } else { |
| 398 extensionId = extension_misc::kHotwordExtensionId; |
| 399 } |
392 const extensions::Extension* extension = | 400 const extensions::Extension* extension = |
393 service->GetExtensionById(extension_misc::kHotwordExtensionId, true); | 401 service->GetExtensionById(extensionId, true); |
394 if (!extension) | 402 if (!extension) |
395 error_message_ = IDS_HOTWORD_GENERIC_ERROR_MESSAGE; | 403 error_message_ = IDS_HOTWORD_GENERIC_ERROR_MESSAGE; |
396 | 404 |
397 RecordExtensionAvailabilityMetrics(service, extension); | 405 RecordExtensionAvailabilityMetrics(service, extension); |
398 RecordLoggingMetrics(profile_); | 406 RecordLoggingMetrics(profile_); |
399 | 407 |
400 // Determine if NaCl is available. | 408 // Determine if NaCl is available. |
401 bool nacl_enabled = false; | 409 bool nacl_enabled = false; |
402 base::FilePath path; | 410 base::FilePath path; |
403 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { | 411 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 return false; | 525 return false; |
518 | 526 |
519 std::string previous_locale = | 527 std::string previous_locale = |
520 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); | 528 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); |
521 std::string locale = GetCurrentLocale(profile_); | 529 std::string locale = GetCurrentLocale(profile_); |
522 | 530 |
523 // If it's a new locale, then the old extension should be uninstalled. | 531 // If it's a new locale, then the old extension should be uninstalled. |
524 return locale != previous_locale && | 532 return locale != previous_locale && |
525 HotwordService::DoesHotwordSupportLanguage(profile_); | 533 HotwordService::DoesHotwordSupportLanguage(profile_); |
526 } | 534 } |
OLD | NEW |