| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 extension_misc::kHotwordExtensionId, | 278 extension_misc::kHotwordExtensionId, |
| 279 profile_, | 279 profile_, |
| 280 false, | 280 false, |
| 281 extensions::WebstoreStandaloneInstaller::Callback()); | 281 extensions::WebstoreStandaloneInstaller::Callback()); |
| 282 installer_->BeginInstall(); | 282 installer_->BeginInstall(); |
| 283 #endif | 283 #endif |
| 284 } | 284 } |
| 285 | 285 |
| 286 void HotwordService::OnExtensionInstalled( | 286 void HotwordService::OnExtensionInstalled( |
| 287 content::BrowserContext* browser_context, | 287 content::BrowserContext* browser_context, |
| 288 const extensions::Extension* extension) { | 288 const extensions::Extension* extension, |
| 289 bool is_update) { |
| 289 | 290 |
| 290 if (extension->id() != extension_misc::kHotwordExtensionId || | 291 if (extension->id() != extension_misc::kHotwordExtensionId || |
| 291 profile_ != Profile::FromBrowserContext(browser_context)) | 292 profile_ != Profile::FromBrowserContext(browser_context)) |
| 292 return; | 293 return; |
| 293 | 294 |
| 294 // If the previous locale pref has never been set, set it now since | 295 // If the previous locale pref has never been set, set it now since |
| 295 // the extension has been installed. | 296 // the extension has been installed. |
| 296 if (!profile_->GetPrefs()->HasPrefPath(prefs::kHotwordPreviousLanguage)) | 297 if (!profile_->GetPrefs()->HasPrefPath(prefs::kHotwordPreviousLanguage)) |
| 297 SetPreviousLanguagePref(); | 298 SetPreviousLanguagePref(); |
| 298 | 299 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 return false; | 500 return false; |
| 500 | 501 |
| 501 std::string previous_locale = | 502 std::string previous_locale = |
| 502 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); | 503 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage); |
| 503 std::string locale = GetCurrentLocale(profile_); | 504 std::string locale = GetCurrentLocale(profile_); |
| 504 | 505 |
| 505 // If it's a new locale, then the old extension should be uninstalled. | 506 // If it's a new locale, then the old extension should be uninstalled. |
| 506 return locale != previous_locale && | 507 return locale != previous_locale && |
| 507 HotwordService::DoesHotwordSupportLanguage(profile_); | 508 HotwordService::DoesHotwordSupportLanguage(profile_); |
| 508 } | 509 } |
| OLD | NEW |