Skip to content

Commit

Permalink
Added TYPE_EDGE_CHROMIUM
Browse files Browse the repository at this point in the history
  • Loading branch information
spylogsster committed Jul 3, 2022
1 parent b4dbd91 commit c24d6d8
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 54 deletions.
9 changes: 9 additions & 0 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,15 @@ Or change later at <ph name="SETTINGS_EXTENIONS_LINK">$2<ex>brave://settings/ext
Maybe later
</message>

<!-- Importer -->
<message name="IDS_BRAVE_IMPORT_FROM_EDGE" desc="browser combo box: Microsoft Edge Legacy">
Microsoft Edge Legacy
</message>

<message name="IDS_IMPORTED_FROM_BOOKMARK_FOLDER" desc="Name for bookmark panel folder imported from another browser">
Imported from <ph name="BROWSER_NAME">$1<ex>Chrome</ex></ph>.
</message>

<!--Add new items to the appropriate sections above -->
</messages>
</release>
Expand Down
2 changes: 1 addition & 1 deletion browser/importer/brave_external_process_importer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace {
bool ShouldUseBraveImporter(importer::ImporterType type) {
if (type == importer::TYPE_CHROME || type == importer::TYPE_EDGE)
if (type == importer::TYPE_CHROME || type == importer::TYPE_EDGE_CHROMIUM)
return true;

return false;
Expand Down
6 changes: 5 additions & 1 deletion browser/importer/brave_importer_p3a.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum class ImporterSource {
kSafari,
kIE,
kEdge,
kEdgeChromium,
kSize
};
} // namespace
Expand All @@ -34,10 +35,10 @@ void RecordImporterP3A(importer::ImporterType type) {
case importer::TYPE_IE:
metric = ImporterSource::kIE;
break;
#endif
case importer::TYPE_EDGE:
metric = ImporterSource::kEdge;
break;
#endif
case importer::TYPE_FIREFOX:
metric = ImporterSource::kFirefox;
break;
Expand All @@ -52,6 +53,9 @@ void RecordImporterP3A(importer::ImporterType type) {
case importer::TYPE_CHROME:
metric = ImporterSource::kChrome;
break;
case importer::TYPE_EDGE_CHROMIUM:
metric = ImporterSource::kEdgeChromium;
break;
}

UMA_HISTOGRAM_ENUMERATION("Brave.Importer.ImporterSource", metric,
Expand Down
10 changes: 8 additions & 2 deletions chromium_src/chrome/browser/importer/importer_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "chrome/browser/importer/importer_list.h"
#include "base/files/file_path.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/values.h"
#include "brave/common/importer/chrome_importer_utils.h"
#include "chrome/browser/importer/importer_list.h"
#include "brave/grit/brave_generated_resources.h"
#include "chrome/grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"

Expand Down Expand Up @@ -62,9 +63,14 @@ void DetectChromeProfiles(std::vector<importer::SourceProfile>* profiles) {

AddChromeToProfiles(
profiles, GetChromeSourceProfiles(GetEdgeUserDataFolder()),
GetEdgeUserDataFolder(), "Microsoft Edge ", importer::TYPE_EDGE);
GetEdgeUserDataFolder(), "Microsoft Edge ", importer::TYPE_EDGE_CHROMIUM);
}

} // namespace

#define IDS_IMPORT_FROM_EDGE_OLD IDS_IMPORT_FROM_EDGE
#undef IDS_IMPORT_FROM_EDGE
#define IDS_IMPORT_FROM_EDGE IDS_BRAVE_IMPORT_FROM_EDGE
#include "src/chrome/browser/importer/importer_list.cc"
#undef IDS_IMPORT_FROM_EDGE
#define IDS_IMPORT_FROM_EDGE IDS_IMPORT_FROM_EDGE_OLD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Copyright (c) 2022 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

// NOLINT(build/header_guard)
// no-include-guard-because-multiply-included

#include "build/build_config.h"
#include "chrome/common/importer/importer_type.h"

#if !BUILDFLAG(IS_WIN)
#define TYPE_BOOKMARKS_FILE TYPE_EDGE_CHROMIUM
#else
#define TYPE_EDGE TYPE_EDGE_CHROMIUM
#endif
#include "src/chrome/common/importer/profile_import_process_param_traits_macros.h"
#if !BUILDFLAG(IS_WIN)
#undef TYPE_BOOKMARKS_FILE
#else
#undef TYPE_EDGE
#endif
31 changes: 5 additions & 26 deletions patches/chrome-browser-importer-importer_uma.cc.patch
Original file line number Diff line number Diff line change
@@ -1,37 +1,16 @@
diff --git a/chrome/browser/importer/importer_uma.cc b/chrome/browser/importer/importer_uma.cc
index d858676745103908f16a41392c0da42c3683c555..cb3bae6cca1f1739291169cf76d2a80d5817e00a 100644
index d858676745103908f16a41392c0da42c3683c555..ebdd7bdf2c893dacba09bea9c174ce4f5bb176eb 100644
--- a/chrome/browser/importer/importer_uma.cc
+++ b/chrome/browser/importer/importer_uma.cc
@@ -22,9 +22,8 @@ enum ImporterTypeMetrics {
#endif
IMPORTER_METRICS_GOOGLE_TOOLBAR5 = 5, // obsolete
IMPORTER_METRICS_BOOKMARKS_FILE = 6,
-#if BUILDFLAG(IS_WIN)
+
IMPORTER_METRICS_EDGE = 7,
-#endif

// Insert new values here. Never remove any existing values, as this enum is
// used to bucket a UMA histogram, and removing values breaks that.
@@ -44,10 +43,11 @@ void LogImporterUseToMetrics(const std::string& metric_postfix,
case TYPE_IE:
metrics_type = IMPORTER_METRICS_IE;
break;
+#endif
case TYPE_EDGE:
metrics_type = IMPORTER_METRICS_EDGE;
break;
-#endif
+
case TYPE_FIREFOX:
metrics_type = IMPORTER_METRICS_FIREFOX3;
break;
@@ -59,6 +59,9 @@ void LogImporterUseToMetrics(const std::string& metric_postfix,
@@ -59,6 +59,12 @@ void LogImporterUseToMetrics(const std::string& metric_postfix,
case TYPE_BOOKMARKS_FILE:
metrics_type = IMPORTER_METRICS_BOOKMARKS_FILE;
break;
+ case TYPE_CHROME:
+ // TODO: Wire this up if we want to record metrics on users who import from Chrome
+ break;
+ case TYPE_EDGE_CHROMIUM:
+ // TODO: Wire this up if we want to record metrics on users who import from Chrome
+ break;
}

Expand Down
13 changes: 6 additions & 7 deletions patches/chrome-common-importer-importer_type.h.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/chrome/common/importer/importer_type.h b/chrome/common/importer/importer_type.h
index 783aeeb86b265b9abf6c1d5c8a77c726daea277d..80ae323a237d8bed46a8722267b4773e09e1be08 100644
index 783aeeb86b265b9abf6c1d5c8a77c726daea277d..e7f580e9136ffa37b24a08336ae7f8cdcee353f7 100644
--- a/chrome/common/importer/importer_type.h
+++ b/chrome/common/importer/importer_type.h
@@ -19,15 +19,15 @@ enum ImporterType {
@@ -19,6 +19,8 @@ enum ImporterType {
TYPE_IE = 0,
#endif
// Value 1 was the (now deleted) Firefox 2 profile importer.
Expand All @@ -11,12 +11,11 @@ index 783aeeb86b265b9abf6c1d5c8a77c726daea277d..80ae323a237d8bed46a8722267b4773e
TYPE_FIREFOX = 2,
#if BUILDFLAG(IS_MAC)
TYPE_SAFARI = 3,
#endif
// Value 4 was the (now deleted) Google Toolbar importer.
TYPE_BOOKMARKS_FILE = 5, // Identifies a 'bookmarks.html' file.
-#if BUILDFLAG(IS_WIN)
@@ -28,6 +30,7 @@ enum ImporterType {
#if BUILDFLAG(IS_WIN)
TYPE_EDGE = 6,
-#endif
#endif
+ TYPE_EDGE_CHROMIUM = 10
};

} // namespace importer

This file was deleted.

2 changes: 1 addition & 1 deletion utility/importer/brave_profile_import_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ scoped_refptr<Importer> CreateImporterByType(importer::ImporterType type) {
switch (type) {
case importer::TYPE_CHROME:
return new ChromeImporter();
case importer::TYPE_EDGE:
case importer::TYPE_EDGE_CHROMIUM:
return new EdgeImporter();
default:
NOTREACHED();
Expand Down
9 changes: 6 additions & 3 deletions utility/importer/chrome_importer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "brave/common/importer/scoped_copy_file.h"
#include "brave/grit/brave_generated_resources.h"
#include "brave/utility/importer/brave_external_process_importer_bridge.h"
#include "build/build_config.h"
#include "chrome/common/importer/imported_bookmark_entry.h"
Expand All @@ -33,13 +34,13 @@
#include "sql/database.h"
#include "sql/statement.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/page_transition_types.h"
#include "url/gurl.h"

#if BUILDFLAG(IS_LINUX)
#include "chrome/grit/chromium_strings.h"
#include "components/os_crypt/key_storage_config_linux.h"
#include "ui/base/l10n/l10n_util.h"
#endif // BUILDFLAG(IS_LINUX)

#if BUILDFLAG(IS_WIN)
Expand Down Expand Up @@ -181,7 +182,7 @@ void ChromeImporter::StartImport(const importer::SourceProfile& source_profile,
ImporterBridge* bridge) {
bridge_ = bridge;
source_path_ = source_profile.source_path;

importer_name_ = source_profile.importer_name;
// The order here is important!
bridge_->NotifyStarted();

Expand Down Expand Up @@ -303,7 +304,9 @@ void ChromeImporter::ImportBookmarks() {
}
// Write into profile.
if (!bookmarks.empty() && !cancelled()) {
bridge_->AddBookmarks(bookmarks, u"Imported from Chrome");
bridge_->AddBookmarks(
bookmarks, l10n_util::GetStringFUTF16(IDS_IMPORTED_FROM_BOOKMARK_FOLDER,
importer_name_));
}

// Import favicons.
Expand Down
3 changes: 3 additions & 0 deletions utility/importer/chrome_importer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <map>
#include <set>
#include <string>
#include <vector>

#include "base/compiler_specific.h"
Expand Down Expand Up @@ -71,6 +72,8 @@ class ChromeImporter : public Importer {
const std::vector<std::u16string>& parent_path,
bool is_in_toolbar,
std::vector<ImportedBookmarkEntry>* bookmarks);

std::u16string importer_name_;
};

#endif // BRAVE_UTILITY_IMPORTER_CHROME_IMPORTER_H_
1 change: 1 addition & 0 deletions utility/importer/sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if (!is_android) {

brave_utility_importer_deps += [
"//base",
"//brave/app:brave_generated_resources_grit",
"//brave/common/importer:importer",
"//brave/common/importer:interfaces",
"//chrome/app:chromium_strings",
Expand Down

0 comments on commit c24d6d8

Please sign in to comment.