Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/extensions/external_component_loader.h" | 5 #include "chrome/browser/extensions/external_component_loader.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/i18n/case_conversion.h" | |
| 9 #include "base/metrics/field_trial.h" | |
| 8 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
| 9 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 10 #include "base/values.h" | 12 #include "base/values.h" |
| 11 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | 13 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
| 12 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/extensions/external_provider_impl.h" | 15 #include "chrome/browser/extensions/external_provider_impl.h" |
| 14 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 16 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 17 #include "components/user_prefs/pref_registry_syncable.h" | 19 #include "components/user_prefs/pref_registry_syncable.h" |
| 18 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | |
| 19 | 22 |
| 20 namespace extensions { | 23 namespace extensions { |
| 21 | 24 |
| 22 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
| 23 namespace { | 26 namespace { |
| 24 // Table mapping language codes to the extension ids of high-quality | 27 // Table mapping language codes to the extension ids of high-quality |
| 25 // speech synthesis extensions. See the comment in StartLoading() for more. | 28 // speech synthesis extensions. See the comment in StartLoading() for more. |
| 26 struct LangToExtensionId { | 29 struct LangToExtensionId { |
| 27 const char* lang; | 30 const char* lang; |
| 28 const char* extension_id; | 31 const char* extension_id; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 51 | 54 |
| 52 ExternalComponentLoader::~ExternalComponentLoader() {} | 55 ExternalComponentLoader::~ExternalComponentLoader() {} |
| 53 | 56 |
| 54 void ExternalComponentLoader::StartLoading() { | 57 void ExternalComponentLoader::StartLoading() { |
| 55 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 58 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 56 prefs_.reset(new base::DictionaryValue()); | 59 prefs_.reset(new base::DictionaryValue()); |
| 57 std::string appId = extension_misc::kInAppPaymentsSupportAppId; | 60 std::string appId = extension_misc::kInAppPaymentsSupportAppId; |
| 58 prefs_->SetString(appId + ".external_update_url", | 61 prefs_->SetString(appId + ".external_update_url", |
| 59 extension_urls::GetWebstoreUpdateUrl().spec()); | 62 extension_urls::GetWebstoreUpdateUrl().spec()); |
| 60 | 63 |
| 64 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger"); | |
| 65 std::string locale = | |
| 66 #if defined(OS_CHROMEOS) | |
| 67 // On ChromeOS locale is per-profile. | |
| 68 profile_->GetPrefs()->GetString(prefs::kApplicationLocale); | |
| 69 #else | |
| 70 g_browser_process->GetApplicationLocale(); | |
| 71 #endif | |
|
asargent_no_longer_on_chrome
2014/01/30 00:22:56
optional: would it make sense to have a common met
rpetterson
2014/01/30 00:46:09
Yes, I actually have plans to do this in another C
| |
| 72 // Only available for English now. | |
| 73 std::string normalized_locale = l10n_util::NormalizeLocale(locale); | |
| 74 bool locale_available = | |
| 75 !(strcmp(normalized_locale.c_str(), "en")) || | |
| 76 !(strcmp(normalized_locale.c_str(), "en_us")) || | |
| 77 !(strcmp(normalized_locale.c_str(), "en_US")); | |
|
asargent_no_longer_on_chrome
2014/01/30 00:22:56
optional: consider using base::EqualsASCII for the
rpetterson
2014/01/30 00:46:09
That's correct. We only want the ones listed at th
| |
| 78 if (group != "" && group != "Disabled" && locale_available) { | |
|
asargent_no_longer_on_chrome
2014/01/30 00:22:56
optional: consider using
!group.empty()
inst
rpetterson
2014/01/30 00:46:09
Done.
| |
| 79 std::string hotwordId = extension_misc::kHotwordExtensionId; | |
| 80 prefs_->SetString(hotwordId + ".external_update_url", | |
| 81 extension_urls::GetWebstoreUpdateUrl().spec()); | |
| 82 } | |
| 83 | |
| 61 if (CommandLine::ForCurrentProcess()-> | 84 if (CommandLine::ForCurrentProcess()-> |
| 62 GetSwitchValueASCII(switches::kEnableEnhancedBookmarks) != "0") { | 85 GetSwitchValueASCII(switches::kEnableEnhancedBookmarks) != "0") { |
| 63 std::string ext_id = GetEnhancedBookmarksExtensionId(); | 86 std::string ext_id = GetEnhancedBookmarksExtensionId(); |
| 64 if (!ext_id.empty()) { | 87 if (!ext_id.empty()) { |
| 65 prefs_->SetString(ext_id + ".external_update_url", | 88 prefs_->SetString(ext_id + ".external_update_url", |
| 66 extension_urls::GetWebstoreUpdateUrl().spec()); | 89 extension_urls::GetWebstoreUpdateUrl().spec()); |
| 67 } | 90 } |
| 68 } | 91 } |
| 69 | 92 |
| 70 #if defined(OS_CHROMEOS) | 93 #if defined(OS_CHROMEOS) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 // static | 127 // static |
| 105 void ExternalComponentLoader::RegisterProfilePrefs( | 128 void ExternalComponentLoader::RegisterProfilePrefs( |
| 106 user_prefs::PrefRegistrySyncable* registry) { | 129 user_prefs::PrefRegistrySyncable* registry) { |
| 107 #if defined(OS_CHROMEOS) | 130 #if defined(OS_CHROMEOS) |
| 108 registry->RegisterListPref(prefs::kHighQualitySpeechSynthesisLanguages, | 131 registry->RegisterListPref(prefs::kHighQualitySpeechSynthesisLanguages, |
| 109 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 132 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 110 #endif | 133 #endif |
| 111 } | 134 } |
| 112 | 135 |
| 113 } // namespace extensions | 136 } // namespace extensions |
| OLD | NEW |