summaryrefslogtreecommitdiff
path: root/chromium/chrome/common/importer
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/chrome/common/importer')
-rw-r--r--chromium/chrome/common/importer/DEPS3
-rw-r--r--chromium/chrome/common/importer/OWNERS13
-rw-r--r--chromium/chrome/common/importer/edge_importer_utils_win.cc91
-rw-r--r--chromium/chrome/common/importer/edge_importer_utils_win.h28
-rw-r--r--chromium/chrome/common/importer/firefox_importer_utils.cc330
-rw-r--r--chromium/chrome/common/importer/firefox_importer_utils.h92
-rw-r--r--chromium/chrome/common/importer/firefox_importer_utils_linux.cc25
-rw-r--r--chromium/chrome/common/importer/firefox_importer_utils_mac.mm45
-rw-r--r--chromium/chrome/common/importer/firefox_importer_utils_unittest.cc163
-rw-r--r--chromium/chrome/common/importer/firefox_importer_utils_win.cc82
-rw-r--r--chromium/chrome/common/importer/ie_importer_utils_win.cc48
-rw-r--r--chromium/chrome/common/importer/ie_importer_utils_win.h26
-rw-r--r--chromium/chrome/common/importer/imported_bookmark_entry.cc24
-rw-r--r--chromium/chrome/common/importer/imported_bookmark_entry.h29
-rw-r--r--chromium/chrome/common/importer/importer_autofill_form_data_entry.cc11
-rw-r--r--chromium/chrome/common/importer/importer_autofill_form_data_entry.h33
-rw-r--r--chromium/chrome/common/importer/importer_bridge.cc9
-rw-r--r--chromium/chrome/common/importer/importer_bridge.h89
-rw-r--r--chromium/chrome/common/importer/importer_data_types.cc32
-rw-r--r--chromium/chrome/common/importer/importer_data_types.h90
-rw-r--r--chromium/chrome/common/importer/importer_test_registry_overrider_win.cc70
-rw-r--r--chromium/chrome/common/importer/importer_test_registry_overrider_win.h34
-rw-r--r--chromium/chrome/common/importer/importer_type.h36
-rw-r--r--chromium/chrome/common/importer/importer_url_row.cc21
-rw-r--r--chromium/chrome/common/importer/importer_url_row.h39
-rw-r--r--chromium/chrome/common/importer/mock_importer_bridge.cc9
-rw-r--r--chromium/chrome/common/importer/mock_importer_bridge.h45
-rw-r--r--chromium/chrome/common/importer/profile_import_process_param_traits.cc33
-rw-r--r--chromium/chrome/common/importer/profile_import_process_param_traits.h10
-rw-r--r--chromium/chrome/common/importer/profile_import_process_param_traits_macros.h94
-rw-r--r--chromium/chrome/common/importer/pstore_declarations.h188
-rw-r--r--chromium/chrome/common/importer/safari_importer_utils.h22
-rw-r--r--chromium/chrome/common/importer/safari_importer_utils.mm29
33 files changed, 1893 insertions, 0 deletions
diff --git a/chromium/chrome/common/importer/DEPS b/chromium/chrome/common/importer/DEPS
new file mode 100644
index 00000000000..3daf8ae6239
--- /dev/null
+++ b/chromium/chrome/common/importer/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+components/favicon_base",
+]
diff --git a/chromium/chrome/common/importer/OWNERS b/chromium/chrome/common/importer/OWNERS
new file mode 100644
index 00000000000..4c26573d6df
--- /dev/null
+++ b/chromium/chrome/common/importer/OWNERS
@@ -0,0 +1,13 @@
+gab@chromium.org
+isherman@chromium.org
+
+per-file *_messages*.h=set noparent
+per-file *_messages*.h=file://ipc/SECURITY_OWNERS
+
+per-file *_param_traits*.*=set noparent
+per-file *_param_traits*.*=file://ipc/SECURITY_OWNERS
+
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
+
+# COMPONENT: UI>Browser>Import
diff --git a/chromium/chrome/common/importer/edge_importer_utils_win.cc b/chromium/chrome/common/importer/edge_importer_utils_win.cc
new file mode 100644
index 00000000000..c92159f1405
--- /dev/null
+++ b/chromium/chrome/common/importer/edge_importer_utils_win.cc
@@ -0,0 +1,91 @@
+// Copyright 2015 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.
+
+#include "chrome/common/importer/edge_importer_utils_win.h"
+
+#include <Shlobj.h>
+
+#include "base/files/file.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/win/registry.h"
+#include "base/win/windows_version.h"
+#include "chrome/common/importer/importer_test_registry_overrider_win.h"
+
+namespace {
+
+const base::char16 kEdgeSettingsMainKey[] = L"MicrosoftEdge\\Main";
+
+const base::char16 kEdgePackageName[] =
+ L"microsoft.microsoftedge_8wekyb3d8bbwe";
+
+// We assume at the moment that the package name never changes for Edge.
+base::string16 GetEdgePackageName() {
+ return kEdgePackageName;
+}
+
+base::string16 GetEdgeRegistryKey(const base::string16& key_name) {
+ base::string16 registry_key =
+ L"Software\\Classes\\Local Settings\\"
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\AppContainer\\"
+ L"Storage\\";
+ registry_key += GetEdgePackageName();
+ registry_key += L"\\";
+ registry_key += key_name;
+ return registry_key;
+}
+
+base::string16 GetPotentiallyOverridenEdgeKey(
+ const base::string16& desired_key_path) {
+ base::string16 test_registry_override(
+ ImporterTestRegistryOverrider::GetTestRegistryOverride());
+ return test_registry_override.empty() ? GetEdgeRegistryKey(desired_key_path)
+ : test_registry_override;
+}
+
+} // namespace
+
+namespace importer {
+
+base::string16 GetEdgeSettingsKey() {
+ return GetPotentiallyOverridenEdgeKey(kEdgeSettingsMainKey);
+}
+
+base::FilePath GetEdgeDataFilePath() {
+ wchar_t buffer[MAX_PATH];
+ if (::SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT,
+ buffer) != S_OK)
+ return base::FilePath();
+
+ base::FilePath base_path(buffer);
+ base::string16 rel_path = L"Packages\\";
+ rel_path += GetEdgePackageName();
+ rel_path += L"\\AC\\MicrosoftEdge\\User\\Default";
+ return base_path.Append(rel_path);
+}
+
+bool IsEdgeFavoritesLegacyMode() {
+ base::win::RegKey key(HKEY_CURRENT_USER, GetEdgeSettingsKey().c_str(),
+ KEY_READ);
+ DWORD ese_enabled = 0;
+ // Check whether Edge is using the new Extensible Store Engine (ESE) format
+ // for its favorites.
+
+ if (key.ReadValueDW(L"FavoritesESEEnabled", &ese_enabled) == ERROR_SUCCESS)
+ return !ese_enabled;
+ // If the registry key is missing, check the Windows version.
+ // Edge switched to ESE in Windows 10 Build 10565 (somewhere between
+ // Windows 10 RTM and Windows 10 November 1511 Update).
+ return base::win::GetVersion() < base::win::Version::WIN10_TH2;
+}
+
+bool EdgeImporterCanImport() {
+ base::File::Info file_info;
+ if (base::win::GetVersion() < base::win::Version::WIN10)
+ return false;
+ return base::GetFileInfo(GetEdgeDataFilePath(), &file_info) &&
+ file_info.is_directory;
+}
+
+} // namespace importer
diff --git a/chromium/chrome/common/importer/edge_importer_utils_win.h b/chromium/chrome/common/importer/edge_importer_utils_win.h
new file mode 100644
index 00000000000..4d54be7cdc0
--- /dev/null
+++ b/chromium/chrome/common/importer/edge_importer_utils_win.h
@@ -0,0 +1,28 @@
+// Copyright 2015 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.
+
+#ifndef CHROME_COMMON_IMPORTER_EDGE_IMPORTER_UTILS_WIN_H_
+#define CHROME_COMMON_IMPORTER_EDGE_IMPORTER_UTILS_WIN_H_
+
+#include "base/files/file_path.h"
+#include "base/strings/string16.h"
+
+namespace importer {
+
+// Returns the key to be used in HKCU to look for Edge's settings.
+// Overridable by tests via ImporterTestRegistryOverrider.
+base::string16 GetEdgeSettingsKey();
+
+// Returns the data path for the Edge browser. Returns an empty path on error.
+base::FilePath GetEdgeDataFilePath();
+
+// Returns true if Edge favorites is currently in legacy (pre-Edge 13) mode.
+bool IsEdgeFavoritesLegacyMode();
+
+// Returns true if the Edge browser is installed and available for import.
+bool EdgeImporterCanImport();
+
+} // namespace importer
+
+#endif // CHROME_COMMON_IMPORTER_EDGE_IMPORTER_UTILS_WIN_H_
diff --git a/chromium/chrome/common/importer/firefox_importer_utils.cc b/chromium/chrome/common/importer/firefox_importer_utils.cc
new file mode 100644
index 00000000000..e1f5ada7771
--- /dev/null
+++ b/chromium/chrome/common/importer/firefox_importer_utils.cc
@@ -0,0 +1,330 @@
+// Copyright (c) 2012 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.
+
+#include "chrome/common/importer/firefox_importer_utils.h"
+
+#include <stddef.h>
+
+#include <algorithm>
+#include <map>
+#include <string>
+
+#include "base/files/file_util.h"
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_split.h"
+#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/values.h"
+#include "build/build_config.h"
+#include "chrome/common/ini_parser.h"
+#include "chrome/grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "url/gurl.h"
+
+namespace {
+
+// Retrieves the file system path of the profile name.
+base::FilePath GetProfilePath(const base::DictionaryValue& root,
+ const std::string& profile_name) {
+ base::string16 path16;
+ std::string is_relative;
+ if (!root.GetStringASCII(profile_name + ".IsRelative", &is_relative) ||
+ !root.GetString(profile_name + ".Path", &path16))
+ return base::FilePath();
+
+#if defined(OS_WIN)
+ base::ReplaceSubstringsAfterOffset(
+ &path16, 0, base::ASCIIToUTF16("/"), base::ASCIIToUTF16("\\"));
+#endif
+ base::FilePath path = base::FilePath::FromUTF16Unsafe(path16);
+
+ // IsRelative=1 means the folder path would be relative to the
+ // path of profiles.ini. IsRelative=0 refers to a custom profile
+ // location.
+ if (is_relative == "1")
+ path = GetProfilesINI().DirName().Append(path);
+
+ return path;
+}
+
+// Checks if the named profile is the default profile.
+bool IsDefaultProfile(const base::DictionaryValue& root,
+ const std::string& profile_name) {
+ std::string is_default;
+ root.GetStringASCII(profile_name + ".Default", &is_default);
+ return is_default == "1";
+}
+
+} // namespace
+
+base::FilePath GetFirefoxProfilePath() {
+ base::FilePath ini_file = GetProfilesINI();
+ std::string content;
+ base::ReadFileToString(ini_file, &content);
+ DictionaryValueINIParser ini_parser;
+ ini_parser.Parse(content);
+ return GetFirefoxProfilePathFromDictionary(ini_parser.root());
+}
+
+base::FilePath GetFirefoxProfilePathFromDictionary(
+ const base::DictionaryValue& root) {
+ std::vector<std::string> profiles;
+ for (int i = 0; ; ++i) {
+ std::string current_profile = base::StringPrintf("Profile%d", i);
+ if (root.HasKey(current_profile)) {
+ profiles.push_back(current_profile);
+ } else {
+ // Profiles are continuously numbered. So we exit when we can't
+ // find the i-th one.
+ break;
+ }
+ }
+
+ if (profiles.empty())
+ return base::FilePath();
+
+ // When multiple profiles exist, the path to the default profile is returned,
+ // since the other profiles are used mostly by developers for testing.
+ for (std::vector<std::string>::const_iterator it = profiles.begin();
+ it != profiles.end(); ++it)
+ if (IsDefaultProfile(root, *it))
+ return GetProfilePath(root, *it);
+
+ // If no default profile is found, the path to Profile0 will be returned.
+ return GetProfilePath(root, profiles.front());
+}
+
+#if defined(OS_MACOSX)
+// Find the "*.app" component of the path and build up from there.
+// The resulting path will be .../Firefox.app/Contents/MacOS.
+// We do this because we don't trust LastAppDir to always be
+// this particular path, without any subdirs, and we want to make
+// our assumption about Firefox's root being in that path explicit.
+bool ComposeMacAppPath(const std::string& path_from_file,
+ base::FilePath* output) {
+ base::FilePath path(path_from_file);
+ typedef std::vector<base::FilePath::StringType> ComponentVector;
+ ComponentVector path_components;
+ path.GetComponents(&path_components);
+ if (path_components.empty())
+ return false;
+ // The first path component is special because it may be absolute. Calling
+ // Append with an absolute path component will trigger an assert, so we
+ // must handle it differently and initialize output with it.
+ *output = base::FilePath(path_components[0]);
+ // Append next path components untill we find the *.app component. When we do,
+ // append Contents/MacOS.
+ for (size_t i = 1; i < path_components.size(); ++i) {
+ *output = output->Append(path_components[i]);
+ if (base::EndsWith(path_components[i], ".app",
+ base::CompareCase::SENSITIVE)) {
+ *output = output->Append("Contents");
+ *output = output->Append("MacOS");
+ return true;
+ }
+ }
+ LOG(ERROR) << path_from_file << " doesn't look like a valid Firefox "
+ << "installation path: missing /*.app/ directory.";
+ return false;
+}
+#endif // OS_MACOSX
+
+bool GetFirefoxVersionAndPathFromProfile(const base::FilePath& profile_path,
+ int* version,
+ base::FilePath* app_path) {
+ bool ret = false;
+ base::FilePath compatibility_file =
+ profile_path.AppendASCII("compatibility.ini");
+ std::string content;
+ base::ReadFileToString(compatibility_file, &content);
+ base::ReplaceSubstringsAfterOffset(&content, 0, "\r\n", "\n");
+
+ for (const std::string& line : base::SplitString(
+ content, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ if (line.empty() || line[0] == '#' || line[0] == ';')
+ continue;
+ size_t equal = line.find('=');
+ if (equal != std::string::npos) {
+ std::string key = line.substr(0, equal);
+ if (key == "LastVersion") {
+ base::StringToInt(line.substr(equal + 1), version);
+ ret = true;
+ } else if (key == "LastAppDir") {
+ // TODO(evanm): If the path in question isn't convertible to
+ // UTF-8, what does Firefox do? If it puts raw bytes in the
+ // file, we could go straight from bytes -> filepath;
+ // otherwise, we're out of luck here.
+#if defined(OS_MACOSX)
+ // Extract path from "LastAppDir=/actual/path"
+ size_t separator_pos = line.find_first_of('=');
+ const std::string& path_from_ini = line.substr(separator_pos + 1);
+ if (!ComposeMacAppPath(path_from_ini, app_path))
+ return false;
+#else // !OS_MACOSX
+ *app_path = base::FilePath::FromUTF8Unsafe(line.substr(equal + 1));
+#endif // OS_MACOSX
+ }
+ }
+ }
+ return ret;
+}
+
+bool ReadPrefFile(const base::FilePath& path, std::string* content) {
+ if (content == NULL)
+ return false;
+
+ base::ReadFileToString(path, content);
+
+ if (content->empty()) {
+ LOG(WARNING) << "Firefox preference file " << path.value() << " is empty.";
+ return false;
+ }
+
+ return true;
+}
+
+std::string ReadBrowserConfigProp(const base::FilePath& app_path,
+ const std::string& pref_key) {
+ std::string content;
+ if (!ReadPrefFile(app_path.AppendASCII("browserconfig.properties"), &content))
+ return std::string();
+
+ // This file has the syntax: key=value.
+ size_t prop_index = content.find(pref_key + "=");
+ if (prop_index == std::string::npos)
+ return std::string();
+
+ size_t start = prop_index + pref_key.length();
+ size_t stop = std::string::npos;
+ if (start != std::string::npos)
+ stop = content.find("\n", start + 1);
+
+ if (start == std::string::npos ||
+ stop == std::string::npos || (start == stop)) {
+ LOG(WARNING) << "Firefox property " << pref_key << " could not be parsed.";
+ return std::string();
+ }
+
+ return content.substr(start + 1, stop - start - 1);
+}
+
+std::string ReadPrefsJsValue(const base::FilePath& profile_path,
+ const std::string& pref_key) {
+ std::string content;
+ if (!ReadPrefFile(profile_path.AppendASCII("prefs.js"), &content))
+ return std::string();
+
+ return GetPrefsJsValue(content, pref_key);
+}
+
+GURL GetHomepage(const base::FilePath& profile_path) {
+ std::string home_page_list =
+ ReadPrefsJsValue(profile_path, "browser.startup.homepage");
+
+ size_t seperator = home_page_list.find_first_of('|');
+ if (seperator == std::string::npos)
+ return GURL(home_page_list);
+
+ return GURL(home_page_list.substr(0, seperator));
+}
+
+bool IsDefaultHomepage(const GURL& homepage, const base::FilePath& app_path) {
+ if (!homepage.is_valid())
+ return false;
+
+ std::string default_homepages =
+ ReadBrowserConfigProp(app_path, "browser.startup.homepage");
+
+ size_t seperator = default_homepages.find_first_of('|');
+ if (seperator == std::string::npos)
+ return homepage.spec() == GURL(default_homepages).spec();
+
+ // Crack the string into separate homepage urls.
+ for (const std::string& url : base::SplitString(
+ default_homepages, "|",
+ base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ if (homepage.spec() == GURL(url).spec())
+ return true;
+ }
+
+ return false;
+}
+
+std::string GetPrefsJsValue(const std::string& content,
+ const std::string& pref_key) {
+ // This file has the syntax: user_pref("key", value);
+ std::string search_for = std::string("user_pref(\"") + pref_key +
+ std::string("\", ");
+ size_t prop_index = content.find(search_for);
+ if (prop_index == std::string::npos)
+ return std::string();
+
+ size_t start = prop_index + search_for.length();
+ size_t stop = std::string::npos;
+ if (start != std::string::npos) {
+ // Stop at the last ')' on this line.
+ stop = content.find("\n", start + 1);
+ stop = content.rfind(")", stop);
+ }
+
+ if (start == std::string::npos || stop == std::string::npos ||
+ stop < start) {
+ LOG(WARNING) << "Firefox property " << pref_key << " could not be parsed.";
+ return std::string();
+ }
+
+ // String values have double quotes we don't need to return to the caller.
+ if (content[start] == '\"' && content[stop - 1] == '\"') {
+ ++start;
+ --stop;
+ }
+
+ return content.substr(start, stop - start);
+}
+
+// The branding name is obtained from the application.ini file from the Firefox
+// application directory. A sample application.ini file is the following:
+// [App]
+// Vendor=Mozilla
+// Name=Iceweasel
+// Profile=mozilla/firefox
+// Version=3.5.16
+// BuildID=20120421070307
+// Copyright=Copyright (c) 1998 - 2010 mozilla.org
+// ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
+// .........................................
+// In this example the function returns "Iceweasel" (or a localized equivalent).
+base::string16 GetFirefoxImporterName(const base::FilePath& app_path) {
+ const base::FilePath app_ini_file = app_path.AppendASCII("application.ini");
+ std::string branding_name;
+ if (base::PathExists(app_ini_file)) {
+ std::string content;
+ base::ReadFileToString(app_ini_file, &content);
+
+ const std::string name_attr("Name=");
+ bool in_app_section = false;
+ for (const base::StringPiece& line : base::SplitStringPiece(
+ content, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ if (line == "[App]") {
+ in_app_section = true;
+ } else if (in_app_section) {
+ if (base::StartsWith(line, name_attr, base::CompareCase::SENSITIVE)) {
+ line.substr(name_attr.size()).CopyToString(&branding_name);
+ break;
+ }
+ if (line.length() > 0 && line[0] == '[') {
+ // No longer in the [App] section.
+ break;
+ }
+ }
+ }
+ }
+
+ branding_name = base::ToLowerASCII(branding_name);
+ if (branding_name.find("iceweasel") != std::string::npos)
+ return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_ICEWEASEL);
+ return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX);
+}
diff --git a/chromium/chrome/common/importer/firefox_importer_utils.h b/chromium/chrome/common/importer/firefox_importer_utils.h
new file mode 100644
index 00000000000..ec57c179271
--- /dev/null
+++ b/chromium/chrome/common/importer/firefox_importer_utils.h
@@ -0,0 +1,92 @@
+// Copyright (c) 2012 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.
+
+#ifndef CHROME_COMMON_IMPORTER_FIREFOX_IMPORTER_UTILS_H_
+#define CHROME_COMMON_IMPORTER_FIREFOX_IMPORTER_UTILS_H_
+
+#include <string>
+#include <vector>
+
+#include "base/strings/string16.h"
+#include "build/build_config.h"
+
+class GURL;
+
+namespace base {
+class DictionaryValue;
+class FilePath;
+}
+
+#if defined(OS_WIN)
+// Detects which version of Firefox is installed from registry. Returns its
+// major version, and drops the minor version. Returns 0 if failed. If there are
+// indicators of both Firefox 2 and Firefox 3 it is biased to return the biggest
+// version.
+int GetCurrentFirefoxMajorVersionFromRegistry();
+
+// Detects where Firefox lives. Returns an empty path if Firefox is not
+// installed.
+base::FilePath GetFirefoxInstallPathFromRegistry();
+#endif // OS_WIN
+
+#if defined(OS_MACOSX)
+// Get the directory in which the Firefox .dylibs live, we need to load these
+// in order to decoded FF profile passwords.
+// The Path is usuall FF App Bundle/Contents/Mac OS/
+// Returns empty path on failure.
+base::FilePath GetFirefoxDylibPath();
+#endif // OS_MACOSX
+
+// Returns the path to the Firefox profile.
+base::FilePath GetFirefoxProfilePath();
+
+// Returns the path to the Firefox profile, using a custom dictionary.
+// Exposed for testing.
+base::FilePath GetFirefoxProfilePathFromDictionary(
+ const base::DictionaryValue& root);
+
+// Detects version of Firefox and installation path for the given Firefox
+// profile.
+bool GetFirefoxVersionAndPathFromProfile(const base::FilePath& profile_path,
+ int* version,
+ base::FilePath* app_path);
+
+// Gets the full path of the profiles.ini file. This file records the profiles
+// that can be used by Firefox. Returns an empty path if failed.
+base::FilePath GetProfilesINI();
+
+// Parses the profile.ini file, and stores its information in |root|.
+// This file is a plain-text file. Key/value pairs are stored one per line, and
+// they are separated in different sections. For example:
+// [General]
+// StartWithLastProfile=1
+//
+// [Profile0]
+// Name=default
+// IsRelative=1
+// Path=Profiles/abcdefeg.default
+// We set "[value]" in path "<Section>.<Key>". For example, the path
+// "Genenral.StartWithLastProfile" has the value "1".
+void ParseProfileINI(const base::FilePath& file, base::DictionaryValue* root);
+
+// Returns the home page set in Firefox in a particular profile.
+GURL GetHomepage(const base::FilePath& profile_path);
+
+// Checks to see if this home page is a default home page, as specified by
+// the resource file browserconfig.properties in the Firefox application
+// directory.
+bool IsDefaultHomepage(const GURL& homepage, const base::FilePath& app_path);
+
+// Parses the value of a particular firefox preference from a string that is the
+// contents of the prefs file.
+std::string GetPrefsJsValue(const std::string& prefs,
+ const std::string& pref_key);
+
+// Returns the localized Firefox branding name.
+// This is useful to differentiate between Firefox and Iceweasel.
+// If anything goes wrong while trying to obtain the branding name,
+// the function assumes it's Firefox.
+base::string16 GetFirefoxImporterName(const base::FilePath& app_path);
+
+#endif // CHROME_COMMON_IMPORTER_FIREFOX_IMPORTER_UTILS_H_
diff --git a/chromium/chrome/common/importer/firefox_importer_utils_linux.cc b/chromium/chrome/common/importer/firefox_importer_utils_linux.cc
new file mode 100644
index 00000000000..1935dcb3b96
--- /dev/null
+++ b/chromium/chrome/common/importer/firefox_importer_utils_linux.cc
@@ -0,0 +1,25 @@
+// Copyright (c) 2009 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.
+
+#include "chrome/common/importer/firefox_importer_utils.h"
+
+#include "base/base_paths.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/path_service.h"
+
+base::FilePath GetProfilesINI() {
+ base::FilePath ini_file;
+ // The default location of the profile folder containing user data is
+ // under user HOME directory in .mozilla/firefox folder on Linux.
+ base::FilePath home;
+ base::PathService::Get(base::DIR_HOME, &home);
+ if (!home.empty()) {
+ ini_file = home.Append(".mozilla/firefox/profiles.ini");
+ }
+ if (base::PathExists(ini_file))
+ return ini_file;
+
+ return base::FilePath();
+}
diff --git a/chromium/chrome/common/importer/firefox_importer_utils_mac.mm b/chromium/chrome/common/importer/firefox_importer_utils_mac.mm
new file mode 100644
index 00000000000..1152a5645ed
--- /dev/null
+++ b/chromium/chrome/common/importer/firefox_importer_utils_mac.mm
@@ -0,0 +1,45 @@
+// Copyright (c) 2011 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.
+
+#include <Cocoa/Cocoa.h>
+#include <sys/param.h>
+
+#include "chrome/common/importer/firefox_importer_utils.h"
+
+#include "base/files/file_util.h"
+#include "base/mac/foundation_util.h"
+#include "base/path_service.h"
+
+base::FilePath GetProfilesINI() {
+ base::FilePath app_data_path;
+ if (!base::PathService::Get(base::DIR_APP_DATA, &app_data_path)) {
+ return base::FilePath();
+ }
+ base::FilePath ini_file =
+ app_data_path.Append("Firefox").Append("profiles.ini");
+ if (!base::PathExists(ini_file)) {
+ return base::FilePath();
+ }
+ return ini_file;
+}
+
+base::FilePath GetFirefoxDylibPath() {
+ base::ScopedCFTypeRef<CFErrorRef> out_err;
+ base::ScopedCFTypeRef<CFArrayRef> app_urls(
+ LSCopyApplicationURLsForBundleIdentifier(CFSTR("org.mozilla.firefox"),
+ out_err.InitializeInto()));
+ if (out_err || CFArrayGetCount(app_urls) == 0) {
+ return base::FilePath();
+ }
+ CFURLRef app_url =
+ base::mac::CFCastStrict<CFURLRef>(CFArrayGetValueAtIndex(app_urls, 0));
+ NSBundle* ff_bundle =
+ [NSBundle bundleWithPath:[base::mac::CFToNSCast(app_url) path]];
+ NSString *ff_library_path =
+ [[ff_bundle executablePath] stringByDeletingLastPathComponent];
+ char buf[MAXPATHLEN];
+ if (![ff_library_path getFileSystemRepresentation:buf maxLength:sizeof(buf)])
+ return base::FilePath();
+ return base::FilePath(buf);
+}
diff --git a/chromium/chrome/common/importer/firefox_importer_utils_unittest.cc b/chromium/chrome/common/importer/firefox_importer_utils_unittest.cc
new file mode 100644
index 00000000000..6fdf99de260
--- /dev/null
+++ b/chromium/chrome/common/importer/firefox_importer_utils_unittest.cc
@@ -0,0 +1,163 @@
+// Copyright 2013 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.
+
+#include "chrome/common/importer/firefox_importer_utils.h"
+
+#include <stddef.h>
+
+#include "base/files/file_util.h"
+#include "base/files/scoped_temp_dir.h"
+#include "base/stl_util.h"
+#include "base/values.h"
+#include "chrome/grit/generated_resources.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+struct GetPrefsJsValueCase {
+ std::string prefs_content;
+ std::string pref_name;
+ std::string pref_value;
+} GetPrefsJsValueCases[] = {
+ // Basic case. Single pref, unquoted value.
+ { "user_pref(\"foo.bar\", 1);", "foo.bar", "1" },
+ // Value is quoted. Quotes should be stripped.
+ { "user_pref(\"foo.bar\", \"1\");", "foo.bar", "1" },
+ // Value has parens.
+ { "user_pref(\"foo.bar\", \"Value (detail)\");",
+ "foo.bar", "Value (detail)" },
+ // Multi-line case.
+ { "user_pref(\"foo.bar\", 1);\n"
+ "user_pref(\"foo.baz\", 2);\n"
+ "user_pref(\"foo.bag\", 3);",
+ "foo.baz", "2" },
+ // Malformed content.
+ { "user_pref(\"foo.bar\", 1);\n"
+ "user_pref(\"foo.baz\", 2;\n"
+ "user_pref(\"foo.bag\", 3);",
+ "foo.baz", "" },
+ // Malformed content.
+ { "uesr_pref(\"foo.bar\", 1);", "foo.bar", "" },
+};
+
+struct GetFirefoxImporterNameCase {
+ std::string app_ini_content;
+ int resource_id;
+} GetFirefoxImporterNameCases[] = {
+ // Basic case
+ { "[App]\n"
+ "Vendor=Mozilla\n"
+ "Name=iceweasel\n"
+ "Version=10.0.6\n"
+ "BuildID=20120717115048\n"
+ "ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
+ IDS_IMPORT_FROM_ICEWEASEL },
+ // Whitespace
+ { " \t[App] \n"
+ "Vendor=Mozilla\n"
+ " Name=Firefox\t \r\n"
+ "Version=10.0.6\n",
+ IDS_IMPORT_FROM_FIREFOX },
+ // No Name setting
+ { "[App]\n"
+ "Vendor=Mozilla\n"
+ "Version=10.0.6\n"
+ "BuildID=20120717115048\n"
+ "ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
+ IDS_IMPORT_FROM_FIREFOX },
+ // No [App] section
+ { "[Foo]\n"
+ "Vendor=Mozilla\n"
+ "Name=Foo\n",
+ IDS_IMPORT_FROM_FIREFOX },
+ // Multiple Name settings in different sections
+ { "[Foo]\n"
+ "Vendor=Mozilla\n"
+ "Name=Firefox\n"
+ "[App]\n"
+ "Profile=mozilla/firefox\n"
+ "Name=iceweasel\n"
+ "[Bar]\n"
+ "Name=Bar\n"
+ "ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
+ IDS_IMPORT_FROM_ICEWEASEL },
+ // Case-insensitivity
+ { "[App]\n"
+ "Vendor=Mozilla\n"
+ "Name=IceWeasel\n"
+ "Version=10.0.6\n",
+ IDS_IMPORT_FROM_ICEWEASEL },
+ // Empty file
+ { "", IDS_IMPORT_FROM_FIREFOX }
+};
+
+} // anonymous namespace
+
+TEST(FirefoxImporterUtilsTest, GetPrefsJsValue) {
+ for (size_t i = 0; i < base::size(GetPrefsJsValueCases); ++i) {
+ EXPECT_EQ(
+ GetPrefsJsValueCases[i].pref_value,
+ GetPrefsJsValue(GetPrefsJsValueCases[i].prefs_content,
+ GetPrefsJsValueCases[i].pref_name));
+ }
+}
+
+TEST(FirefoxImporterUtilsTest, GetFirefoxImporterName) {
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ const base::FilePath app_ini_file(
+ temp_dir.GetPath().AppendASCII("application.ini"));
+ for (size_t i = 0; i < base::size(GetFirefoxImporterNameCases); ++i) {
+ base::WriteFile(app_ini_file,
+ GetFirefoxImporterNameCases[i].app_ini_content.c_str(),
+ GetFirefoxImporterNameCases[i].app_ini_content.size());
+ EXPECT_EQ(
+ GetFirefoxImporterName(temp_dir.GetPath()),
+ l10n_util::GetStringUTF16(GetFirefoxImporterNameCases[i].resource_id));
+ }
+ EXPECT_EQ(l10n_util::GetStringUTF16(
+ IDS_IMPORT_FROM_FIREFOX),
+ GetFirefoxImporterName(base::FilePath(
+ FILE_PATH_LITERAL("/invalid/path"))));
+}
+
+TEST(FirefoxImporterUtilsTest, GetFirefoxProfilePath) {
+ base::DictionaryValue no_profiles;
+ EXPECT_EQ("",
+ GetFirefoxProfilePathFromDictionary(no_profiles).MaybeAsASCII());
+
+ base::DictionaryValue single_profile;
+ single_profile.SetString("Profile0.Path", "first");
+ single_profile.SetString("Profile0.IsRelative", "0");
+ single_profile.SetString("Profile0.Default", "1");
+ EXPECT_EQ("first",
+ GetFirefoxProfilePathFromDictionary(single_profile).MaybeAsASCII());
+
+ base::DictionaryValue no_default;
+ no_default.SetString("Profile0.Path", "first");
+ no_default.SetString("Profile0.IsRelative", "0");
+ no_default.SetString("Profile1.Path", "second");
+ no_default.SetString("Profile1.IsRelative", "0");
+ EXPECT_EQ("first",
+ GetFirefoxProfilePathFromDictionary(no_default).MaybeAsASCII());
+
+ base::DictionaryValue default_first;
+ default_first.SetString("Profile0.Path", "first");
+ default_first.SetString("Profile0.IsRelative", "0");
+ default_first.SetString("Profile0.Default", "1");
+ default_first.SetString("Profile1.Path", "second");
+ default_first.SetString("Profile1.IsRelative", "0");
+ EXPECT_EQ("first",
+ GetFirefoxProfilePathFromDictionary(default_first).MaybeAsASCII());
+
+ base::DictionaryValue default_second;
+ default_second.SetString("Profile0.Path", "first");
+ default_second.SetString("Profile0.IsRelative", "0");
+ default_second.SetString("Profile1.Path", "second");
+ default_second.SetString("Profile1.IsRelative", "0");
+ default_second.SetString("Profile1.Default", "1");
+ EXPECT_EQ("second",
+ GetFirefoxProfilePathFromDictionary(default_second).MaybeAsASCII());
+}
diff --git a/chromium/chrome/common/importer/firefox_importer_utils_win.cc b/chromium/chrome/common/importer/firefox_importer_utils_win.cc
new file mode 100644
index 00000000000..a44104f9b26
--- /dev/null
+++ b/chromium/chrome/common/importer/firefox_importer_utils_win.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 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.
+
+#include "chrome/common/importer/firefox_importer_utils.h"
+
+#include <shlobj.h>
+
+#include "base/files/file_util.h"
+#include "base/path_service.h"
+#include "base/strings/string16.h"
+#include "base/win/registry.h"
+
+namespace {
+
+// NOTE: Keep these in order since we need test all those paths according
+// to priority. For example. One machine has multiple users. One non-admin
+// user installs Firefox 2, which causes there is a Firefox2 entry under HKCU.
+// One admin user installs Firefox 3, which causes there is a Firefox 3 entry
+// under HKLM. So when the non-admin user log in, we should deal with Firefox 2
+// related data instead of Firefox 3.
+const HKEY kFireFoxRegistryPaths[] = {HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE};
+
+constexpr const wchar_t* kFirefoxPath = L"Software\\Mozilla\\Mozilla Firefox";
+constexpr const wchar_t* kCurrentVersion = L"CurrentVersion";
+
+} // namespace
+
+int GetCurrentFirefoxMajorVersionFromRegistry() {
+ TCHAR ver_buffer[128];
+ DWORD ver_buffer_length = sizeof(ver_buffer);
+ int highest_version = 0;
+ // When installing Firefox with admin account, the product keys will be
+ // written under HKLM\Mozilla. Otherwise it the keys will be written under
+ // HKCU\Mozilla.
+ for (const HKEY kFireFoxRegistryPath : kFireFoxRegistryPaths) {
+ base::win::RegKey reg_key(kFireFoxRegistryPath, kFirefoxPath, KEY_READ);
+
+ LONG result = reg_key.ReadValue(kCurrentVersion, ver_buffer,
+ &ver_buffer_length, NULL);
+ if (result != ERROR_SUCCESS)
+ continue;
+ highest_version = std::max(highest_version, _wtoi(ver_buffer));
+ }
+ return highest_version;
+}
+
+base::FilePath GetFirefoxInstallPathFromRegistry() {
+ // Detects the path that Firefox is installed in.
+ base::string16 registry_path = kFirefoxPath;
+ wchar_t buffer[MAX_PATH];
+ DWORD buffer_length = sizeof(buffer);
+ base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, registry_path.c_str(),
+ KEY_READ);
+ LONG result = reg_key.ReadValue(kCurrentVersion, buffer,
+ &buffer_length, NULL);
+ if (result != ERROR_SUCCESS)
+ return base::FilePath();
+
+ registry_path += L"\\" + base::string16(buffer) + L"\\Main";
+ buffer_length = sizeof(buffer);
+ base::win::RegKey reg_key_directory(HKEY_LOCAL_MACHINE,
+ registry_path.c_str(), KEY_READ);
+ result = reg_key_directory.ReadValue(L"Install Directory", buffer,
+ &buffer_length, NULL);
+
+ return (result != ERROR_SUCCESS) ? base::FilePath() : base::FilePath(buffer);
+}
+
+base::FilePath GetProfilesINI() {
+ base::FilePath ini_file;
+ // The default location of the profile folder containing user data is
+ // under the "Application Data" folder in Windows XP, Vista, and 7.
+ if (!base::PathService::Get(base::DIR_APP_DATA, &ini_file))
+ return base::FilePath();
+
+ ini_file = ini_file.AppendASCII("Mozilla");
+ ini_file = ini_file.AppendASCII("Firefox");
+ ini_file = ini_file.AppendASCII("profiles.ini");
+
+ return base::PathExists(ini_file) ? ini_file : base::FilePath();
+}
diff --git a/chromium/chrome/common/importer/ie_importer_utils_win.cc b/chromium/chrome/common/importer/ie_importer_utils_win.cc
new file mode 100644
index 00000000000..726e5b01668
--- /dev/null
+++ b/chromium/chrome/common/importer/ie_importer_utils_win.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2013 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.
+
+#include "chrome/common/importer/ie_importer_utils_win.h"
+
+#include "chrome/common/importer/importer_test_registry_overrider_win.h"
+
+namespace {
+
+const base::char16 kIEFavoritesOrderKey[] =
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\"
+ L"MenuOrder\\Favorites";
+
+const base::char16 kIEStorage2Key[] =
+ L"Software\\Microsoft\\Internet Explorer\\IntelliForms\\Storage2";
+
+const base::char16 kIESettingsMainKey[] =
+ L"Software\\Microsoft\\Internet Explorer\\Main";
+
+base::string16 GetPotentiallyOverridenIEKey(
+ const base::string16& desired_key_path) {
+ base::string16 test_reg_override(
+ ImporterTestRegistryOverrider::GetTestRegistryOverride());
+ return test_reg_override.empty() ? desired_key_path : test_reg_override;
+}
+
+} // namespace
+
+namespace importer {
+
+base::string16 GetIEFavoritesOrderKey() {
+ // Return kIEFavoritesOrderKey unless an override has been set for tests.
+ return GetPotentiallyOverridenIEKey(kIEFavoritesOrderKey);
+}
+
+base::string16 GetIE7PasswordsKey() {
+ // Return kIEStorage2Key unless an override has been set for tests.
+ return GetPotentiallyOverridenIEKey(kIEStorage2Key);
+}
+
+base::string16 GetIESettingsKey() {
+ // Return kIESettingsMainKey unless an override has been set for tests.
+ return GetPotentiallyOverridenIEKey(kIESettingsMainKey);
+}
+
+} // namespace importer
+
diff --git a/chromium/chrome/common/importer/ie_importer_utils_win.h b/chromium/chrome/common/importer/ie_importer_utils_win.h
new file mode 100644
index 00000000000..8e43bbaee4c
--- /dev/null
+++ b/chromium/chrome/common/importer/ie_importer_utils_win.h
@@ -0,0 +1,26 @@
+// Copyright (c) 2013 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.
+
+#ifndef CHROME_COMMON_IMPORTER_IE_IMPORTER_UTILS_WIN_H_
+#define CHROME_COMMON_IMPORTER_IE_IMPORTER_UTILS_WIN_H_
+
+#include "base/strings/string16.h"
+
+namespace importer {
+
+// Returns the key to be used in HKCU to look for IE's favorites order blob.
+// Overridable by tests via ImporterTestRegistryOverrider.
+base::string16 GetIEFavoritesOrderKey();
+
+// Returns the key to be used in HKCU to look for IE7 passwords.
+// Overridable by tests via ImporterTestRegistryOverrider.
+base::string16 GetIE7PasswordsKey();
+
+// Returns the key to be used in HKCU to look for IE settings.
+// Overridable by tests via ImporterTestRegistryOverrider.
+base::string16 GetIESettingsKey();
+
+} // namespace importer
+
+#endif // CHROME_COMMON_IMPORTER_IE_IMPORTER_UTILS_WIN_H_
diff --git a/chromium/chrome/common/importer/imported_bookmark_entry.cc b/chromium/chrome/common/importer/imported_bookmark_entry.cc
new file mode 100644
index 00000000000..a82e1cd85c0
--- /dev/null
+++ b/chromium/chrome/common/importer/imported_bookmark_entry.cc
@@ -0,0 +1,24 @@
+// Copyright 2013 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.
+
+#include "chrome/common/importer/imported_bookmark_entry.h"
+
+ImportedBookmarkEntry::ImportedBookmarkEntry()
+ : in_toolbar(false),
+ is_folder(false) {}
+
+ImportedBookmarkEntry::ImportedBookmarkEntry(
+ const ImportedBookmarkEntry& other) = default;
+
+ImportedBookmarkEntry::~ImportedBookmarkEntry() {}
+
+bool ImportedBookmarkEntry::operator==(
+ const ImportedBookmarkEntry& other) const {
+ return (in_toolbar == other.in_toolbar &&
+ is_folder == other.is_folder &&
+ url == other.url &&
+ path == other.path &&
+ title == other.title &&
+ creation_time == other.creation_time);
+}
diff --git a/chromium/chrome/common/importer/imported_bookmark_entry.h b/chromium/chrome/common/importer/imported_bookmark_entry.h
new file mode 100644
index 00000000000..abb9ea0ba3e
--- /dev/null
+++ b/chromium/chrome/common/importer/imported_bookmark_entry.h
@@ -0,0 +1,29 @@
+// Copyright 2013 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.
+
+#ifndef CHROME_COMMON_IMPORTER_IMPORTED_BOOKMARK_ENTRY_H_
+#define CHROME_COMMON_IMPORTER_IMPORTED_BOOKMARK_ENTRY_H_
+
+#include <vector>
+
+#include "base/strings/string16.h"
+#include "base/time/time.h"
+#include "url/gurl.h"
+
+struct ImportedBookmarkEntry {
+ ImportedBookmarkEntry();
+ ImportedBookmarkEntry(const ImportedBookmarkEntry& other);
+ ~ImportedBookmarkEntry();
+
+ bool operator==(const ImportedBookmarkEntry& other) const;
+
+ bool in_toolbar;
+ bool is_folder;
+ GURL url;
+ std::vector<base::string16> path;
+ base::string16 title;
+ base::Time creation_time;
+};
+
+#endif // CHROME_COMMON_IMPORTER_IMPORTED_BOOKMARK_ENTRY_H_
diff --git a/chromium/chrome/common/importer/importer_autofill_form_data_entry.cc b/chromium/chrome/common/importer/importer_autofill_form_data_entry.cc
new file mode 100644
index 00000000000..5dd4c5a3742
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_autofill_form_data_entry.cc
@@ -0,0 +1,11 @@
+// Copyright 2014 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.
+
+#include "chrome/common/importer/importer_autofill_form_data_entry.h"
+
+ImporterAutofillFormDataEntry::ImporterAutofillFormDataEntry() : times_used(0) {
+}
+
+ImporterAutofillFormDataEntry::~ImporterAutofillFormDataEntry() {
+}
diff --git a/chromium/chrome/common/importer/importer_autofill_form_data_entry.h b/chromium/chrome/common/importer/importer_autofill_form_data_entry.h
new file mode 100644
index 00000000000..af35195ae43
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_autofill_form_data_entry.h
@@ -0,0 +1,33 @@
+// Copyright 2014 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.
+
+#ifndef CHROME_COMMON_IMPORTER_IMPORTER_AUTOFILL_FORM_DATA_ENTRY_H_
+#define CHROME_COMMON_IMPORTER_IMPORTER_AUTOFILL_FORM_DATA_ENTRY_H_
+
+#include "base/strings/string16.h"
+#include "base/time/time.h"
+
+// Used as the target for importing form history from other browsers' profiles
+// in the utility process.
+struct ImporterAutofillFormDataEntry {
+ ImporterAutofillFormDataEntry();
+ ~ImporterAutofillFormDataEntry();
+
+ // Name of input element.
+ base::string16 name;
+
+ // Value of input element.
+ base::string16 value;
+
+ // Number of times this name-value pair has been used.
+ int times_used;
+
+ // The date of the first time when this name-value pair was used.
+ base::Time first_used;
+
+ // The date of the last time when this name-value pair was used.
+ base::Time last_used;
+};
+
+#endif // CHROME_COMMON_IMPORTER_IMPORTER_AUTOFILL_FORM_DATA_ENTRY_H_
diff --git a/chromium/chrome/common/importer/importer_bridge.cc b/chromium/chrome/common/importer/importer_bridge.cc
new file mode 100644
index 00000000000..15b7f745cfa
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_bridge.cc
@@ -0,0 +1,9 @@
+// Copyright (c) 2011 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.
+
+#include "chrome/common/importer/importer_bridge.h"
+
+ImporterBridge::ImporterBridge() {}
+
+ImporterBridge::~ImporterBridge() {}
diff --git a/chromium/chrome/common/importer/importer_bridge.h b/chromium/chrome/common/importer/importer_bridge.h
new file mode 100644
index 00000000000..b4250c91d1b
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_bridge.h
@@ -0,0 +1,89 @@
+// Copyright (c) 2012 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.
+
+#ifndef CHROME_COMMON_IMPORTER_IMPORTER_BRIDGE_H_
+#define CHROME_COMMON_IMPORTER_IMPORTER_BRIDGE_H_
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/strings/string16.h"
+#include "build/build_config.h"
+#include "chrome/common/importer/importer_data_types.h"
+#include "chrome/common/importer/importer_url_row.h"
+#include "components/favicon_base/favicon_usage_data.h"
+
+class GURL;
+struct ImportedBookmarkEntry;
+struct ImporterAutofillFormDataEntry;
+
+namespace autofill {
+struct PasswordForm;
+}
+
+namespace importer {
+struct SearchEngineInfo;
+}
+
+class ImporterBridge : public base::RefCountedThreadSafe<ImporterBridge> {
+ public:
+ ImporterBridge();
+
+ virtual void AddBookmarks(
+ const std::vector<ImportedBookmarkEntry>& bookmarks,
+ const base::string16& first_folder_name) = 0;
+
+ virtual void AddHomePage(const GURL& home_page) = 0;
+
+ virtual void SetFavicons(
+ const favicon_base::FaviconUsageDataList& favicons) = 0;
+
+ virtual void SetHistoryItems(const std::vector<ImporterURLRow>& rows,
+ importer::VisitSource visit_source) = 0;
+
+ virtual void SetKeywords(
+ const std::vector<importer::SearchEngineInfo>& search_engines,
+ bool unique_on_host_and_path) = 0;
+
+ // The search_engine_data vector contains XML data retrieved from the Firefox
+ // profile and its sqlite db.
+ virtual void SetFirefoxSearchEnginesXMLData(
+ const std::vector<std::string>& search_engine_data) = 0;
+
+ virtual void SetPasswordForm(const autofill::PasswordForm& form) = 0;
+
+ virtual void SetAutofillFormData(
+ const std::vector<ImporterAutofillFormDataEntry>& entries) = 0;
+
+ // Notifies the coordinator that the import operation has begun.
+ virtual void NotifyStarted() = 0;
+
+ // Notifies the coordinator that the collection of data for the specified
+ // item has begun.
+ virtual void NotifyItemStarted(importer::ImportItem item) = 0;
+
+ // Notifies the coordinator that the collection of data for the specified
+ // item has completed.
+ virtual void NotifyItemEnded(importer::ImportItem item) = 0;
+
+ // Notifies the coordinator that the entire import operation has completed.
+ virtual void NotifyEnded() = 0;
+
+ // For InProcessImporters this calls l10n_util. For ExternalProcessImporters
+ // this calls the set of strings we've ported over to the external process.
+ // It's good to avoid having to create a separate ResourceBundle for the
+ // external import process, since the importer only needs a few strings.
+ virtual base::string16 GetLocalizedString(int message_id) = 0;
+
+ protected:
+ friend class base::RefCountedThreadSafe<ImporterBridge>;
+
+ virtual ~ImporterBridge();
+
+ DISALLOW_COPY_AND_ASSIGN(ImporterBridge);
+};
+
+#endif // CHROME_COMMON_IMPORTER_IMPORTER_BRIDGE_H_
diff --git a/chromium/chrome/common/importer/importer_data_types.cc b/chromium/chrome/common/importer/importer_data_types.cc
new file mode 100644
index 00000000000..25e4444dd05
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_data_types.cc
@@ -0,0 +1,32 @@
+// Copyright 2013 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.
+
+#include "build/build_config.h"
+#include "chrome/common/importer/importer_data_types.h"
+
+namespace importer {
+
+SourceProfile::SourceProfile()
+ : importer_type(TYPE_UNKNOWN),
+ services_supported(0) {
+}
+
+SourceProfile::SourceProfile(const SourceProfile& other) = default;
+
+SourceProfile::~SourceProfile() {
+}
+
+ImporterIE7PasswordInfo::ImporterIE7PasswordInfo() {
+}
+
+ImporterIE7PasswordInfo::ImporterIE7PasswordInfo(
+ const ImporterIE7PasswordInfo& other) = default;
+
+ImporterIE7PasswordInfo::~ImporterIE7PasswordInfo() {
+}
+
+ImporterIE7PasswordInfo& ImporterIE7PasswordInfo::operator=(
+ const ImporterIE7PasswordInfo& other) = default;
+
+} // namespace importer
diff --git a/chromium/chrome/common/importer/importer_data_types.h b/chromium/chrome/common/importer/importer_data_types.h
new file mode 100644
index 00000000000..0fc90c62398
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_data_types.h
@@ -0,0 +1,90 @@
+// Copyright 2013 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.
+
+#ifndef CHROME_COMMON_IMPORTER_IMPORTER_DATA_TYPES_H_
+#define CHROME_COMMON_IMPORTER_IMPORTER_DATA_TYPES_H_
+
+#include <stdint.h>
+
+#include <string>
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "base/strings/string16.h"
+#include "base/time/time.h"
+#include "build/build_config.h"
+#include "chrome/common/importer/importer_type.h"
+#include "url/gurl.h"
+
+// Types needed for importing data from other browsers and the Google Toolbar.
+namespace importer {
+
+// An enumeration of the type of data that can be imported.
+enum ImportItem {
+ NONE = 0,
+ HISTORY = 1 << 0,
+ FAVORITES = 1 << 1,
+ COOKIES = 1 << 2, // Not supported yet.
+ PASSWORDS = 1 << 3,
+ SEARCH_ENGINES = 1 << 4,
+ HOME_PAGE = 1 << 5,
+ AUTOFILL_FORM_DATA = 1 << 6,
+ ALL = (1 << 7) - 1 // All the bits should be 1, hence the -1.
+};
+
+// Information about a profile needed by an importer to do import work.
+struct SourceProfile {
+ SourceProfile();
+ SourceProfile(const SourceProfile& other);
+ ~SourceProfile();
+
+ base::string16 importer_name;
+ ImporterType importer_type;
+ base::FilePath source_path;
+ base::FilePath app_path;
+ uint16_t services_supported; // Bitmask of ImportItem.
+ // The application locale. Stored because we can only access it from the UI
+ // thread on the browser process. This is only used by the Firefox importer.
+ std::string locale;
+};
+
+// Contains information needed for importing search engine urls.
+struct SearchEngineInfo {
+ // |url| is a string instead of a GURL since it may not actually be a valid
+ // GURL directly (e.g. for "http://%s.com").
+ base::string16 url;
+ base::string16 keyword;
+ base::string16 display_name;
+};
+
+// Contains the information read from the IE7/IE8 Storage2 key in the registry.
+struct ImporterIE7PasswordInfo {
+ ImporterIE7PasswordInfo();
+ ImporterIE7PasswordInfo(const ImporterIE7PasswordInfo& other);
+ ~ImporterIE7PasswordInfo();
+ ImporterIE7PasswordInfo& operator=(const ImporterIE7PasswordInfo& other);
+
+ // Hash of the url.
+ base::string16 url_hash;
+
+ // Encrypted data containing the username, password and some more
+ // undocumented fields.
+ std::vector<unsigned char> encrypted_data;
+
+ // When the login was imported.
+ base::Time date_created;
+};
+
+// Mapped to history::VisitSource after import in the browser.
+enum VisitSource {
+ VISIT_SOURCE_BROWSED = 0,
+ VISIT_SOURCE_FIREFOX_IMPORTED = 1,
+ VISIT_SOURCE_IE_IMPORTED = 2,
+ VISIT_SOURCE_SAFARI_IMPORTED = 3,
+};
+
+} // namespace importer
+
+#endif // CHROME_COMMON_IMPORTER_IMPORTER_DATA_TYPES_H_
diff --git a/chromium/chrome/common/importer/importer_test_registry_overrider_win.cc b/chromium/chrome/common/importer/importer_test_registry_overrider_win.cc
new file mode 100644
index 00000000000..0f881968259
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_test_registry_overrider_win.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2013 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.
+
+#include "chrome/common/importer/importer_test_registry_overrider_win.h"
+
+#include <windows.h>
+
+#include <memory>
+#include <string>
+
+#include "base/environment.h"
+#include "base/guid.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/win/registry.h"
+
+namespace {
+
+// The key to which a random subkey will be appended. This key itself will never
+// be deleted.
+const wchar_t kTestHKCUOverrideKeyPrefix[] = L"SOFTWARE\\Chromium Unit Tests\\";
+const char kTestHKCUOverrideEnvironmentVariable[] =
+ "IE_IMPORTER_TEST_OVERRIDE_HKCU";
+
+// Reads the environment variable set by a previous call to
+// SetTestRegistryOverride() into |key| if it exists and |key| is not NULL.
+// Returns true if the variable was successfully read.
+bool GetTestKeyFromEnvironment(base::string16* key) {
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ std::string value;
+ bool result = env->GetVar(kTestHKCUOverrideEnvironmentVariable, &value);
+ if (result)
+ *key = base::UTF8ToUTF16(value);
+ return result;
+}
+
+} // namespace
+
+////////////////////////////////////////////////////////////////////////////////
+// ImporterTestRegistryOverrider, public:
+
+ImporterTestRegistryOverrider::ImporterTestRegistryOverrider()
+ : temporary_key_(kTestHKCUOverrideKeyPrefix +
+ base::UTF8ToUTF16(base::GenerateGUID())) {
+ DCHECK(!GetTestKeyFromEnvironment(NULL));
+
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ bool success = env->SetVar(kTestHKCUOverrideEnvironmentVariable,
+ base::UTF16ToUTF8(temporary_key_));
+ DCHECK(success);
+}
+
+ImporterTestRegistryOverrider::~ImporterTestRegistryOverrider() {
+ base::win::RegKey reg_key(HKEY_CURRENT_USER, temporary_key_.c_str(),
+ KEY_ALL_ACCESS);
+ DCHECK(reg_key.Valid());
+ reg_key.DeleteKey(L"");
+
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ bool success = env->UnSetVar(kTestHKCUOverrideEnvironmentVariable);
+ DCHECK(success);
+}
+
+// static
+base::string16 ImporterTestRegistryOverrider::GetTestRegistryOverride() {
+ base::string16 key;
+ if (!GetTestKeyFromEnvironment(&key))
+ return base::string16();
+ return key;
+}
diff --git a/chromium/chrome/common/importer/importer_test_registry_overrider_win.h b/chromium/chrome/common/importer/importer_test_registry_overrider_win.h
new file mode 100644
index 00000000000..f814382ca3a
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_test_registry_overrider_win.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2013 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.
+
+#ifndef CHROME_COMMON_IMPORTER_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_
+#define CHROME_COMMON_IMPORTER_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_
+
+#include "base/macros.h"
+#include "base/strings/string16.h"
+
+// A helper class to let tests generate a random registry key to be used in
+// HKEY_CURRENT_USER in tests. After the key has been generated by constructing
+// an ImporterTestRegistryOverrider, consumers in this process (or in any
+// child processes created after the key has been generated) can obtain the key
+// via GetTestRegistryOverride(). ImporterTestRegistryOverrider will delete
+// the temporary key upon being deleted itself. Only one
+// ImporterTestRegistryOverrider should live at once in a given process
+// hiearchy.
+class ImporterTestRegistryOverrider {
+ public:
+ ImporterTestRegistryOverrider();
+ ~ImporterTestRegistryOverrider();
+
+ // Returns a test key if one was chosen and set by a call to
+ // SetTestRegistryOverride(); returns the empty string if none.
+ static base::string16 GetTestRegistryOverride();
+
+ private:
+ base::string16 temporary_key_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImporterTestRegistryOverrider);
+};
+
+#endif // CHROME_COMMON_IMPORTER_IMPORTER_TEST_REGISTRY_OVERRIDER_WIN_H_
diff --git a/chromium/chrome/common/importer/importer_type.h b/chromium/chrome/common/importer/importer_type.h
new file mode 100644
index 00000000000..c172f8a5bc5
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_type.h
@@ -0,0 +1,36 @@
+// Copyright 2013 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.
+
+#ifndef CHROME_COMMON_IMPORTER_IMPORTER_TYPE_H_
+#define CHROME_COMMON_IMPORTER_IMPORTER_TYPE_H_
+
+#include "build/build_config.h"
+
+namespace importer {
+
+// An enumeration of the type of importers that we support to import
+// settings and data from (browsers, google toolbar and a bookmarks html file).
+// NOTE: Numbers added so that data can be reliably cast to ints and passed
+// across IPC.
+enum ImporterType {
+ TYPE_UNKNOWN = -1,
+#if defined(OS_WIN)
+ TYPE_IE = 0,
+#endif
+ // Value 1 was the (now deleted) Firefox 2 profile importer.
+ TYPE_FIREFOX = 2,
+#if defined(OS_MACOSX)
+ TYPE_SAFARI = 3,
+#endif
+ // Value 4 was the (now deleted) Google Toolbar importer.
+ TYPE_BOOKMARKS_FILE = 5, // Identifies a 'bookmarks.html' file.
+#if defined(OS_WIN)
+ TYPE_EDGE = 6,
+#endif
+};
+
+} // namespace importer
+
+
+#endif // CHROME_COMMON_IMPORTER_IMPORTER_TYPE_H_
diff --git a/chromium/chrome/common/importer/importer_url_row.cc b/chromium/chrome/common/importer/importer_url_row.cc
new file mode 100644
index 00000000000..26a3414a6c0
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_url_row.cc
@@ -0,0 +1,21 @@
+// Copyright 2013 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.
+
+#include "chrome/common/importer/importer_url_row.h"
+
+ImporterURLRow::ImporterURLRow()
+ : visit_count(0),
+ typed_count(0),
+ hidden(false) {
+}
+
+ImporterURLRow::ImporterURLRow(const GURL& url)
+ : url(url),
+ visit_count(0),
+ typed_count(0),
+ hidden(false) {
+}
+
+ImporterURLRow::ImporterURLRow(const ImporterURLRow& other) = default;
+
diff --git a/chromium/chrome/common/importer/importer_url_row.h b/chromium/chrome/common/importer/importer_url_row.h
new file mode 100644
index 00000000000..f7e0a6dd8e8
--- /dev/null
+++ b/chromium/chrome/common/importer/importer_url_row.h
@@ -0,0 +1,39 @@
+// Copyright 2013 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.
+
+#ifndef CHROME_COMMON_IMPORTER_IMPORTER_URL_ROW_H_
+#define CHROME_COMMON_IMPORTER_IMPORTER_URL_ROW_H_
+
+#include "base/strings/string16.h"
+#include "base/time/time.h"
+#include "url/gurl.h"
+
+// Used as the target for importing history URLs from other browser's profiles
+// in the utility process. Converted to history::URLRow after being passed via
+// IPC to the browser.
+struct ImporterURLRow {
+ public:
+ ImporterURLRow();
+ explicit ImporterURLRow(const GURL& url);
+ ImporterURLRow(const ImporterURLRow& other);
+
+ GURL url;
+ base::string16 title;
+
+ // Total number of times this URL has been visited.
+ int visit_count;
+
+ // Number of times this URL has been manually entered in the URL bar.
+ int typed_count;
+
+ // The date of the last visit of this URL, which saves us from having to
+ // loop up in the visit table for things like autocomplete and expiration.
+ base::Time last_visit;
+
+ // Indicates this entry should now be shown in typical UI or queries, this
+ // is usually for subframes.
+ bool hidden;
+};
+
+#endif // CHROME_COMMON_IMPORTER_IMPORTER_URL_ROW_H_
diff --git a/chromium/chrome/common/importer/mock_importer_bridge.cc b/chromium/chrome/common/importer/mock_importer_bridge.cc
new file mode 100644
index 00000000000..69fd927a1fa
--- /dev/null
+++ b/chromium/chrome/common/importer/mock_importer_bridge.cc
@@ -0,0 +1,9 @@
+// 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.
+
+#include "chrome/common/importer/mock_importer_bridge.h"
+
+MockImporterBridge::MockImporterBridge() {}
+
+MockImporterBridge::~MockImporterBridge() {}
diff --git a/chromium/chrome/common/importer/mock_importer_bridge.h b/chromium/chrome/common/importer/mock_importer_bridge.h
new file mode 100644
index 00000000000..104c44b4847
--- /dev/null
+++ b/chromium/chrome/common/importer/mock_importer_bridge.h
@@ -0,0 +1,45 @@
+// Copyright (c) 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.
+
+#ifndef CHROME_COMMON_IMPORTER_MOCK_IMPORTER_BRIDGE_H_
+#define CHROME_COMMON_IMPORTER_MOCK_IMPORTER_BRIDGE_H_
+
+#include <string>
+#include <vector>
+
+#include "chrome/common/importer/imported_bookmark_entry.h"
+#include "chrome/common/importer/importer_autofill_form_data_entry.h"
+#include "chrome/common/importer/importer_bridge.h"
+#include "components/autofill/core/common/password_form.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+class MockImporterBridge : public ImporterBridge {
+ public:
+ MockImporterBridge();
+
+ MOCK_METHOD2(AddBookmarks,
+ void(const std::vector<ImportedBookmarkEntry>&,
+ const base::string16&));
+ MOCK_METHOD1(AddHomePage, void(const GURL&));
+ MOCK_METHOD1(SetFavicons, void(const favicon_base::FaviconUsageDataList&));
+ MOCK_METHOD2(SetHistoryItems,
+ void(const std::vector<ImporterURLRow>&, importer::VisitSource));
+ MOCK_METHOD2(SetKeywords,
+ void(const std::vector<importer::SearchEngineInfo>&, bool));
+ MOCK_METHOD1(SetFirefoxSearchEnginesXMLData,
+ void(const std::vector<std::string>&));
+ MOCK_METHOD1(SetPasswordForm, void(const autofill::PasswordForm&));
+ MOCK_METHOD1(SetAutofillFormData,
+ void(const std::vector<ImporterAutofillFormDataEntry>&));
+ MOCK_METHOD0(NotifyStarted, void());
+ MOCK_METHOD1(NotifyItemStarted, void(importer::ImportItem));
+ MOCK_METHOD1(NotifyItemEnded, void(importer::ImportItem));
+ MOCK_METHOD0(NotifyEnded, void());
+ MOCK_METHOD1(GetLocalizedString, base::string16(int));
+
+ private:
+ ~MockImporterBridge() override;
+};
+
+#endif // CHROME_COMMON_IMPORTER_MOCK_IMPORTER_BRIDGE_H_
diff --git a/chromium/chrome/common/importer/profile_import_process_param_traits.cc b/chromium/chrome/common/importer/profile_import_process_param_traits.cc
new file mode 100644
index 00000000000..424a17f9e32
--- /dev/null
+++ b/chromium/chrome/common/importer/profile_import_process_param_traits.cc
@@ -0,0 +1,33 @@
+// Copyright 2013 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.
+
+// Get basic type definitions.
+#define IPC_MESSAGE_IMPL
+#include "chrome/common/importer/profile_import_process_param_traits_macros.h"
+
+// Generate constructors.
+#include "ipc/struct_constructor_macros.h"
+#undef CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_PARAM_TRAITS_MACROS_H_
+#include "chrome/common/importer/profile_import_process_param_traits_macros.h"
+
+// Generate param traits write methods.
+#include "ipc/param_traits_write_macros.h"
+namespace IPC {
+#undef CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_PARAM_TRAITS_MACROS_H_
+#include "chrome/common/importer/profile_import_process_param_traits_macros.h"
+} // namespace IPC
+
+// Generate param traits read methods.
+#include "ipc/param_traits_read_macros.h"
+namespace IPC {
+#undef CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_PARAM_TRAITS_MACROS_H_
+#include "chrome/common/importer/profile_import_process_param_traits_macros.h"
+} // namespace IPC
+
+// Generate param traits log methods.
+#include "ipc/param_traits_log_macros.h"
+namespace IPC {
+#undef CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_PARAM_TRAITS_MACROS_H_
+#include "chrome/common/importer/profile_import_process_param_traits_macros.h"
+} // namespace IPC
diff --git a/chromium/chrome/common/importer/profile_import_process_param_traits.h b/chromium/chrome/common/importer/profile_import_process_param_traits.h
new file mode 100644
index 00000000000..46ed09336af
--- /dev/null
+++ b/chromium/chrome/common/importer/profile_import_process_param_traits.h
@@ -0,0 +1,10 @@
+// Copyright 2013 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.
+
+#ifndef CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_PARAM_TRAITS_H_
+#define CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_PARAM_TRAITS_H_
+
+#include "chrome/common/importer/profile_import_process_param_traits_macros.h"
+
+#endif // CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_PARAM_TRAITS_H_
diff --git a/chromium/chrome/common/importer/profile_import_process_param_traits_macros.h b/chromium/chrome/common/importer/profile_import_process_param_traits_macros.h
new file mode 100644
index 00000000000..dd005641f43
--- /dev/null
+++ b/chromium/chrome/common/importer/profile_import_process_param_traits_macros.h
@@ -0,0 +1,94 @@
+// Copyright 2014 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.
+
+// Singly or Multiply-included shared traits file depending on circumstances.
+// This allows the use of IPC serialization macros in more than one IPC message
+// file.
+#ifndef CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_PARAM_TRAITS_MACROS_H_
+#define CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_PARAM_TRAITS_MACROS_H_
+
+#include <string>
+#include <vector>
+
+#include "base/strings/string16.h"
+#include "base/values.h"
+#include "build/build_config.h"
+#include "chrome/common/common_param_traits_macros.h"
+#include "chrome/common/importer/imported_bookmark_entry.h"
+#include "chrome/common/importer/importer_autofill_form_data_entry.h"
+#include "chrome/common/importer/importer_data_types.h"
+#include "chrome/common/importer/importer_url_row.h"
+#include "components/autofill/core/common/password_form.h"
+#include "components/favicon_base/favicon_usage_data.h"
+#include "content/public/common/common_param_traits.h"
+#include "ipc/ipc_message_macros.h"
+
+#if defined(OS_WIN)
+IPC_ENUM_TRAITS_MIN_MAX_VALUE(importer::ImporterType,
+ importer::TYPE_UNKNOWN,
+ importer::TYPE_EDGE)
+#else
+IPC_ENUM_TRAITS_MIN_MAX_VALUE(importer::ImporterType,
+ importer::TYPE_UNKNOWN,
+ importer::TYPE_BOOKMARKS_FILE)
+#endif
+
+IPC_ENUM_TRAITS_MIN_MAX_VALUE(importer::ImportItem,
+ importer::NONE,
+ importer::ALL)
+
+IPC_STRUCT_TRAITS_BEGIN(importer::SourceProfile)
+ IPC_STRUCT_TRAITS_MEMBER(importer_name)
+ IPC_STRUCT_TRAITS_MEMBER(importer_type)
+ IPC_STRUCT_TRAITS_MEMBER(source_path)
+ IPC_STRUCT_TRAITS_MEMBER(app_path)
+ IPC_STRUCT_TRAITS_MEMBER(services_supported)
+ IPC_STRUCT_TRAITS_MEMBER(locale)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(ImporterURLRow)
+ IPC_STRUCT_TRAITS_MEMBER(url)
+ IPC_STRUCT_TRAITS_MEMBER(title)
+ IPC_STRUCT_TRAITS_MEMBER(visit_count)
+ IPC_STRUCT_TRAITS_MEMBER(typed_count)
+ IPC_STRUCT_TRAITS_MEMBER(last_visit)
+ IPC_STRUCT_TRAITS_MEMBER(hidden)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(ImportedBookmarkEntry)
+ IPC_STRUCT_TRAITS_MEMBER(in_toolbar)
+ IPC_STRUCT_TRAITS_MEMBER(is_folder)
+ IPC_STRUCT_TRAITS_MEMBER(url)
+ IPC_STRUCT_TRAITS_MEMBER(path)
+ IPC_STRUCT_TRAITS_MEMBER(title)
+ IPC_STRUCT_TRAITS_MEMBER(creation_time)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(favicon_base::FaviconUsageData)
+ IPC_STRUCT_TRAITS_MEMBER(favicon_url)
+ IPC_STRUCT_TRAITS_MEMBER(png_data)
+ IPC_STRUCT_TRAITS_MEMBER(urls)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(importer::SearchEngineInfo)
+ IPC_STRUCT_TRAITS_MEMBER(url)
+ IPC_STRUCT_TRAITS_MEMBER(keyword)
+ IPC_STRUCT_TRAITS_MEMBER(display_name)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(ImporterAutofillFormDataEntry)
+ IPC_STRUCT_TRAITS_MEMBER(name)
+ IPC_STRUCT_TRAITS_MEMBER(value)
+ IPC_STRUCT_TRAITS_MEMBER(times_used)
+ IPC_STRUCT_TRAITS_MEMBER(first_used)
+ IPC_STRUCT_TRAITS_MEMBER(last_used)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(importer::ImporterIE7PasswordInfo)
+ IPC_STRUCT_TRAITS_MEMBER(url_hash)
+ IPC_STRUCT_TRAITS_MEMBER(encrypted_data)
+ IPC_STRUCT_TRAITS_MEMBER(date_created)
+IPC_STRUCT_TRAITS_END()
+
+#endif // CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_PARAM_TRAITS_MACROS_H_
diff --git a/chromium/chrome/common/importer/pstore_declarations.h b/chromium/chrome/common/importer/pstore_declarations.h
new file mode 100644
index 00000000000..74b5954da7c
--- /dev/null
+++ b/chromium/chrome/common/importer/pstore_declarations.h
@@ -0,0 +1,188 @@
+// Copyright 2012 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.
+
+#ifndef CHROME_COMMON_IMPORTER_PSTORE_DECLARATIONS_H_
+#define CHROME_COMMON_IMPORTER_PSTORE_DECLARATIONS_H_
+
+#ifdef __PSTORE_H__
+#error Should not include pstore.h and this file simultaneously.
+#endif
+
+#include <ole2.h>
+
+// pstore.h is no longer shipped in the Windows 8 SDK. Define a minimal set
+// here.
+
+// These types are referenced in interfaces we use, but our code does not use
+// refer to these types, so simply make them opaque.
+class IEnumPStoreTypes;
+struct PST_ACCESSRULESET;
+struct PST_PROMPTINFO;
+struct PST_PROVIDERINFO;
+struct PST_TYPEINFO;
+
+EXTERN_C const IID IID_IPStore;
+EXTERN_C const IID IID_IEnumPStoreItems;
+
+typedef DWORD PST_KEY;
+typedef DWORD PST_ACCESSMODE;
+#define PST_E_OK _HRESULT_TYPEDEF_(0x00000000L)
+
+interface
+#ifdef __clang__
+ [[clang::lto_visibility_public]]
+#endif
+ IEnumPStoreItems : public IUnknown {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE Next(
+ DWORD celt,
+ LPWSTR __RPC_FAR *rgelt,
+ DWORD __RPC_FAR *pceltFetched) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE Skip(DWORD celt) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE Reset(void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE Clone(
+ IEnumPStoreItems __RPC_FAR *__RPC_FAR *ppenum) = 0;
+};
+
+interface
+#ifdef __clang__
+ [[clang::lto_visibility_public]]
+#endif
+ IPStore : public IUnknown {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE GetInfo(
+ PST_PROVIDERINFO* __RPC_FAR *ppProperties) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetProvParam(
+ DWORD dwParam,
+ DWORD __RPC_FAR *pcbData,
+ BYTE __RPC_FAR *__RPC_FAR *ppbData,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetProvParam(
+ DWORD dwParam,
+ DWORD cbData,
+ BYTE __RPC_FAR *pbData,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE CreateType(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pType,
+ PST_TYPEINFO* pInfo,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pType,
+ PST_TYPEINFO* __RPC_FAR *ppInfo,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE DeleteType(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pType,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE CreateSubtype(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pType,
+ const GUID __RPC_FAR *pSubtype,
+ PST_TYPEINFO* pInfo,
+ PST_ACCESSRULESET* pRules,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetSubtypeInfo(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pType,
+ const GUID __RPC_FAR *pSubtype,
+ PST_TYPEINFO* __RPC_FAR *ppInfo,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE DeleteSubtype(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pType,
+ const GUID __RPC_FAR *pSubtype,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE ReadAccessRuleset(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pType,
+ const GUID __RPC_FAR *pSubtype,
+ PST_ACCESSRULESET* __RPC_FAR *ppRules,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE WriteAccessRuleset(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pType,
+ const GUID __RPC_FAR *pSubtype,
+ PST_ACCESSRULESET* pRules,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE EnumTypes(
+ PST_KEY Key,
+ DWORD dwFlags,
+ IEnumPStoreTypes __RPC_FAR *__RPC_FAR *ppenum) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE EnumSubtypes(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pType,
+ DWORD dwFlags,
+ IEnumPStoreTypes __RPC_FAR *__RPC_FAR *ppenum) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE DeleteItem(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pItemType,
+ const GUID __RPC_FAR *pItemSubtype,
+ LPCWSTR szItemName,
+ PST_PROMPTINFO* pPromptInfo,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE ReadItem(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pItemType,
+ const GUID __RPC_FAR *pItemSubtype,
+ LPCWSTR szItemName,
+ DWORD __RPC_FAR *pcbData,
+ BYTE __RPC_FAR *__RPC_FAR *ppbData,
+ PST_PROMPTINFO* pPromptInfo,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE WriteItem(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pItemType,
+ const GUID __RPC_FAR *pItemSubtype,
+ LPCWSTR szItemName,
+ DWORD cbData,
+ BYTE __RPC_FAR *pbData,
+ PST_PROMPTINFO* pPromptInfo,
+ DWORD dwDefaultConfirmationStyle,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE OpenItem(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pItemType,
+ const GUID __RPC_FAR *pItemSubtype,
+ LPCWSTR szItemName,
+ PST_ACCESSMODE ModeFlags,
+ PST_PROMPTINFO* pPromptInfo,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE CloseItem(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pItemType,
+ const GUID __RPC_FAR *pItemSubtype,
+ LPCWSTR szItemName,
+ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE EnumItems(
+ PST_KEY Key,
+ const GUID __RPC_FAR *pItemType,
+ const GUID __RPC_FAR *pItemSubtype,
+ DWORD dwFlags,
+ IEnumPStoreItems __RPC_FAR *__RPC_FAR *ppenum) = 0;
+};
+
+#endif // CHROME_COMMON_IMPORTER_PSTORE_DECLARATIONS_H_
diff --git a/chromium/chrome/common/importer/safari_importer_utils.h b/chromium/chrome/common/importer/safari_importer_utils.h
new file mode 100644
index 00000000000..6885251a62b
--- /dev/null
+++ b/chromium/chrome/common/importer/safari_importer_utils.h
@@ -0,0 +1,22 @@
+// Copyright 2013 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.
+
+#ifndef CHROME_COMMON_IMPORTER_SAFARI_IMPORTER_UTILS_H_
+#define CHROME_COMMON_IMPORTER_SAFARI_IMPORTER_UTILS_H_
+
+#include <stdint.h>
+
+namespace base {
+class FilePath;
+}
+
+// Does this user account have a Safari Profile and if so, what items
+// are supported?
+// in: library_dir - ~/Library or a standin for testing purposes.
+// out: services_supported - the service supported for import.
+// Returns true if we can import the Safari profile.
+bool SafariImporterCanImport(const base::FilePath& library_dir,
+ uint16_t* services_supported);
+
+#endif // CHROME_COMMON_IMPORTER_SAFARI_IMPORTER_UTILS_H_
diff --git a/chromium/chrome/common/importer/safari_importer_utils.mm b/chromium/chrome/common/importer/safari_importer_utils.mm
new file mode 100644
index 00000000000..b69506abbae
--- /dev/null
+++ b/chromium/chrome/common/importer/safari_importer_utils.mm
@@ -0,0 +1,29 @@
+// Copyright 2013 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.
+
+#include "chrome/common/importer/safari_importer_utils.h"
+
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "chrome/common/importer/importer_data_types.h"
+
+bool SafariImporterCanImport(const base::FilePath& library_dir,
+ uint16_t* services_supported) {
+ DCHECK(services_supported);
+ *services_supported = importer::NONE;
+
+ // Import features are toggled by the following:
+ // bookmarks import: existence of ~/Library/Safari/Bookmarks.plist file.
+ // history import: existence of ~/Library/Safari/History.plist file.
+ base::FilePath safari_dir = library_dir.Append("Safari");
+ base::FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist");
+ base::FilePath history_path = safari_dir.Append("History.plist");
+
+ if (base::PathExists(bookmarks_path))
+ *services_supported |= importer::FAVORITES;
+ if (base::PathExists(history_path))
+ *services_supported |= importer::HISTORY;
+
+ return *services_supported != importer::NONE;
+}