chromium/chrome/common/importer/profile_import.mojom

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

module chrome.mojom;

import "mojo/public/mojom/base/string16.mojom";
import "sandbox/policy/mojom/sandbox.mojom";
import "url/mojom/url.mojom";

[Native]
struct ImportedBookmarkEntry;

[Native]
struct ImporterAutofillFormDataEntry;

[Native]
struct SearchEngineInfo;

[Native]
struct ImporterURLRow;

[Native]
struct SourceProfile;

[Native]
struct FaviconUsageDataList;

[Native]
struct ImporterIE7PasswordInfo;

[Native]
enum ImportItem;

// Represents information about an imported password form. Typemapped to
// importer::ImportedPasswordForm.
struct ImportedPasswordForm {
  // Enum to differentiate between HTML form based authentication, and dialogs
  // using basic or digest schemes. Default is kHtml.
  enum Scheme {
    kHtml,
    kBasic,
  };

  Scheme scheme;
  string signon_realm;
  url.mojom.Url url;
  url.mojom.Url action;
  mojo_base.mojom.String16 username_element;
  mojo_base.mojom.String16 username_value;
  mojo_base.mojom.String16 password_element;
  mojo_base.mojom.String16 password_value;
  bool blocked_by_user;
};

// These are messages sent from the profile import process to the browser.
// These messages send information about the status of the import and individual
// import tasks.
interface ProfileImportObserver {
  OnImportStart();
  OnImportFinished(bool succeeded, string error_msg);
  OnImportItemStart(ImportItem item);
  OnImportItemFinished(ImportItem item);

  // These messages send data from the external importer process back to the
  // process host so it can be written to the profile.
  OnHistoryImportStart(uint32 total_history_rows_count);
  OnHistoryImportGroup(
      array<ImporterURLRow> history_rows_group,
      int32 visit_source);
  OnHomePageImportReady(url.mojom.Url home_page);
  OnBookmarksImportStart(
      mojo_base.mojom.String16 first_folder_name,
      uint32 total_bookmarks_count);
  OnBookmarksImportGroup(array<ImportedBookmarkEntry> bookmarks_group);
  OnFaviconsImportStart(uint32 total_favicons_count);
  OnFaviconsImportGroup(FaviconUsageDataList favicons_group);
  OnPasswordFormImportReady(ImportedPasswordForm form);
  OnKeywordsImportReady(
      array<SearchEngineInfo> search_engines,
      bool unique_on_host_and_path);
  OnAutofillFormDataImportStart(uint32 total_autofill_form_data_entry_count);
  OnAutofillFormDataImportGroup(
      array<ImporterAutofillFormDataEntry> autofill_form_data_entry_group);
};

// This interface is used to control the import process.
[ServiceSandbox=sandbox.mojom.Sandbox.kNoSandbox]
interface ProfileImport {
  // Start the importer. |items| is a bitmask of importer::ImportItem of items
  // to import.
  StartImport(
      SourceProfile source_profile,
      uint16 items,
      map<uint32, string> localized_strings,
      pending_remote<ProfileImportObserver> observer);

  // Stop the importer.
  CancelImport();

  // Tell the importer that we're done with one item.
  ReportImportItemFinished(ImportItem item);
};