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

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

Issue 8804021: Proper management for policy-configured networks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/policy/network_configuration_updater.h" 5 #include "chrome/browser/policy/network_configuration_updater.h"
6 6
7 #include "chrome/browser/chromeos/cros/network_library.h" 7 #include "chrome/browser/chromeos/cros/network_library.h"
8 #include "chrome/browser/policy/policy_map.h" 8 #include "chrome/browser/policy/policy_map.h"
9 #include "policy/policy_constants.h" 9 #include "policy/policy_constants.h"
10 10
11 namespace policy { 11 namespace policy {
12 12
13 const char NetworkConfigurationUpdater::kEmptyConfiguration[] =
14 "{NetworkConfigurations:[],Certificates:[]}";
15
13 NetworkConfigurationUpdater::NetworkConfigurationUpdater( 16 NetworkConfigurationUpdater::NetworkConfigurationUpdater(
14 ConfigurationPolicyProvider* provider, 17 ConfigurationPolicyProvider* provider,
15 chromeos::NetworkLibrary* network_library) 18 chromeos::NetworkLibrary* network_library)
16 : network_library_(network_library) { 19 : network_library_(network_library) {
17 DCHECK(network_library_); 20 DCHECK(network_library_);
18 provider_registrar_.Init(provider, this); 21 provider_registrar_.Init(provider, this);
19 Update(); 22 Update();
20 } 23 }
21 24
22 NetworkConfigurationUpdater::~NetworkConfigurationUpdater() {} 25 NetworkConfigurationUpdater::~NetworkConfigurationUpdater() {}
(...skipping 27 matching lines...) Expand all
50 std::string* cached_value) { 53 std::string* cached_value) {
51 std::string new_network_config; 54 std::string new_network_config;
52 const base::Value* value = policy_map.Get(policy_type); 55 const base::Value* value = policy_map.Get(policy_type);
53 if (value != NULL) { 56 if (value != NULL) {
54 // If the policy is not a string, we issue a warning, but still clear the 57 // If the policy is not a string, we issue a warning, but still clear the
55 // network configuration. 58 // network configuration.
56 if (!value->GetAsString(&new_network_config)) 59 if (!value->GetAsString(&new_network_config))
57 LOG(WARNING) << "Invalid network configuration."; 60 LOG(WARNING) << "Invalid network configuration.";
58 } 61 }
59 62
63 // We need to load an empty configuration to get rid of any configuration
64 // that has been installed previously. An empty string also works, but
65 // generates warnings and errors, which we'd like to avoid.
66 if (new_network_config.empty())
67 new_network_config = kEmptyConfiguration;
68
60 if (*cached_value != new_network_config) { 69 if (*cached_value != new_network_config) {
61 *cached_value = new_network_config; 70 *cached_value = new_network_config;
62 std::string error; 71 std::string error;
63 if (!network_library_->LoadOncNetworks(new_network_config, "", onc_source, 72 if (!network_library_->LoadOncNetworks(new_network_config, "", onc_source,
64 &error)) { 73 &error)) {
65 LOG(WARNING) << "Network library failed to load ONC configuration:" 74 LOG(WARNING) << "Network library failed to load ONC configuration:"
66 << error; 75 << error;
67 } 76 }
68 } 77 }
69 } 78 }
70 79
71 } // namespace policy 80 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/network_configuration_updater.h ('k') | chrome/browser/policy/network_configuration_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698