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

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

Issue 948943003: Better support for Cellular roaming state in ONC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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_state.h" 5 #include "chromeos/network/network_state.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chromeos/network/device_state.h"
11 #include "chromeos/network/network_handler.h"
10 #include "chromeos/network/network_profile_handler.h" 12 #include "chromeos/network/network_profile_handler.h"
13 #include "chromeos/network/network_state_handler.h"
11 #include "chromeos/network/network_type_pattern.h" 14 #include "chromeos/network/network_type_pattern.h"
12 #include "chromeos/network/network_util.h" 15 #include "chromeos/network/network_util.h"
13 #include "chromeos/network/onc/onc_utils.h" 16 #include "chromeos/network/onc/onc_utils.h"
14 #include "chromeos/network/shill_property_util.h" 17 #include "chromeos/network/shill_property_util.h"
15 #include "components/device_event_log/device_event_log.h" 18 #include "components/device_event_log/device_event_log.h"
16 #include "third_party/cros_system_api/dbus/service_constants.h" 19 #include "third_party/cros_system_api/dbus/service_constants.h"
17 20
18 namespace { 21 namespace {
19 22
20 const char kErrorUnknown[] = "Unknown"; 23 const char kErrorUnknown[] = "Unknown";
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 dictionary->SetStringWithoutPathExpansion(shill::kEapMethodProperty, 231 dictionary->SetStringWithoutPathExpansion(shill::kEapMethodProperty,
229 eap_method()); 232 eap_method());
230 } 233 }
231 234
232 // Mobile properties 235 // Mobile properties
233 if (NetworkTypePattern::Mobile().MatchesType(type())) { 236 if (NetworkTypePattern::Mobile().MatchesType(type())) {
234 dictionary->SetStringWithoutPathExpansion(shill::kNetworkTechnologyProperty, 237 dictionary->SetStringWithoutPathExpansion(shill::kNetworkTechnologyProperty,
235 network_technology()); 238 network_technology());
236 dictionary->SetStringWithoutPathExpansion(shill::kActivationStateProperty, 239 dictionary->SetStringWithoutPathExpansion(shill::kActivationStateProperty,
237 activation_state()); 240 activation_state());
238 dictionary->SetStringWithoutPathExpansion(shill::kRoamingStateProperty, 241 if (NetworkTypePattern::Cellular().MatchesType(type())) {
239 roaming()); 242 dictionary->SetStringWithoutPathExpansion(shill::kRoamingStateProperty,
240 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, 243 roaming());
241 cellular_out_of_credits()); 244 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty,
245 cellular_out_of_credits());
246 // We need to set Device[Cellular.ProviderRequiresRoaming] so that
247 // the Shill -> ONC translation can provide 'ProviderRequiresRoaming'
armansito 2015/02/24 03:05:03 nit: Is there an additional indentation here?
stevenjb 2015/02/24 16:31:18 Done.
248 // to the UI for badging network icons.
249 const DeviceState* device =
250 NetworkHandler::Get()->network_state_handler()->GetDeviceState(
251 device_path_);
252 if (device) {
253 scoped_ptr<base::DictionaryValue> device_dict(
254 new base::DictionaryValue);
255 device_dict->SetBooleanWithoutPathExpansion(
256 shill::kProviderRequiresRoamingProperty,
257 device->provider_requires_roaming());
258 dictionary->SetWithoutPathExpansion(shill::kDeviceProperty,
259 device_dict.release());
260 }
261 }
242 } 262 }
243 } 263 }
244 264
245 void NetworkState::IPConfigPropertiesChanged( 265 void NetworkState::IPConfigPropertiesChanged(
246 const base::DictionaryValue& properties) { 266 const base::DictionaryValue& properties) {
247 for (base::DictionaryValue::Iterator iter(properties); !iter.IsAtEnd(); 267 for (base::DictionaryValue::Iterator iter(properties); !iter.IsAtEnd();
248 iter.Advance()) { 268 iter.Advance()) {
249 std::string key = iter.key(); 269 std::string key = iter.key();
250 const base::Value& value = iter.value(); 270 const base::Value& value = iter.value();
251 271
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 return IsCaptivePortalState(shill_properties, false /* log */); 397 return IsCaptivePortalState(shill_properties, false /* log */);
378 } 398 }
379 399
380 // static 400 // static
381 bool NetworkState::ErrorIsValid(const std::string& error) { 401 bool NetworkState::ErrorIsValid(const std::string& error) {
382 // Shill uses "Unknown" to indicate an unset or cleared error state. 402 // Shill uses "Unknown" to indicate an unset or cleared error state.
383 return !error.empty() && error != kErrorUnknown; 403 return !error.empty() && error != kErrorUnknown;
384 } 404 }
385 405
386 } // namespace chromeos 406 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698