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 "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | 7 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/search/hotword_service_factory.h" | |
10 #include "chrome/browser/signin/signin_manager_factory.h" | 9 #include "chrome/browser/signin/signin_manager_factory.h" |
11 #include "chrome/common/extensions/extension_constants.h" | 10 #include "chrome/common/extensions/extension_constants.h" |
12 #include "components/signin/core/browser/signin_manager.h" | 11 #include "components/signin/core/browser/signin_manager.h" |
13 | 12 |
| 13 // TODO(thestig): Remove after extensions are disabled on mobile. |
| 14 #if defined(ENABLE_EXTENSIONS) |
| 15 #include "chrome/browser/search/hotword_service_factory.h" |
| 16 #endif |
| 17 |
14 namespace { | 18 namespace { |
15 | 19 |
16 bool IsUserSignedin(Profile* profile) { | 20 bool IsUserSignedin(Profile* profile) { |
17 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); | 21 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
18 return signin && !signin->GetAuthenticatedUsername().empty(); | 22 return signin && !signin->GetAuthenticatedUsername().empty(); |
19 } | 23 } |
20 | 24 |
21 } // namespace | 25 } // namespace |
22 | 26 |
23 namespace extensions { | 27 namespace extensions { |
24 | 28 |
25 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) | 29 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) |
26 : profile_(profile) { | 30 : profile_(profile) { |
27 } | 31 } |
28 | 32 |
29 ExternalComponentLoader::~ExternalComponentLoader() {} | 33 ExternalComponentLoader::~ExternalComponentLoader() {} |
30 | 34 |
31 void ExternalComponentLoader::StartLoading() { | 35 void ExternalComponentLoader::StartLoading() { |
32 prefs_.reset(new base::DictionaryValue()); | 36 prefs_.reset(new base::DictionaryValue()); |
33 std::string appId = extension_misc::kInAppPaymentsSupportAppId; | 37 std::string appId = extension_misc::kInAppPaymentsSupportAppId; |
34 prefs_->SetString(appId + ".external_update_url", | 38 prefs_->SetString(appId + ".external_update_url", |
35 extension_urls::GetWebstoreUpdateUrl().spec()); | 39 extension_urls::GetWebstoreUpdateUrl().spec()); |
36 | 40 |
| 41 #if defined(ENABLE_EXTENSIONS) |
37 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) { | 42 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) { |
38 std::string hotwordId = extension_misc::kHotwordExtensionId; | 43 std::string hotwordId = extension_misc::kHotwordExtensionId; |
39 prefs_->SetString(hotwordId + ".external_update_url", | 44 prefs_->SetString(hotwordId + ".external_update_url", |
40 extension_urls::GetWebstoreUpdateUrl().spec()); | 45 extension_urls::GetWebstoreUpdateUrl().spec()); |
41 } | 46 } |
| 47 #endif |
42 | 48 |
43 UpdateBookmarksExperimentState( | 49 UpdateBookmarksExperimentState( |
44 profile_->GetPrefs(), | 50 profile_->GetPrefs(), |
45 g_browser_process->local_state(), | 51 g_browser_process->local_state(), |
46 IsUserSignedin(profile_), | 52 IsUserSignedin(profile_), |
47 BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN); | 53 BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN); |
48 std::string ext_id; | 54 std::string ext_id; |
49 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && | 55 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && |
50 !ext_id.empty()) { | 56 !ext_id.empty()) { |
51 prefs_->SetString(ext_id + ".external_update_url", | 57 prefs_->SetString(ext_id + ".external_update_url", |
52 extension_urls::GetWebstoreUpdateUrl().spec()); | 58 extension_urls::GetWebstoreUpdateUrl().spec()); |
53 } | 59 } |
54 | 60 |
55 LoadFinished(); | 61 LoadFinished(); |
56 } | 62 } |
57 | 63 |
58 } // namespace extensions | 64 } // namespace extensions |
OLD | NEW |