• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/extensions/external_component_loader.h"
6 
7 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.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"
11 #include "chrome/common/extensions/extension_constants.h"
12 #include "components/signin/core/browser/signin_manager.h"
13 
14 namespace {
15 
IsUserSignedin(Profile * profile)16 bool IsUserSignedin(Profile* profile) {
17   SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile);
18   return signin && !signin->GetAuthenticatedUsername().empty();
19 }
20 
21 }  // namespace
22 
23 namespace extensions {
24 
ExternalComponentLoader(Profile * profile)25 ExternalComponentLoader::ExternalComponentLoader(Profile* profile)
26     : profile_(profile) {
27 }
28 
~ExternalComponentLoader()29 ExternalComponentLoader::~ExternalComponentLoader() {}
30 
StartLoading()31 void ExternalComponentLoader::StartLoading() {
32   prefs_.reset(new base::DictionaryValue());
33   std::string appId = extension_misc::kInAppPaymentsSupportAppId;
34   prefs_->SetString(appId + ".external_update_url",
35                     extension_urls::GetWebstoreUpdateUrl().spec());
36 
37   if (HotwordServiceFactory::IsHotwordAllowed(profile_)) {
38     std::string hotwordId = extension_misc::kHotwordExtensionId;
39     prefs_->SetString(hotwordId + ".external_update_url",
40                       extension_urls::GetWebstoreUpdateUrl().spec());
41   }
42 
43   UpdateBookmarksExperimentState(
44       profile_->GetPrefs(),
45       g_browser_process->local_state(),
46       IsUserSignedin(profile_),
47       BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN);
48   std::string ext_id;
49   if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) &&
50       !ext_id.empty()) {
51     prefs_->SetString(ext_id + ".external_update_url",
52                       extension_urls::GetWebstoreUpdateUrl().spec());
53   }
54 
55   LoadFinished();
56 }
57 
58 }  // namespace extensions
59