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

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

Issue 275543005: Use GUID instead of ServicePath in networkingPrivate API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/favorite_state.h" 5 #include "chromeos/network/favorite_state.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chromeos/network/network_event_log.h" 10 #include "chromeos/network/network_event_log.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (proxy_config_dict) { 56 if (proxy_config_dict) {
57 // Warning: The DictionaryValue returned from 57 // Warning: The DictionaryValue returned from
58 // ReadDictionaryFromJson/JSONParser is an optimized derived class that 58 // ReadDictionaryFromJson/JSONParser is an optimized derived class that
59 // doesn't allow releasing ownership of nested values. A Swap in the wrong 59 // doesn't allow releasing ownership of nested values. A Swap in the wrong
60 // order leads to memory access errors. 60 // order leads to memory access errors.
61 proxy_config_.MergeDictionary(proxy_config_dict.get()); 61 proxy_config_.MergeDictionary(proxy_config_dict.get());
62 } else { 62 } else {
63 NET_LOG_ERROR("Failed to parse " + key, path()); 63 NET_LOG_ERROR("Failed to parse " + key, path());
64 } 64 }
65 return true; 65 return true;
66 } else if (key == shill::kSecurityProperty) {
67 return GetStringValue(key, value, &security_);
66 } 68 }
67 return false; 69 return false;
68 } 70 }
69 71
70 void FavoriteState::GetStateProperties( 72 void FavoriteState::GetStateProperties(
71 base::DictionaryValue* dictionary) const { 73 base::DictionaryValue* dictionary) const {
72 ManagedState::GetStateProperties(dictionary); 74 ManagedState::GetStateProperties(dictionary);
73 75
74 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); 76 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid());
75 dictionary->SetStringWithoutPathExpansion(shill::kProfileProperty, 77 dictionary->SetStringWithoutPathExpansion(shill::kProfileProperty,
76 profile_path()); 78 profile_path());
77 // Add ONCSource for debugging. 79 // Add ONCSource for debugging.
78 dictionary->SetStringWithoutPathExpansion(NetworkUIData::kKeyONCSource, 80 dictionary->SetStringWithoutPathExpansion(NetworkUIData::kKeyONCSource,
79 ui_data_.GetONCSourceAsString()); 81 ui_data_.GetONCSourceAsString());
80 } 82 }
81 83
82 bool FavoriteState::IsFavorite() const { 84 std::string FavoriteState::GetSpecifier() const {
83 // kTypeEthernetEap is always a favorite. We need this check because it does 85 if (!update_received()) {
86 NET_LOG_ERROR("GetSpecifier called before update", path());
87 return std::string();
88 }
89 if (type() == shill::kTypeWifi)
90 return name() + "_" + security_;
91 if (!name().empty())
92 return name();
93 return type(); // For unnamed networks such as ethernet.
94 }
95
96 void FavoriteState::SetGuid(const std::string& guid) {
97 DCHECK(guid_.empty());
98 guid_ = guid;
99 }
100
101 bool FavoriteState::IsInProfile() const {
102 // kTypeEthernetEap is always saved. We need this check because it does
84 // not show up in the visible list, but its properties may not be available 103 // not show up in the visible list, but its properties may not be available
85 // when it first shows up in ServiceCompleteList. See crbug.com/355117. 104 // when it first shows up in ServiceCompleteList. See crbug.com/355117.
86 return !profile_path_.empty() || type() == shill::kTypeEthernetEap; 105 return !profile_path_.empty() || type() == shill::kTypeEthernetEap;
87 } 106 }
88 107
89 bool FavoriteState::IsPrivate() const { 108 bool FavoriteState::IsPrivate() const {
90 return !profile_path_.empty() && 109 return !profile_path_.empty() &&
91 profile_path_ != NetworkProfileHandler::GetSharedProfilePath(); 110 profile_path_ != NetworkProfileHandler::GetSharedProfilePath();
92 } 111 }
93 112
94 } // namespace chromeos 113 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/favorite_state.h ('k') | chromeos/network/managed_network_configuration_handler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698