Chromium Code Reviews| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 default: | 133 default: |
| 134 error = NO_HOTWORD_ERROR; | 134 error = NO_HOTWORD_ERROR; |
| 135 } | 135 } |
| 136 | 136 |
| 137 UMA_HISTOGRAM_ENUMERATION("Hotword.HotwordError", | 137 UMA_HISTOGRAM_ENUMERATION("Hotword.HotwordError", |
| 138 error, | 138 error, |
| 139 NUM_HOTWORD_ERROR_METRICS); | 139 NUM_HOTWORD_ERROR_METRICS); |
| 140 } | 140 } |
| 141 | 141 |
| 142 ExtensionService* GetExtensionService(Profile* profile) { | 142 ExtensionService* GetExtensionService(Profile* profile) { |
| 143 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 143 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
|
Devlin
2014/06/25 19:38:48
nit: I think we have a DCHECK_CURRENTLY_ON now.
| |
| 144 | 144 |
| 145 extensions::ExtensionSystem* extension_system = | 145 extensions::ExtensionSystem* extension_system = |
| 146 extensions::ExtensionSystem::Get(profile); | 146 extensions::ExtensionSystem::Get(profile); |
| 147 if (extension_system) | 147 return extension_system ? extension_system->extension_service() : NULL; |
| 148 return extension_system->extension_service(); | |
| 149 return NULL; | |
| 150 } | 148 } |
| 151 | 149 |
| 152 std::string GetCurrentLocale(Profile* profile) { | 150 std::string GetCurrentLocale(Profile* profile) { |
| 153 std::string locale = | 151 std::string locale = |
| 154 #if defined(OS_CHROMEOS) | 152 #if defined(OS_CHROMEOS) |
| 155 // On ChromeOS locale is per-profile. | 153 // On ChromeOS locale is per-profile. |
| 156 profile->GetPrefs()->GetString(prefs::kApplicationLocale); | 154 profile->GetPrefs()->GetString(prefs::kApplicationLocale); |
| 157 #else | 155 #else |
| 158 g_browser_process->GetApplicationLocale(); | 156 g_browser_process->GetApplicationLocale(); |
| 159 #endif | 157 #endif |
| (...skipping 339 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 |