• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 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_policy_loader.h"
6 
7 #include "base/strings/stringprintf.h"
8 #include "base/values.h"
9 #include "chrome/browser/extensions/external_provider_impl.h"
10 
11 namespace extensions {
12 
ExternalPolicyLoader(ExtensionManagement * settings)13 ExternalPolicyLoader::ExternalPolicyLoader(ExtensionManagement *settings)
14     : settings_(settings) {
15   settings_->AddObserver(this);
16 }
17 
~ExternalPolicyLoader()18 ExternalPolicyLoader::~ExternalPolicyLoader() {
19   settings_->RemoveObserver(this);
20 }
21 
OnExtensionManagementSettingsChanged()22 void ExternalPolicyLoader::OnExtensionManagementSettingsChanged() {
23   StartLoading();
24 }
25 
26 // static
AddExtension(base::DictionaryValue * dict,const std::string & extension_id,const std::string & update_url)27 void ExternalPolicyLoader::AddExtension(base::DictionaryValue* dict,
28                                         const std::string& extension_id,
29                                         const std::string& update_url) {
30   dict->SetString(base::StringPrintf("%s.%s", extension_id.c_str(),
31                                      ExternalProviderImpl::kExternalUpdateUrl),
32                   update_url);
33 }
34 
StartLoading()35 void ExternalPolicyLoader::StartLoading() {
36   prefs_ = settings_->GetForceInstallList();
37   LoadFinished();
38 }
39 
40 }  // namespace extensions
41