Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 7044: Do not import cookies from Chrome and Firefox. (uplift to 1.1.x) #4236

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions chromium_src/chrome/utility/importer/importer_creator.cc
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/* Copyright 2019 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/. */

#include "chrome/utility/importer/importer_creator.h"
#define CreateImporterByType CreateImporterByType_ChromiumImpl
#include "../../../../../chrome/utility/importer/importer_creator.cc"
#undef CreateImporterByType

#include "brave/utility/importer/brave_importer.h"
#include "brave/utility/importer/chrome_importer.h"
#include "brave/utility/importer/firefox_importer.h"

namespace importer {

scoped_refptr<Importer> CreateImporterByType(ImporterType type) {
switch (type) {
case TYPE_FIREFOX:
return new brave::FirefoxImporter();
case TYPE_CHROME:
return new ChromeImporter();
case TYPE_BRAVE:
Expand Down
4 changes: 0 additions & 4 deletions common/importer/chrome_importer_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,13 @@ bool ChromeImporterCanImport(const base::FilePath& profile,
profile.Append(base::FilePath::StringType(FILE_PATH_LITERAL("History")));
base::FilePath passwords =
profile.Append(base::FilePath::StringType(FILE_PATH_LITERAL("Login Data")));
base::FilePath cookies =
profile.Append(base::FilePath::StringType(FILE_PATH_LITERAL("Cookies")));

if (base::PathExists(bookmarks))
*services_supported |= importer::FAVORITES;
if (base::PathExists(history))
*services_supported |= importer::HISTORY;
if (base::PathExists(passwords))
*services_supported |= importer::PASSWORDS;
if (base::PathExists(cookies))
*services_supported |= importer::COOKIES;

return *services_supported != importer::NONE;
}
12 changes: 2 additions & 10 deletions patches/chrome-browser-importer-importer_list.cc.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc
index da4c6f6cec37523f59fd6b18e9e1c603c8e6a0df..f613af5207e550b91fb878d7fe56204fbdaecbc7 100644
index da4c6f6cec37523f59fd6b18e9e1c603c8e6a0df..569bb3a108132454c2213ece7abcb4ff23fcbc3c 100644
--- a/chrome/browser/importer/importer_list.cc
+++ b/chrome/browser/importer/importer_list.cc
@@ -29,6 +29,9 @@
Expand Down Expand Up @@ -28,15 +28,7 @@ index da4c6f6cec37523f59fd6b18e9e1c603c8e6a0df..f613af5207e550b91fb878d7fe56204f
if (profile_path.empty())
return;

@@ -127,6 +135,7 @@ void DetectFirefoxProfiles(const std::string locale,
firefox.app_path = app_path;
firefox.services_supported = importer::HISTORY | importer::FAVORITES |
importer::PASSWORDS | importer::SEARCH_ENGINES |
+ importer::COOKIES |
importer::AUTOFILL_FORM_DATA;
firefox.locale = locale;
profiles->push_back(firefox);
@@ -145,21 +154,37 @@ std::vector<importer::SourceProfile> DetectSourceProfilesWorker(
@@ -145,21 +153,37 @@ std::vector<importer::SourceProfile> DetectSourceProfilesWorker(
#if defined(OS_WIN)
if (shell_integration::IsFirefoxDefaultBrowser()) {
DetectFirefoxProfiles(locale, &profiles);
Expand Down
12 changes: 0 additions & 12 deletions patches/chrome-utility-importer-firefox_importer.cc.patch

This file was deleted.

23 changes: 0 additions & 23 deletions patches/chrome-utility-importer-firefox_importer.h.patch

This file was deleted.

1 change: 0 additions & 1 deletion test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ test("brave_unit_tests") {
"../browser/importer/chrome_profile_lock_unittest.cc",
"../utility/importer/chrome_importer_unittest.cc",
"../utility/importer/brave_importer_unittest.cc",
"../utility/importer/firefox_importer_unittest.cc",

# These tests should probably work on Android and compile, but don't pass currently
"//brave/browser/autocomplete/brave_autocomplete_provider_client_unittest.cc",
Expand Down
2 changes: 0 additions & 2 deletions utility/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ source_set("utility") {
"importer/brave_importer.h",
"importer/chrome_importer.cc",
"importer/chrome_importer.h",
"importer/firefox_importer.cc",
"importer/firefox_importer.h",
]

deps += [
Expand Down
6 changes: 1 addition & 5 deletions utility/importer/chrome_importer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ void ChromeImporter::StartImport(const importer::SourceProfile& source_profile,
bridge_->NotifyItemEnded(importer::PASSWORDS);
}

if ((items & importer::COOKIES) && !cancelled()) {
bridge_->NotifyItemStarted(importer::COOKIES);
ImportCookies();
bridge_->NotifyItemEnded(importer::COOKIES);
}
// Note that we do not import cookies from Chrome (issues/7044).

bridge_->NotifyEnded();
}
Expand Down
38 changes: 11 additions & 27 deletions utility/importer/chrome_importer_unittest.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* Copyright (c) 2019 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/. */

#include "brave/utility/importer/chrome_importer.h"
#include "brave/common/brave_paths.h"
#include "brave/common/importer/brave_mock_importer_bridge.h"

#include <string>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/strings/utf_string_conversions.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "brave/common/brave_paths.h"
#include "brave/common/importer/brave_mock_importer_bridge.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/importer/imported_bookmark_entry.h"
#include "chrome/common/importer/importer_data_types.h"
Expand Down Expand Up @@ -41,7 +44,8 @@ class ChromeImporterTest : public ::testing::Test {
void SetUpChromeProfile() {
// Creates a new profile in a new subdirectory in the temp directory.
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
base::FilePath test_path = temp_dir_.GetPath().AppendASCII("ChromeImporterTest");
base::FilePath test_path =
temp_dir_.GetPath().AppendASCII("ChromeImporterTest");
base::DeleteFile(test_path, true);
base::CreateDirectory(test_path);
profile_dir_ = test_path.AppendASCII("profile");
Expand Down Expand Up @@ -134,7 +138,8 @@ TEST_F(ChromeImporterTest, ImportFavicons) {
favicons[3].favicon_url.spec());
}

// The mock keychain only works on macOS, so only run this test on macOS (for now)
// The mock keychain only works on macOS, so only run this test on macOS (for
// now)
#if defined(OS_MACOSX)
TEST_F(ChromeImporterTest, ImportPasswords) {
// Use mock keychain on mac to prevent blocking permissions dialogs.
Expand Down Expand Up @@ -170,25 +175,4 @@ TEST_F(ChromeImporterTest, ImportPasswords) {
OSCryptMocker::TearDown();
}

TEST_F(ChromeImporterTest, ImportCookies) {
OSCryptMocker::SetUp();

std::vector<net::CanonicalCookie> cookies;

EXPECT_CALL(*bridge_, NotifyStarted());
EXPECT_CALL(*bridge_, NotifyItemStarted(importer::COOKIES));
EXPECT_CALL(*bridge_, SetCookies(_))
.WillOnce(::testing::SaveArg<0>(&cookies));
EXPECT_CALL(*bridge_, NotifyItemEnded(importer::COOKIES));
EXPECT_CALL(*bridge_, NotifyEnded());

importer_->StartImport(profile_, importer::COOKIES, bridge_.get());

ASSERT_EQ(1u, cookies.size());
EXPECT_EQ("localhost", cookies[0].Domain());
EXPECT_EQ("test", cookies[0].Name());
EXPECT_EQ("test", cookies[0].Value());

OSCryptMocker::TearDown();
}
#endif
109 changes: 0 additions & 109 deletions utility/importer/firefox_importer.cc

This file was deleted.

33 changes: 0 additions & 33 deletions utility/importer/firefox_importer.h

This file was deleted.

Loading