// Copyright 2016 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.

module chrome.mojom;

import "components/autofill/content/common/autofill_types.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "url/mojom/url.mojom";

const string kProfileImportServiceName = "profile_import";

[Native]
struct ImportedBookmarkEntry;

[Native]
struct ImporterAutofillFormDataEntry;

[Native]
struct SearchEngineInfo;

[Native]
struct ImporterURLRow;

[Native]
struct SourceProfile;

[Native]
struct FaviconUsageDataList;

[Native]
struct ImporterIE7PasswordInfo;

[Native]
enum ImportItem;

// 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(autofill.mojom.PasswordForm form);
  OnKeywordsImportReady(
      array<SearchEngineInfo> search_engines,
      bool unique_on_host_and_path);
  OnFirefoxSearchEngineDataReceived(array<string> search_engine_data);
  OnAutofillFormDataImportStart(uint32 total_autofill_form_data_entry_count);
  OnAutofillFormDataImportGroup(
      array<ImporterAutofillFormDataEntry> autofill_form_data_entry_group);
  // Windows only:
  OnIE7PasswordReceived(ImporterIE7PasswordInfo importer_password_info);
};

// This interface is used to control the import process.
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,
      ProfileImportObserver observer);

  // Stop the importer.
  CancelImport();

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