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

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

Issue 423083002: Add new hotword extension for built-in hotword triggering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 4 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
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 "chrome/browser/bookmarks/enhanced_bookmarks_features.h" 8 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h"
8 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/search/hotword_service_factory.h"
10 #include "chrome/browser/signin/signin_manager_factory.h" 10 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/extensions/extension_constants.h" 12 #include "chrome/common/extensions/extension_constants.h"
12 #include "components/signin/core/browser/signin_manager.h" 13 #include "components/signin/core/browser/signin_manager.h"
13 14
15 // TODO(thestig): Remove after extensions are disabled on mobile.
16 #if defined(ENABLE_EXTENSIONS)
17 #include "chrome/browser/search/hotword_service_factory.h"
18 #endif
19
14 namespace { 20 namespace {
15 21
16 bool IsUserSignedin(Profile* profile) { 22 bool IsUserSignedin(Profile* profile) {
17 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); 23 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile);
18 return signin && !signin->GetAuthenticatedUsername().empty(); 24 return signin && !signin->GetAuthenticatedUsername().empty();
19 } 25 }
20 26
21 } // namespace 27 } // namespace
22 28
23 namespace extensions { 29 namespace extensions {
24 30
25 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) 31 ExternalComponentLoader::ExternalComponentLoader(Profile* profile)
26 : profile_(profile) { 32 : profile_(profile) {
27 } 33 }
28 34
29 ExternalComponentLoader::~ExternalComponentLoader() {} 35 ExternalComponentLoader::~ExternalComponentLoader() {}
30 36
31 void ExternalComponentLoader::StartLoading() { 37 void ExternalComponentLoader::StartLoading() {
32 prefs_.reset(new base::DictionaryValue()); 38 prefs_.reset(new base::DictionaryValue());
33 std::string appId = extension_misc::kInAppPaymentsSupportAppId; 39 std::string appId = extension_misc::kInAppPaymentsSupportAppId;
34 prefs_->SetString(appId + ".external_update_url", 40 prefs_->SetString(appId + ".external_update_url",
35 extension_urls::GetWebstoreUpdateUrl().spec()); 41 extension_urls::GetWebstoreUpdateUrl().spec());
36 42
43 #if defined(ENABLE_EXTENSIONS)
37 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) { 44 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) {
38 std::string hotwordId = extension_misc::kHotwordExtensionId; 45 std::string hotwordId = extension_misc::kHotwordExtensionId;
39 prefs_->SetString(hotwordId + ".external_update_url", 46 CommandLine* command_line = CommandLine::ForCurrentProcess();
40 extension_urls::GetWebstoreUpdateUrl().spec()); 47 // TODO(amistry): Load the hotword shared module when enabling built-in
48 // hotword detection.
49 if (!command_line->HasSwitch(switches::kEnableExperimentalHotwording)) {
50 prefs_->SetString(hotwordId + ".external_update_url",
51 extension_urls::GetWebstoreUpdateUrl().spec());
52 }
41 } 53 }
54 #endif
42 55
43 UpdateBookmarksExperimentState( 56 UpdateBookmarksExperimentState(
44 profile_->GetPrefs(), 57 profile_->GetPrefs(),
45 g_browser_process->local_state(), 58 g_browser_process->local_state(),
46 IsUserSignedin(profile_), 59 IsUserSignedin(profile_),
47 BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN); 60 BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN);
48 std::string ext_id; 61 std::string ext_id;
49 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && 62 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) &&
50 !ext_id.empty()) { 63 !ext_id.empty()) {
51 prefs_->SetString(ext_id + ".external_update_url", 64 prefs_->SetString(ext_id + ".external_update_url",
52 extension_urls::GetWebstoreUpdateUrl().spec()); 65 extension_urls::GetWebstoreUpdateUrl().spec());
53 } 66 }
54 67
55 LoadFinished(); 68 LoadFinished();
56 } 69 }
57 70
58 } // namespace extensions 71 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/component_loader.cc ('k') | chrome/browser/resources/component_extension_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698