OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_policy_loader.h" | 5 #include "chrome/browser/extensions/external_policy_loader.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/external_provider_impl.h" | 9 #include "chrome/browser/extensions/external_provider_impl.h" |
10 | 10 |
11 namespace extensions { | 11 namespace extensions { |
12 | 12 |
13 ExternalPolicyLoader::ExternalPolicyLoader(ExtensionManagement *settings) | 13 ExternalPolicyLoader::ExternalPolicyLoader(ExtensionManagement* settings, |
14 : settings_(settings) { | 14 InstallationType type) |
15 : settings_(settings), type_(type) { | |
15 settings_->AddObserver(this); | 16 settings_->AddObserver(this); |
16 } | 17 } |
17 | 18 |
18 ExternalPolicyLoader::~ExternalPolicyLoader() { | 19 ExternalPolicyLoader::~ExternalPolicyLoader() { |
19 settings_->RemoveObserver(this); | 20 settings_->RemoveObserver(this); |
20 } | 21 } |
21 | 22 |
22 void ExternalPolicyLoader::OnExtensionManagementSettingsChanged() { | 23 void ExternalPolicyLoader::OnExtensionManagementSettingsChanged() { |
23 StartLoading(); | 24 StartLoading(); |
24 } | 25 } |
25 | 26 |
26 // static | 27 // static |
27 void ExternalPolicyLoader::AddExtension(base::DictionaryValue* dict, | 28 void ExternalPolicyLoader::AddExtension(base::DictionaryValue* dict, |
28 const std::string& extension_id, | 29 const std::string& extension_id, |
29 const std::string& update_url) { | 30 const std::string& update_url) { |
30 dict->SetString(base::StringPrintf("%s.%s", extension_id.c_str(), | 31 dict->SetString(base::StringPrintf("%s.%s", extension_id.c_str(), |
31 ExternalProviderImpl::kExternalUpdateUrl), | 32 ExternalProviderImpl::kExternalUpdateUrl), |
32 update_url); | 33 update_url); |
33 } | 34 } |
34 | 35 |
35 void ExternalPolicyLoader::StartLoading() { | 36 void ExternalPolicyLoader::StartLoading() { |
36 prefs_ = settings_->GetForceInstallList(); | 37 if (type_ == FORCED) |
38 prefs_ = settings_->GetForceInstallList(); | |
39 else // type_ == RECOMMENDED | |
40 prefs_ = settings_->GetRecommendedInstallList(); | |
Finnur
2014/10/06 14:01:42
I usually prefer a switch with no default: case fo
binjin
2014/10/06 18:48:47
Done.
| |
37 LoadFinished(); | 41 LoadFinished(); |
38 } | 42 } |
39 | 43 |
40 } // namespace extensions | 44 } // namespace extensions |
OLD | NEW |