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.
5 #include "chrome/browser/extensions/external_component_loader.h"
7 #include "base/command_line.h"
8 #include "base/prefs/pref_change_registrar.h"
9 #include "base/prefs/pref_service.h"
10 #include "base/values.h"
11 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h"
12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/extensions/external_provider_impl.h"
14 #include "chrome/browser/search/hotword_service_factory.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/extensions/extension_constants.h"
17 #include "chrome/common/pref_names.h"
18 #include "components/user_prefs/pref_registry_syncable.h"
19 #include "content/public/browser/browser_thread.h"
21 namespace extensions {
23 ExternalComponentLoader::ExternalComponentLoader(Profile* profile)
27 ExternalComponentLoader::~ExternalComponentLoader() {}
29 void ExternalComponentLoader::StartLoading() {
30 prefs_.reset(new base::DictionaryValue());
31 std::string appId = extension_misc::kInAppPaymentsSupportAppId;
32 prefs_->SetString(appId + ".external_update_url",
33 extension_urls::GetWebstoreUpdateUrl().spec());
35 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) {
36 std::string hotwordId = extension_misc::kHotwordExtensionId;
37 prefs_->SetString(hotwordId + ".external_update_url",
38 extension_urls::GetWebstoreUpdateUrl().spec());
41 if (CommandLine::ForCurrentProcess()->
42 GetSwitchValueASCII(switches::kEnableEnhancedBookmarks) != "0") {
44 if (profile_->GetPrefs()->GetBoolean(
45 prefs::kEnhancedBookmarksExperimentEnabled)) {
47 profile_->GetPrefs()->GetString(prefs::kEnhancedBookmarksExtensionId);
49 ext_id = GetEnhancedBookmarksExtensionIdFromFinch();
51 if (!ext_id.empty()) {
52 prefs_->SetString(ext_id + ".external_update_url",
53 extension_urls::GetWebstoreUpdateUrl().spec());
56 profile_->GetPrefs()->ClearPref(prefs::kEnhancedBookmarksExperimentEnabled);
57 profile_->GetPrefs()->ClearPref(prefs::kEnhancedBookmarksExtensionId);
62 } // namespace extensions