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

Side by Side Diff: chromeos/network/network_util.cc

Issue 948943003: Better support for Cellular roaming state in ONC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 5 years, 10 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
« no previous file with comments | « chromeos/dbus/fake_shill_manager_client.cc ('k') | chromeos/network/onc/onc_signature.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chromeos/network/network_util.h" 5 #include "chromeos/network/network_util.h"
6 6
7 #include "base/strings/string_tokenizer.h" 7 #include "base/strings/string_tokenizer.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chromeos/login/login_state.h" 10 #include "chromeos/login/login_state.h"
11 #include "chromeos/network/device_state.h"
11 #include "chromeos/network/managed_network_configuration_handler.h" 12 #include "chromeos/network/managed_network_configuration_handler.h"
12 #include "chromeos/network/network_state.h" 13 #include "chromeos/network/network_state.h"
13 #include "chromeos/network/network_state_handler.h" 14 #include "chromeos/network/network_state_handler.h"
14 #include "chromeos/network/network_ui_data.h" 15 #include "chromeos/network/network_ui_data.h"
15 #include "chromeos/network/onc/onc_signature.h" 16 #include "chromeos/network/onc/onc_signature.h"
16 #include "chromeos/network/onc/onc_translation_tables.h" 17 #include "chromeos/network/onc/onc_translation_tables.h"
17 #include "chromeos/network/onc/onc_translator.h" 18 #include "chromeos/network/onc/onc_translator.h"
18 #include "third_party/cros_system_api/dbus/service_constants.h" 19 #include "third_party/cros_system_api/dbus/service_constants.h"
19 20
20 namespace chromeos { 21 namespace chromeos {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 dict->GetStringWithoutPathExpansion(shill::kTechnologyProperty, 140 dict->GetStringWithoutPathExpansion(shill::kTechnologyProperty,
140 &scan_result.technology); 141 &scan_result.technology);
141 scan_results->push_back(scan_result); 142 scan_results->push_back(scan_result);
142 } 143 }
143 return true; 144 return true;
144 } 145 }
145 146
146 scoped_ptr<base::DictionaryValue> TranslateNetworkStateToONC( 147 scoped_ptr<base::DictionaryValue> TranslateNetworkStateToONC(
147 const NetworkState* network) { 148 const NetworkState* network) {
148 // Get the properties from the NetworkState. 149 // Get the properties from the NetworkState.
149 base::DictionaryValue shill_dictionary; 150 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue);
150 network->GetStateProperties(&shill_dictionary); 151 network->GetStateProperties(shill_dictionary.get());
152
153 // Get any Device properties required to translate state.
154 if (NetworkTypePattern::Cellular().MatchesType(network->type())) {
155 // We need to set Device[Cellular.ProviderRequiresRoaming] so that
156 // Cellular[RoamingState] can be set correctly for badging network icons.
157 const DeviceState* device =
158 NetworkHandler::Get()->network_state_handler()->GetDeviceState(
159 network->device_path());
160 if (device) {
161 scoped_ptr<base::DictionaryValue> device_dict(new base::DictionaryValue);
162 device_dict->SetBooleanWithoutPathExpansion(
163 shill::kProviderRequiresRoamingProperty,
164 device->provider_requires_roaming());
165 shill_dictionary->SetWithoutPathExpansion(shill::kDeviceProperty,
166 device_dict.release());
167 }
168 }
151 169
152 // NetworkState is always associated with the primary user profile, regardless 170 // NetworkState is always associated with the primary user profile, regardless
153 // of what profile is associated with the page that calls this method. We do 171 // of what profile is associated with the page that calls this method. We do
154 // not expose any sensitive properties in the resulting dictionary, it is 172 // not expose any sensitive properties in the resulting dictionary, it is
155 // only used to show connection state and icons. 173 // only used to show connection state and icons.
156 std::string user_id_hash = chromeos::LoginState::Get()->primary_user_hash(); 174 std::string user_id_hash = chromeos::LoginState::Get()->primary_user_hash();
157 ::onc::ONCSource onc_source = ::onc::ONC_SOURCE_NONE; 175 ::onc::ONCSource onc_source = ::onc::ONC_SOURCE_NONE;
158 NetworkHandler::Get() 176 NetworkHandler::Get()
159 ->managed_network_configuration_handler() 177 ->managed_network_configuration_handler()
160 ->FindPolicyByGUID(user_id_hash, network->guid(), &onc_source); 178 ->FindPolicyByGUID(user_id_hash, network->guid(), &onc_source);
161 179
162 scoped_ptr<base::DictionaryValue> onc_dictionary = 180 scoped_ptr<base::DictionaryValue> onc_dictionary =
163 TranslateShillServiceToONCPart(shill_dictionary, onc_source, 181 TranslateShillServiceToONCPart(*shill_dictionary, onc_source,
164 &onc::kNetworkWithStateSignature); 182 &onc::kNetworkWithStateSignature);
165 return onc_dictionary.Pass(); 183 return onc_dictionary.Pass();
166 } 184 }
167 185
168 scoped_ptr<base::ListValue> TranslateNetworkListToONC( 186 scoped_ptr<base::ListValue> TranslateNetworkListToONC(
169 NetworkTypePattern pattern, 187 NetworkTypePattern pattern,
170 bool configured_only, 188 bool configured_only,
171 bool visible_only, 189 bool visible_only,
172 int limit, 190 int limit,
173 bool debugging_properties) { 191 bool debugging_properties) {
(...skipping 29 matching lines...) Expand all
203 std::string TranslateShillTypeToONC(const std::string& shill_type) { 221 std::string TranslateShillTypeToONC(const std::string& shill_type) {
204 if (shill_type == shill::kTypeEthernet) 222 if (shill_type == shill::kTypeEthernet)
205 return ::onc::network_type::kEthernet; 223 return ::onc::network_type::kEthernet;
206 std::string onc_type; 224 std::string onc_type;
207 onc::TranslateStringToONC(onc::kNetworkTypeTable, shill_type, &onc_type); 225 onc::TranslateStringToONC(onc::kNetworkTypeTable, shill_type, &onc_type);
208 return onc_type; 226 return onc_type;
209 } 227 }
210 228
211 } // namespace network_util 229 } // namespace network_util
212 } // namespace chromeos 230 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_shill_manager_client.cc ('k') | chromeos/network/onc/onc_signature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698