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

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

Issue 12319145: Using the new Network*Handlers in networkingPrivate Extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unused method declaration. Fixing a comment. Created 7 years, 9 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 "chromeos/network/network_state.h" 5 #include "chromeos/network/network_state.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chromeos/network/onc/onc_signature.h"
9 #include "chromeos/network/onc/onc_translator.h"
8 #include "third_party/cros_system_api/dbus/service_constants.h" 10 #include "third_party/cros_system_api/dbus/service_constants.h"
9 11
10 namespace chromeos { 12 namespace chromeos {
11 13
12 NetworkState::NetworkState(const std::string& path) 14 NetworkState::NetworkState(const std::string& path)
13 : ManagedState(MANAGED_TYPE_NETWORK, path), 15 : ManagedState(MANAGED_TYPE_NETWORK, path),
14 signal_strength_(0) { 16 signal_strength_(0) {
15 } 17 }
16 18
17 NetworkState::~NetworkState() { 19 NetworkState::~NetworkState() {
(...skipping 26 matching lines...) Expand all
44 } 46 }
45 47
46 bool NetworkState::IsConnectedState() const { 48 bool NetworkState::IsConnectedState() const {
47 return StateIsConnected(connection_state_); 49 return StateIsConnected(connection_state_);
48 } 50 }
49 51
50 bool NetworkState::IsConnectingState() const { 52 bool NetworkState::IsConnectingState() const {
51 return StateIsConnecting(connection_state_); 53 return StateIsConnecting(connection_state_);
52 } 54 }
53 55
56 scoped_ptr<base::DictionaryValue> NetworkState::TranslateToONC() const {
57 base::DictionaryValue shill_dictionary;
58 shill_dictionary.SetStringWithoutPathExpansion(flimflam::kNameProperty,
59 name());
60 shill_dictionary.SetStringWithoutPathExpansion(flimflam::kTypeProperty,
61 type());
62 shill_dictionary.SetStringWithoutPathExpansion(flimflam::kSecurityProperty,
63 security());
64 shill_dictionary.SetStringWithoutPathExpansion(
65 flimflam::kNetworkTechnologyProperty,
66 technology());
67 shill_dictionary.SetStringWithoutPathExpansion(flimflam::kStateProperty,
68 connection_state());
69 shill_dictionary.SetStringWithoutPathExpansion(
70 flimflam::kActivationStateProperty,
71 activation_state());
72 shill_dictionary.SetStringWithoutPathExpansion(
73 flimflam::kRoamingStateProperty,
74 roaming());
75 shill_dictionary.SetIntegerWithoutPathExpansion(
76 flimflam::kSignalStrengthProperty,
77 signal_strength());
stevenjb 2013/03/04 18:57:58 Alternately, the above code doesn't actually depen
pneubeck (no reviews) 2013/03/05 13:11:55 Added such an inverse function. Changed the order
78
79 return onc::TranslateShillServiceToONCPart(
80 shill_dictionary,
81 &onc::kNetworkWithStateSignature).Pass();
82 }
83
54 // static 84 // static
55 bool NetworkState::StateIsConnected(const std::string& connection_state) { 85 bool NetworkState::StateIsConnected(const std::string& connection_state) {
56 return (connection_state == flimflam::kStateReady || 86 return (connection_state == flimflam::kStateReady ||
57 connection_state == flimflam::kStateOnline || 87 connection_state == flimflam::kStateOnline ||
58 connection_state == flimflam::kStatePortal); 88 connection_state == flimflam::kStatePortal);
59 } 89 }
60 90
61 // static 91 // static
62 bool NetworkState::StateIsConnecting(const std::string& connection_state) { 92 bool NetworkState::StateIsConnecting(const std::string& connection_state) {
63 return (connection_state == flimflam::kStateAssociation || 93 return (connection_state == flimflam::kStateAssociation ||
64 connection_state == flimflam::kStateConfiguration || 94 connection_state == flimflam::kStateConfiguration ||
65 connection_state == flimflam::kStateCarrier); 95 connection_state == flimflam::kStateCarrier);
66 } 96 }
67 97
68 } // namespace chromeos 98 } // namespace chromeos
OLDNEW
« chromeos/network/network_state.h ('K') | « chromeos/network/network_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698