Index: chromeos/network/onc/onc_certificate_importer.h |
diff --git a/chrome/browser/chromeos/network_settings/onc_certificate_importer.h b/chromeos/network/onc/onc_certificate_importer.h |
similarity index 63% |
rename from chrome/browser/chromeos/network_settings/onc_certificate_importer.h |
rename to chromeos/network/onc/onc_certificate_importer.h |
index 10cc185bdb99db7fa93e7e1b5b3fe511a0677038..bb64f81abe0732a068e6b1d69f288d97ff42fc83 100644 |
--- a/chrome/browser/chromeos/network_settings/onc_certificate_importer.h |
+++ b/chromeos/network/onc/onc_certificate_importer.h |
@@ -2,8 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_CHROMEOS_NETWORK_SETTINGS_ONC_CERTIFICATE_IMPORTER_H_ |
-#define CHROME_BROWSER_CHROMEOS_NETWORK_SETTINGS_ONC_CERTIFICATE_IMPORTER_H_ |
+#ifndef CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_H_ |
+#define CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_H_ |
#include <string> |
#include <vector> |
@@ -11,7 +11,8 @@ |
#include "base/basictypes.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
-#include "chrome/browser/chromeos/cros/network_ui_data.h" |
+#include "chromeos/chromeos_export.h" |
+#include "chromeos/network/onc/onc_constants.h" |
namespace base { |
class DictionaryValue; |
@@ -29,25 +30,31 @@ namespace onc { |
// This class handles certificate imports from ONC (both policy and user |
// imports) into the certificate store. In particular, the GUID of certificates |
// is stored together with the certificate as Nickname. |
-class CertificateImporter { |
+class CHROMEOS_EXPORT CertificateImporter { |
public: |
+ enum ParseResult { |
+ IMPORT_OK, |
+ IMPORT_INCOMPLETE, |
+ IMPORT_FAILED, |
+ }; |
+ |
// Certificates pushed from a policy source with Web trust are only imported |
// with ParseCertificate() if the |allow_web_trust_from_policy| permission is |
// granted. |
- CertificateImporter(NetworkUIData::ONCSource onc_source, |
+ CertificateImporter(ONCSource onc_source, |
bool allow_web_trust_from_policy); |
// Parses and stores the certificates in |onc_certificates| into the |
// certificate store. If the "Remove" field of a certificate is enabled, then |
- // removes the certificate from the store instead of importing. Returns false |
- // and sets |error| to a user readable message if an error occured. In that |
- // case, some of the certificates may already be stored/removed. Otherwise, if |
- // no error occured, returns true and doesn't modify |error|. |
- bool ParseAndStoreCertificates(const base::ListValue& onc_certificates, |
- std::string* error); |
+ // removes the certificate from the store instead of importing. Returns the |
+ // result of the parse operation. In case of IMPORT_INCOMPLETE, some of the |
+ // certificates may be stored/removed successfully while others had errors. |
+ // If no error occurred, returns IMPORT_OK. |
+ ParseResult ParseAndStoreCertificates( |
+ const base::ListValue& onc_certificates); |
// Parses and stores/removes |certificate| in/from the certificate |
- // store. Returns false if an error occured. Returns true otherwise. |
+ // store. Returns true if the operation succeeded. |
bool ParseAndStoreCertificate(const base::DictionaryValue& certificate); |
// Lists the certificates that have the string |label| as their certificate |
@@ -61,27 +68,24 @@ class CertificateImporter { |
static bool DeleteCertAndKeyByNickname(const std::string& label); |
private: |
- bool ParseServerOrCaCertificate( |
- const std::string& cert_type, |
- const std::string& guid, |
- const base::DictionaryValue& certificate); |
- bool ParseClientCertificate( |
- const std::string& guid, |
- const base::DictionaryValue& certificate); |
+ bool ParseServerOrCaCertificate(const std::string& cert_type, |
+ const std::string& guid, |
+ const base::DictionaryValue& certificate); |
+ |
+ bool ParseClientCertificate(const std::string& guid, |
+ const base::DictionaryValue& certificate); |
// Where the ONC blob comes from. |
- NetworkUIData::ONCSource onc_source_; |
+ ONCSource onc_source_; |
// Whether certificates with Web trust should be stored when pushed from a |
// policy source. |
bool allow_web_trust_from_policy_; |
- std::string error_; |
- |
DISALLOW_COPY_AND_ASSIGN(CertificateImporter); |
}; |
} // chromeos |
} // onc |
-#endif // CHROME_BROWSER_CHROMEOS_NETWORK_SETTINGS_ONC_CERTIFICATE_IMPORTER_H_ |
+#endif // CHROMEOS_NETWORK_ONC_ONC_CERTIFICATE_IMPORTER_H_ |