chromium/components/password_manager/services/csv_password/public/mojom/csv_password_parser.mojom

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module password_manager.mojom;

import "sandbox/policy/mojom/sandbox.mojom";
import "url/mojom/url.mojom";

struct CSVPasswordSequence {
  array<CSVPassword> csv_passwords;
};

struct CSVPassword {
  enum Status {
    kOK = 0,
    kSyntaxError = 1,
    kSemanticError = 2,
  };

  // Indicates the parse status of a password.
  Status status;
  string username;
  string password;
  string note;
  url.mojom.Url url;
  // If the url is invalid, the original url will be populated in this field.
  string? invalid_url;
};

// Interface for parsing csv raw string that is expected to
// confrom to the password manager CSV format.
// Lives in a utility process, and used as part of the Password Import feature.
// If parsing failed, |sequence| will be null.
[ServiceSandbox=sandbox.mojom.Sandbox.kService]
interface CSVPasswordParser {
  // Parses the |raw_csv| into a CSVPasswordSequence object.
  ParseCSV(string raw_csv)
    => (CSVPasswordSequence? sequence);
};