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

Unified Diff: components/wifi_sync/wifi_credential.cc

Issue 2463463004: [Sync] Rename wifi_sync to sync_wifi. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/wifi_sync/wifi_credential.h ('k') | components/wifi_sync/wifi_credential_syncable_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/wifi_sync/wifi_credential.cc
diff --git a/components/wifi_sync/wifi_credential.cc b/components/wifi_sync/wifi_credential.cc
deleted file mode 100644
index bbbb492f260e30f982bffd7fe86ad97702fc1bf2..0000000000000000000000000000000000000000
--- a/components/wifi_sync/wifi_credential.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/wifi_sync/wifi_credential.h"
-
-#include "base/i18n/streaming_utf8_validator.h"
-#include "base/logging.h"
-#include "base/memory/ptr_util.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/stringprintf.h"
-#include "base/values.h"
-#include "components/onc/onc_constants.h"
-
-namespace wifi_sync {
-
-WifiCredential::WifiCredential(const WifiCredential& other) = default;
-
-WifiCredential::~WifiCredential() {
-}
-
-// static
-std::unique_ptr<WifiCredential> WifiCredential::Create(
- const SsidBytes& ssid,
- WifiSecurityClass security_class,
- const std::string& passphrase) {
- if (security_class == SECURITY_CLASS_INVALID) {
- LOG(ERROR) << "SecurityClass is invalid.";
- return nullptr;
- }
-
- if (!base::StreamingUtf8Validator::Validate(passphrase)) {
- LOG(ERROR) << "Passphrase is not valid UTF-8";
- return nullptr;
- }
-
- return base::WrapUnique(new WifiCredential(ssid, security_class, passphrase));
-}
-
-std::unique_ptr<base::DictionaryValue> WifiCredential::ToOncProperties() const {
- const std::string ssid_utf8(ssid().begin(), ssid().end());
- // TODO(quiche): Remove this test, once ONC suports non-UTF-8 SSIDs.
- // crbug.com/432546.
- if (!base::StreamingUtf8Validator::Validate(ssid_utf8)) {
- LOG(ERROR) << "SSID is not valid UTF-8";
- return nullptr;
- }
-
- std::string onc_security;
- if (!WifiSecurityClassToOncSecurityString(security_class(), &onc_security)) {
- NOTREACHED() << "Failed to convert SecurityClass with value "
- << security_class();
- return base::MakeUnique<base::DictionaryValue>();
- }
-
- std::unique_ptr<base::DictionaryValue> onc_properties(
- new base::DictionaryValue());
- onc_properties->Set(onc::toplevel_config::kType,
- new base::StringValue(onc::network_type::kWiFi));
- // TODO(quiche): Switch to the HexSSID property, once ONC fully supports it.
- // crbug.com/432546.
- onc_properties->Set(onc::network_config::WifiProperty(onc::wifi::kSSID),
- new base::StringValue(ssid_utf8));
- onc_properties->Set(onc::network_config::WifiProperty(onc::wifi::kSecurity),
- new base::StringValue(onc_security));
- if (WifiSecurityClassSupportsPassphrases(security_class())) {
- onc_properties->Set(
- onc::network_config::WifiProperty(onc::wifi::kPassphrase),
- new base::StringValue(passphrase()));
- }
- return onc_properties;
-}
-
-std::string WifiCredential::ToString() const {
- return base::StringPrintf(
- "[SSID (hex): %s, SecurityClass: %d]",
- base::HexEncode(&ssid_.front(), ssid_.size()).c_str(),
- security_class_); // Passphrase deliberately omitted.
-}
-
-// static
-bool WifiCredential::IsLessThan(
- const WifiCredential& a, const WifiCredential& b) {
- return a.ssid_ < b.ssid_ ||
- a.security_class_< b.security_class_ ||
- a.passphrase_ < b.passphrase_;
-}
-
-// static
-WifiCredential::CredentialSet WifiCredential::MakeSet() {
- return CredentialSet(WifiCredential::IsLessThan);
-}
-
-// static
-WifiCredential::SsidBytes WifiCredential::MakeSsidBytesForTest(
- const std::string& ssid) {
- return SsidBytes(ssid.begin(), ssid.end());
-}
-
-// Private methods.
-
-WifiCredential::WifiCredential(
- const std::vector<unsigned char>& ssid,
- WifiSecurityClass security_class,
- const std::string& passphrase)
- : ssid_(ssid),
- security_class_(security_class),
- passphrase_(passphrase) {
-}
-
-} // namespace wifi_sync
« no previous file with comments | « components/wifi_sync/wifi_credential.h ('k') | components/wifi_sync/wifi_credential_syncable_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698