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

Side by Side Diff: chrome/browser/chromeos/policy/network_configuration_updater.cc

Issue 23526016: Autoconnect policy for CrOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed policy. Created 7 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 | Annotate | Revision Log
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/chromeos/policy/network_configuration_updater.h" 5 #include "chrome/browser/chromeos/policy/network_configuration_updater.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 } 85 }
86 86
87 void NetworkConfigurationUpdater::ImportCertificates( 87 void NetworkConfigurationUpdater::ImportCertificates(
88 const base::ListValue& certificates_onc) { 88 const base::ListValue& certificates_onc) {
89 certificate_importer_->ImportCertificates( 89 certificate_importer_->ImportCertificates(
90 certificates_onc, onc_source_, NULL); 90 certificates_onc, onc_source_, NULL);
91 } 91 }
92 92
93 void NetworkConfigurationUpdater::ApplyNetworkPolicy( 93 void NetworkConfigurationUpdater::ApplyNetworkPolicy(
94 base::ListValue* network_configs_onc) { 94 base::ListValue* network_configs_onc,
95 network_config_handler_->SetPolicy( 95 base::DictionaryValue* global_network_config) {
96 onc_source_, std::string() /* no username hash */, *network_configs_onc); 96 network_config_handler_->SetPolicy(onc_source_,
97 std::string() /* no username hash */,
98 *network_configs_onc,
99 *global_network_config);
97 } 100 }
98 101
99 void NetworkConfigurationUpdater::OnPolicyChanged( 102 void NetworkConfigurationUpdater::OnPolicyChanged(
100 const base::Value* previous, 103 const base::Value* previous,
101 const base::Value* current) { 104 const base::Value* current) {
102 VLOG(1) << LogHeader() << " changed."; 105 VLOG(1) << LogHeader() << " changed.";
103 ApplyPolicy(); 106 ApplyPolicy();
104 } 107 }
105 108
106 void NetworkConfigurationUpdater::ApplyPolicy() { 109 void NetworkConfigurationUpdater::ApplyPolicy() {
107 const PolicyMap& policies = policy_service_->GetPolicies( 110 const PolicyMap& policies = policy_service_->GetPolicies(
108 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); 111 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()));
109 const base::Value* policy_value = policies.GetValue(policy_key_); 112 const base::Value* policy_value = policies.GetValue(policy_key_);
110 113
111 std::string onc_blob; 114 std::string onc_blob;
112 if (!policy_value) 115 if (!policy_value)
113 VLOG(2) << LogHeader() << " is not set."; 116 VLOG(2) << LogHeader() << " is not set.";
114 else if (!policy_value->GetAsString(&onc_blob)) 117 else if (!policy_value->GetAsString(&onc_blob))
115 LOG(ERROR) << LogHeader() << " is not a string value."; 118 LOG(ERROR) << LogHeader() << " is not a string value.";
116 119
117 base::ListValue network_configs; 120 base::ListValue network_configs;
121 base::DictionaryValue global_network_config;
118 base::ListValue certificates; 122 base::ListValue certificates;
119 chromeos::onc::ParseAndValidateOncForImport(onc_blob, 123 chromeos::onc::ParseAndValidateOncForImport(onc_blob,
120 onc_source_, 124 onc_source_,
121 "" /* no passphrase */, 125 "" /* no passphrase */,
122 &network_configs, 126 &network_configs,
127 &global_network_config,
123 &certificates); 128 &certificates);
124 129
125 ImportCertificates(certificates); 130 ImportCertificates(certificates);
126 ApplyNetworkPolicy(&network_configs); 131 ApplyNetworkPolicy(&network_configs, &global_network_config);
127 } 132 }
128 133
129 std::string NetworkConfigurationUpdater::LogHeader() const { 134 std::string NetworkConfigurationUpdater::LogHeader() const {
130 return chromeos::onc::GetSourceAsString(onc_source_); 135 return chromeos::onc::GetSourceAsString(onc_source_);
131 } 136 }
132 137
133 } // namespace policy 138 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698