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

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 // Only used for GetSpecifier()
pneubeck (no reviews) 2014/05/12 13:37:07 this comment should be at the declaration of secur
stevenjb 2014/05/13 01:19:00 Done.
68 return GetStringValue(key, value, &security_);
66 } 69 }
67 return false; 70 return false;
68 } 71 }
69 72
70 void FavoriteState::GetStateProperties( 73 void FavoriteState::GetStateProperties(
71 base::DictionaryValue* dictionary) const { 74 base::DictionaryValue* dictionary) const {
72 ManagedState::GetStateProperties(dictionary); 75 ManagedState::GetStateProperties(dictionary);
73 76
74 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); 77 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid());
75 dictionary->SetStringWithoutPathExpansion(shill::kProfileProperty, 78 dictionary->SetStringWithoutPathExpansion(shill::kProfileProperty,
76 profile_path()); 79 profile_path());
77 // Add ONCSource for debugging. 80 // Add ONCSource for debugging.
78 dictionary->SetStringWithoutPathExpansion(NetworkUIData::kKeyONCSource, 81 dictionary->SetStringWithoutPathExpansion(NetworkUIData::kKeyONCSource,
79 ui_data_.GetONCSourceAsString()); 82 ui_data_.GetONCSourceAsString());
80 } 83 }
81 84
82 bool FavoriteState::IsFavorite() const { 85 std::string FavoriteState::GetSpecifier() const {
pneubeck (no reviews) 2014/05/12 13:37:07 I'd prefer to return "" as long as !update_receive
stevenjb 2014/05/13 01:19:00 Done.
83 // kTypeEthernetEap is always a favorite. We need this check because it does 86 if (type() == shill::kTypeWifi)
87 return name() + "_" + security_;
88 if (!name().empty())
89 return name();
90 return type(); // For unnamed networks such as ethernet.
91 }
92
93 void FavoriteState::SetGuid(const std::string& guid) {
94 DCHECK(guid_.empty());
95 guid_ = guid;
96 }
97
98 bool FavoriteState::IsInProfile() const {
99 // 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 100 // 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. 101 // when it first shows up in ServiceCompleteList. See crbug.com/355117.
86 return !profile_path_.empty() || type() == shill::kTypeEthernetEap; 102 return !profile_path_.empty() || type() == shill::kTypeEthernetEap;
87 } 103 }
88 104
89 bool FavoriteState::IsPrivate() const { 105 bool FavoriteState::IsPrivate() const {
90 return !profile_path_.empty() && 106 return !profile_path_.empty() &&
91 profile_path_ != NetworkProfileHandler::GetSharedProfilePath(); 107 profile_path_ != NetworkProfileHandler::GetSharedProfilePath();
92 } 108 }
93 109
94 } // namespace chromeos 110 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698