diff options
author | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-03 00:32:13 +0000 |
---|---|---|
committer | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-03 00:32:13 +0000 |
commit | b7fa499af1ee55a31f13ca6ec87fd55b592df066 (patch) | |
tree | ec931649ee303084ed274acb8ba3b6160e182d07 /chrome/common/importer | |
parent | bda73911e53ad6e6e059231b6fb97ddac186bea8 (diff) | |
download | chromium_src-b7fa499af1ee55a31f13ca6ec87fd55b592df066.zip chromium_src-b7fa499af1ee55a31f13ca6ec87fd55b592df066.tar.gz chromium_src-b7fa499af1ee55a31f13ca6ec87fd55b592df066.tar.bz2 |
Move importer messages to common
Goal is moving profile_import_process_messages to chrome/common so they
can be used to communicate between the utility and browser. This
also requires moving some of the simple structs/enums that are used in
messages.
(a few gypi updates that got missed in previous CLs too)
TBR=jschuh@chromium.org
R=sky@chromium.org
BUG=254672
Review URL: https://chromiumcodereview.appspot.com/18555005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/importer')
-rw-r--r-- | chrome/common/importer/importer_data_types.cc | 17 | ||||
-rw-r--r-- | chrome/common/importer/importer_data_types.h | 56 | ||||
-rw-r--r-- | chrome/common/importer/importer_type.h | 33 | ||||
-rw-r--r-- | chrome/common/importer/profile_import_process_messages.cc | 33 | ||||
-rw-r--r-- | chrome/common/importer/profile_import_process_messages.h | 293 |
5 files changed, 432 insertions, 0 deletions
diff --git a/chrome/common/importer/importer_data_types.cc b/chrome/common/importer/importer_data_types.cc new file mode 100644 index 0000000..392b13d --- /dev/null +++ b/chrome/common/importer/importer_data_types.cc @@ -0,0 +1,17 @@ +// 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_data_types.h" + +namespace importer { + +SourceProfile::SourceProfile() + : importer_type(TYPE_UNKNOWN), + services_supported(0) { +} + +SourceProfile::~SourceProfile() { +} + +} // namespace importer diff --git a/chrome/common/importer/importer_data_types.h b/chrome/common/importer/importer_data_types.h new file mode 100644 index 0000000..e4c027e --- /dev/null +++ b/chrome/common/importer/importer_data_types.h @@ -0,0 +1,56 @@ +// 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 <string> + +#include "base/basictypes.h" +#include "base/files/file_path.h" +#include "base/memory/ref_counted.h" +#include "base/strings/string16.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, + ALL = (1 << 6) - 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(); + + string16 importer_name; + ImporterType importer_type; + base::FilePath source_path; + base::FilePath app_path; + uint16 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 bookmarks/search engine urls, etc. +struct URLKeywordInfo { + GURL url; + string16 keyword; + string16 display_name; +}; + +} // namespace importer + +#endif // CHROME_COMMON_IMPORTER_IMPORTER_DATA_TYPES_H_ diff --git a/chrome/common/importer/importer_type.h b/chrome/common/importer/importer_type.h new file mode 100644 index 0000000..7b301af --- /dev/null +++ b/chrome/common/importer/importer_type.h @@ -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. + +#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_FIREFOX3 = 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. +}; + +} // namespace importer + + +#endif // CHROME_COMMON_IMPORTER_IMPORTER_TYPE_H_ diff --git a/chrome/common/importer/profile_import_process_messages.cc b/chrome/common/importer/profile_import_process_messages.cc new file mode 100644 index 0000000..4a0b9a4 --- /dev/null +++ b/chrome/common/importer/profile_import_process_messages.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_messages.h" + +// Generate constructors. +#include "ipc/struct_constructor_macros.h" +#include "chrome/common/importer/profile_import_process_messages.h" + +// Generate destructors. +#include "ipc/struct_destructor_macros.h" +#include "chrome/common/importer/profile_import_process_messages.h" + +// Generate param traits write methods. +#include "ipc/param_traits_write_macros.h" +namespace IPC { +#include "chrome/common/importer/profile_import_process_messages.h" +} // namespace IPC + +// Generate param traits read methods. +#include "ipc/param_traits_read_macros.h" +namespace IPC { +#include "chrome/common/importer/profile_import_process_messages.h" +} // namespace IPC + +// Generate param traits log methods. +#include "ipc/param_traits_log_macros.h" +namespace IPC { +#include "chrome/common/importer/profile_import_process_messages.h" +} // namespace IPC diff --git a/chrome/common/importer/profile_import_process_messages.h b/chrome/common/importer/profile_import_process_messages.h new file mode 100644 index 0000000..8641f7c --- /dev/null +++ b/chrome/common/importer/profile_import_process_messages.h @@ -0,0 +1,293 @@ +// 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. + +// Multiply-included message file, no traditonal include guard. +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/strings/string16.h" +#include "base/values.h" +#include "chrome/common/common_param_traits_macros.h" +#include "chrome/common/importer/imported_bookmark_entry.h" +#include "chrome/common/importer/imported_favicon_usage.h" +#include "chrome/common/importer/importer_data_types.h" +#include "chrome/common/importer/importer_url_row.h" +#include "content/public/common/common_param_traits.h" +#include "content/public/common/password_form.h" +#include "ipc/ipc_message_macros.h" +#include "ipc/ipc_message_utils.h" + +#ifndef CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_ +#define CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_ + +namespace IPC { + +// Traits for importer::SourceProfile struct to pack/unpack. +template <> +struct ParamTraits<importer::SourceProfile> { + typedef importer::SourceProfile param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.importer_name); + WriteParam(m, static_cast<int>(p.importer_type)); + WriteParam(m, p.source_path); + WriteParam(m, p.app_path); + WriteParam(m, static_cast<int>(p.services_supported)); + WriteParam(m, p.locale); + } + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { + if (!ReadParam(m, iter, &p->importer_name)) + return false; + + int importer_type = 0; + if (!ReadParam(m, iter, &importer_type)) + return false; + p->importer_type = static_cast<importer::ImporterType>(importer_type); + + if (!ReadParam(m, iter, &p->source_path) || + !ReadParam(m, iter, &p->app_path)) { + return false; + } + + int services_supported = 0; + if (!ReadParam(m, iter, &services_supported)) + return false; + p->services_supported = static_cast<uint16>(services_supported); + + if (!ReadParam(m, iter, &p->locale)) + return false; + + return true; + } + static void Log(const param_type& p, std::string* l) { + l->append("("); + LogParam(p.importer_name, l); + l->append(", "); + LogParam(static_cast<int>(p.importer_type), l); + l->append(", "); + LogParam(p.source_path, l); + l->append(", "); + LogParam(p.app_path, l); + l->append(", "); + LogParam(static_cast<int>(p.services_supported), l); + l->append(", "); + LogParam(p.locale, l); + l->append(")"); + } +}; // ParamTraits<importer::SourceProfile> + +// Traits for ImporterURLRow to pack/unpack. +template <> +struct ParamTraits<ImporterURLRow> { + typedef ImporterURLRow param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.url); + WriteParam(m, p.title); + WriteParam(m, p.visit_count); + WriteParam(m, p.typed_count); + WriteParam(m, p.last_visit); + WriteParam(m, p.hidden); + } + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { + GURL url; + string16 title; + int visit_count, typed_count; + base::Time last_visit; + bool hidden; + if (!ReadParam(m, iter, &url) || + !ReadParam(m, iter, &title) || + !ReadParam(m, iter, &visit_count) || + !ReadParam(m, iter, &typed_count) || + !ReadParam(m, iter, &last_visit) || + !ReadParam(m, iter, &hidden)) + return false; + *p = ImporterURLRow(url); + p->title = title; + p->visit_count = visit_count; + p->typed_count = typed_count; + p->last_visit = last_visit; + p->hidden = hidden; + return true; + } + static void Log(const param_type& p, std::string* l) { + l->append("("); + LogParam(p.url, l); + l->append(", "); + LogParam(p.title, l); + l->append(", "); + LogParam(p.visit_count, l); + l->append(", "); + LogParam(p.typed_count, l); + l->append(", "); + LogParam(p.last_visit, l); + l->append(", "); + LogParam(p.hidden, l); + l->append(")"); + } +}; // ParamTraits<ImporterURLRow> + +// Traits for ImportedBookmarkEntry to pack/unpack. +template <> +struct ParamTraits<ImportedBookmarkEntry> { + typedef ImportedBookmarkEntry param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.in_toolbar); + WriteParam(m, p.is_folder); + WriteParam(m, p.url); + WriteParam(m, p.path); + WriteParam(m, p.title); + WriteParam(m, p.creation_time); + } + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { + return + (ReadParam(m, iter, &p->in_toolbar)) && + (ReadParam(m, iter, &p->is_folder)) && + (ReadParam(m, iter, &p->url)) && + (ReadParam(m, iter, &p->path)) && + (ReadParam(m, iter, &p->title)) && + (ReadParam(m, iter, &p->creation_time)); + } + static void Log(const param_type& p, std::string* l) { + l->append("("); + LogParam(p.in_toolbar, l); + l->append(", "); + LogParam(p.is_folder, l); + l->append(", "); + LogParam(p.url, l); + l->append(", "); + LogParam(p.path, l); + l->append(", "); + LogParam(p.title, l); + l->append(", "); + LogParam(p.creation_time, l); + l->append(")"); + } +}; // ParamTraits<ImportedBookmarkEntry> + +// Traits for ImportedFaviconUsage. +template <> +struct ParamTraits<ImportedFaviconUsage> { + typedef ImportedFaviconUsage param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.favicon_url); + WriteParam(m, p.png_data); + WriteParam(m, p.urls); + } + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { + return + ReadParam(m, iter, &p->favicon_url) && + ReadParam(m, iter, &p->png_data) && + ReadParam(m, iter, &p->urls); + } + static void Log(const param_type& p, std::string* l) { + l->append("("); + LogParam(p.favicon_url, l); + l->append(", "); + LogParam(p.png_data, l); + l->append(", "); + LogParam(p.urls, l); + l->append(")"); + } +}; // ParamTraits<ImportedFaviconUsage> + +// Traits for importer::URLKeywordInfo +template <> +struct ParamTraits<importer::URLKeywordInfo> { + typedef importer::URLKeywordInfo param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.url); + WriteParam(m, p.keyword); + WriteParam(m, p.display_name); + } + + static bool Read(const Message* m, PickleIterator* iter, param_type* p) { + return + ReadParam(m, iter, &p->url) && + ReadParam(m, iter, &p->keyword) && + ReadParam(m, iter, &p->display_name); + } + + static void Log(const param_type& p, std::string* l) { + l->append("("); + LogParam(p.url, l); + l->append(", "); + LogParam(p.keyword, l); + l->append(", "); + LogParam(p.display_name, l); + l->append(")"); + } +}; // ParamTraits<importer::URLKeywordInfo> + +} // namespace IPC + +#endif // CHROME_COMMON_IMPORTER_PROFILE_IMPORT_PROCESS_MESSAGES_H_ + +#define IPC_MESSAGE_START ProfileImportMsgStart + +//----------------------------------------------------------------------------- +// ProfileImportProcess messages +// These are messages sent from the browser to the profile import process. +IPC_MESSAGE_CONTROL3(ProfileImportProcessMsg_StartImport, + importer::SourceProfile, + int /* Bitmask of items to import. */, + DictionaryValue /* Localized strings. */) + +IPC_MESSAGE_CONTROL0(ProfileImportProcessMsg_CancelImport) + +IPC_MESSAGE_CONTROL1(ProfileImportProcessMsg_ReportImportItemFinished, + int /* ImportItem */) + +//--------------------------------------------------------------------------- +// ProfileImportProcessHost messages +// 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. +IPC_MESSAGE_CONTROL0(ProfileImportProcessHostMsg_Import_Started) + +IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_Import_Finished, + bool /* was import successful? */, + std::string /* error message, if any */) + +IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_ImportItem_Started, + int /* ImportItem */) + +IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_ImportItem_Finished, + int /* ImportItem */) + +// These messages send data from the external importer process back to +// the process host so it can be written to the profile. +IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyHistoryImportStart, + int /* total number of ImporterURLRow items */) + +IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyHistoryImportGroup, + std::vector<ImporterURLRow>, + int /* the source of URLs as in history::VisitSource.*/ + /* To simplify IPC call, pass as an integer */) + +IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyHomePageImportReady, + GURL /* GURL of home page */) + +IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyBookmarksImportStart, + string16 /* first folder name */, + int /* total number of bookmarks */) + +IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyBookmarksImportGroup, + std::vector<ImportedBookmarkEntry>) + +IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyFaviconsImportStart, + int /* total number of favicons */) + +IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyFaviconsImportGroup, + std::vector<ImportedFaviconUsage>) + +IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyPasswordFormReady, + content::PasswordForm) + +IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyKeywordsReady, + std::vector<importer::URLKeywordInfo>, // url_keywords + bool /* unique on host and path */) + +IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyFirefoxSearchEngData, + std::vector<std::string>) // search_engine_data + |