Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1055)

Side by Side Diff: chrome/browser/extensions/external_component_loader.cc

Issue 141013015: [Hotword] Set up hotwording to be externally loaded component extension. Only load if the field tri… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: removing changes that snuck in Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (!group.empty() && group != "Disabled") {
66 std::string locale =
67 #if defined(OS_CHROMEOS)
68 // On ChromeOS locale is per-profile.
69 profile_->GetPrefs()->GetString(prefs::kApplicationLocale);
70 #else
71 g_browser_process->GetApplicationLocale();
72 #endif
73 // Only available for English now.
74 std::string normalized_locale = l10n_util::NormalizeLocale(locale);
75 if (!(strcmp(normalized_locale.c_str(), "en")) ||
76 !(strcmp(normalized_locale.c_str(), "en_us")) ||
77 !(strcmp(normalized_locale.c_str(), "en_US"))) {
78 std::string hotwordId = extension_misc::kHotwordExtensionId;
79 prefs_->SetString(hotwordId + ".external_update_url",
80 extension_urls::GetWebstoreUpdateUrl().spec());
81 }
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
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
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698