| 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/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 // change so it's okay to reinstall. | 353 // change so it's okay to reinstall. |
| 354 reinstall_pending_ = true; | 354 reinstall_pending_ = true; |
| 355 | 355 |
| 356 return UninstallHotwordExtension(extension_service); | 356 return UninstallHotwordExtension(extension_service); |
| 357 } | 357 } |
| 358 | 358 |
| 359 bool HotwordService::UninstallHotwordExtension( | 359 bool HotwordService::UninstallHotwordExtension( |
| 360 ExtensionService* extension_service) { | 360 ExtensionService* extension_service) { |
| 361 base::string16 error; | 361 base::string16 error; |
| 362 if (!extension_service->UninstallExtension( | 362 if (!extension_service->UninstallExtension( |
| 363 extension_misc::kHotwordExtensionId, | 363 extension_misc::kHotwordExtensionId, true, &error)) { |
| 364 ExtensionService::UNINSTALL_REASON_INTERNAL_MANAGEMENT, | |
| 365 &error)) { | |
| 366 LOG(WARNING) << "Cannot uninstall extension with id " | 364 LOG(WARNING) << "Cannot uninstall extension with id " |
| 367 << extension_misc::kHotwordExtensionId | 365 << extension_misc::kHotwordExtensionId |
| 368 << ": " << error; | 366 << ": " << error; |
| 369 reinstall_pending_ = false; | 367 reinstall_pending_ = false; |
| 370 return false; | 368 return false; |
| 371 } | 369 } |
| 372 return true; | 370 return true; |
| 373 } | 371 } |
| 374 | 372 |
| 375 bool HotwordService::IsServiceAvailable() { | 373 bool HotwordService::IsServiceAvailable() { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 return false; | 497 return false; |
| 500 | 498 |
| 501 std::string previous_locale = | 499 std::string previous_locale = |
| 502 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); | 500 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); |
| 503 std::string locale = GetCurrentLocale(profile_); | 501 std::string locale = GetCurrentLocale(profile_); |
| 504 | 502 |
| 505 // If it's a new locale, then the old extension should be uninstalled. | 503 // If it's a new locale, then the old extension should be uninstalled. |
| 506 return locale != previous_locale && | 504 return locale != previous_locale && |
| 507 HotwordService::DoesHotwordSupportLanguage(profile_); | 505 HotwordService::DoesHotwordSupportLanguage(profile_); |
| 508 } | 506 } |
| OLD | NEW |