chromium/chrome/browser/importer/importer_list.cc

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

#include "chrome/browser/importer/importer_list.h"

#include <stdint.h>

#include "base/functional/bind.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/common/importer/firefox_importer_utils.h"
#include "chrome/common/importer/importer_bridge.h"
#include "chrome/common/importer/importer_data_types.h"
#include "chrome/grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"

#if BUILDFLAG(IS_MAC)
#include "base/apple/foundation_util.h"
#include "chrome/common/importer/safari_importer_utils.h"
#endif

#if BUILDFLAG(IS_WIN)
#include "chrome/common/importer/edge_importer_utils_win.h"
#endif

namespace {

#if BUILDFLAG(IS_WIN)
void DetectIEProfiles(std::vector<importer::SourceProfile>* profiles) {
  base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
                                                base::BlockingType::MAY_BLOCK);

  // IE always exists and doesn't have multiple profiles.
  importer::SourceProfile ie;
  ie.importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_IE);
  ie.importer_type = importer::TYPE_IE;
  ie.services_supported =
      importer::HISTORY | importer::FAVORITES | importer::SEARCH_ENGINES;
  profiles->push_back(ie);
}

void DetectEdgeProfiles(std::vector<importer::SourceProfile>* profiles) {
  if (!importer::EdgeImporterCanImport())
    return;
  importer::SourceProfile edge;
  edge.importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_EDGE);
  edge.importer_type = importer::TYPE_EDGE;
  edge.services_supported = importer::FAVORITES;
  edge.source_path = importer::GetEdgeDataFilePath();
  profiles->push_back(edge);
}

void DetectBuiltinWindowsProfiles(
    std::vector<importer::SourceProfile>* profiles) {
  if (shell_integration::IsIEDefaultBrowser()) {
    DetectIEProfiles(profiles);
    DetectEdgeProfiles(profiles);
  } else {
    DetectEdgeProfiles(profiles);
    DetectIEProfiles(profiles);
  }
}

#endif  // BUILDFLAG(IS_WIN)

#if BUILDFLAG(IS_MAC)
void DetectSafariProfiles(std::vector<importer::SourceProfile>* profiles) {
  base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
                                                base::BlockingType::MAY_BLOCK);

  uint16_t items = importer::NONE;
  if (!SafariImporterCanImport(base::apple::GetUserLibraryPath(), &items)) {
    return;
  }

  importer::SourceProfile safari;
  safari.importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_SAFARI);
  safari.importer_type = importer::TYPE_SAFARI;
  safari.services_supported = items;
  profiles->push_back(safari);
}
#endif  // BUILDFLAG(IS_MAC)

// |locale|: The application locale used for lookups in Firefox's
// locale-specific search engines feature (see firefox_importer.cc for
// details).
void DetectFirefoxProfiles(const std::string locale,
                           std::vector<importer::SourceProfile>* profiles) {}

std::vector<importer::SourceProfile> DetectSourceProfilesWorker(
    const std::string& locale,
    bool include_interactive_profiles) {}

}  // namespace

ImporterList::ImporterList() = default;

ImporterList::~ImporterList() {}

void ImporterList::DetectSourceProfiles(
    const std::string& locale,
    bool include_interactive_profiles,
    base::OnceClosure profiles_loaded_callback) {}

const importer::SourceProfile& ImporterList::GetSourceProfileAt(
    size_t index) const {}

void ImporterList::SourceProfilesLoaded(
    base::OnceClosure profiles_loaded_callback,
    const std::vector<importer::SourceProfile>& profiles) {}