Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: chrome/browser/extensions/external_policy_loader.cc

Issue 536753003: Add recommended extension installation support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ext-3
Patch Set: more fixes Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/logging.h"
7 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
8 #include "base/values.h" 9 #include "base/values.h"
9 #include "chrome/browser/extensions/external_provider_impl.h" 10 #include "chrome/browser/extensions/external_provider_impl.h"
10 11
11 namespace extensions { 12 namespace extensions {
12 13
13 ExternalPolicyLoader::ExternalPolicyLoader(ExtensionManagement *settings) 14 ExternalPolicyLoader::ExternalPolicyLoader(ExtensionManagement* settings,
14 : settings_(settings) { 15 InstallationType type)
16 : settings_(settings), type_(type) {
15 settings_->AddObserver(this); 17 settings_->AddObserver(this);
16 } 18 }
17 19
18 ExternalPolicyLoader::~ExternalPolicyLoader() { 20 ExternalPolicyLoader::~ExternalPolicyLoader() {
19 settings_->RemoveObserver(this); 21 settings_->RemoveObserver(this);
20 } 22 }
21 23
22 void ExternalPolicyLoader::OnExtensionManagementSettingsChanged() { 24 void ExternalPolicyLoader::OnExtensionManagementSettingsChanged() {
23 StartLoading(); 25 StartLoading();
24 } 26 }
25 27
26 // static 28 // static
27 void ExternalPolicyLoader::AddExtension(base::DictionaryValue* dict, 29 void ExternalPolicyLoader::AddExtension(base::DictionaryValue* dict,
28 const std::string& extension_id, 30 const std::string& extension_id,
29 const std::string& update_url) { 31 const std::string& update_url) {
30 dict->SetString(base::StringPrintf("%s.%s", extension_id.c_str(), 32 dict->SetString(base::StringPrintf("%s.%s", extension_id.c_str(),
31 ExternalProviderImpl::kExternalUpdateUrl), 33 ExternalProviderImpl::kExternalUpdateUrl),
32 update_url); 34 update_url);
33 } 35 }
34 36
35 void ExternalPolicyLoader::StartLoading() { 37 void ExternalPolicyLoader::StartLoading() {
36 prefs_ = settings_->GetForceInstallList(); 38 switch (type_) {
39 case FORCED:
40 prefs_ = settings_->GetForceInstallList();
41 break;
42 case RECOMMENDED:
43 prefs_ = settings_->GetRecommendedInstallList();
44 break;
45 default:
46 NOTREACHED();
Finnur 2014/10/06 19:35:27 Leaving out the default case altogether is better
binjin 2014/10/07 09:29:23 Done.
47 }
37 LoadFinished(); 48 LoadFinished();
38 } 49 }
39 50
40 } // namespace extensions 51 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_policy_loader.h ('k') | chrome/browser/extensions/external_policy_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698