| OLD | NEW |
| 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 Loading... |
| 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() |
| 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 { |
| 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 |
| OLD | NEW |