Skip to content

Commit

Permalink
Revert "Import History from Safari"
Browse files Browse the repository at this point in the history
Importing History from Safari is no longer possible as macOS 10.14
is much stricter now, and Chromium's support is no longer available
so let's drop this patch and keep only the bookmarks import feature.

This reverts commit c9050d2.

Chromium change:

https://chromium.googlesource.com/chromium/src/+/b2a8ac9a97c656e2e5d18f0b1948667f96117b48

commit b2a8ac9a97c656e2e5d18f0b1948667f96117b48
Author: Avi Drissman <avi@chromium.org>
Date:   Fri Sep 11 18:41:32 2020 +0000

    Clean up Safari importing

    Starting in macOS 10.14, access to the Safari bookmarks file was
    restricted. Chromium didn't notice, and would proceed anyway,
    because it assumed that if the file was there, it could be read.
    That's not true in the general case anyway, so fix it.

    History import from Safari broke many years ago when they moved
    to a database for their storage from using a plist. No one realized
    that it broke, and since it's access restricted from 10.14 on,
    there's no point in fixing it, so this CL removes it.

    Bug: 850225
  • Loading branch information
mariospr authored and mkarolin committed Oct 6, 2020
1 parent 6248eef commit c65b0fd
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 202 deletions.
2 changes: 1 addition & 1 deletion app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
Full Disk Access required
</message>
<message name="IDS_FULL_DISK_ACCESS_CONFIRM_DIALOG_MESSAGE" desc="The label for full disk access dialog message">
Brave needs Full Disk Access to import your Bookmarks and History from Safari.
Brave needs Full Disk Access to import your Bookmarks from Safari.
</message>
<message name="IDS_FULL_DISK_ACCESS_CONFIRM_DIALOG_LINK_TEXT" desc="The label for full disk access dialog link text">
Learn how to grant Full Disk Access from your System Preferences.
Expand Down
34 changes: 3 additions & 31 deletions browser/ui/webui/settings/brave_import_data_handler_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,6 @@

using content::BrowserThread;

class ScopedOpenFile {
public:
explicit ScopedOpenFile(const base::FilePath& file_path) {
file_ = base::OpenFile(file_path, "r");
}

~ScopedOpenFile() {
if (file_)
base::CloseFile(file_);
}

bool CanRead() const { return !!file_; }

ScopedOpenFile(const ScopedOpenFile&) = delete;
ScopedOpenFile& operator=(const ScopedOpenFile&) = delete;

private:
FILE* file_ = nullptr;
};

class FullDiskAccessConfirmDialogDelegate
: public TabModalConfirmDialogDelegate {
public:
Expand Down Expand Up @@ -124,24 +104,16 @@ bool HasProperDiskAccessPermission(uint16_t imported_items) {

if (imported_items & importer::FAVORITES) {
const base::FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist");
ScopedOpenFile open_file(bookmarks_path);
if(!open_file.CanRead()) {
if(!PathIsWritable(bookmarks_path)) {
LOG(ERROR) << __func__ << " " << bookmarks_path << " is not accessible."
<< " Please check full disk access permission.";
return false;
}
}

if (imported_items & importer::HISTORY) {
// HISTORY is set if plist or db exists.
base::FilePath history_path = safari_dir.Append("History.plist");
if (!base::PathExists(history_path)) {
history_path = safari_dir.Append("History.db");
DCHECK(base::PathExists(history_path));
}

ScopedOpenFile open_file(history_path);
if(!open_file.CanRead()) {
const base::FilePath history_path = safari_dir.Append("History.plist");
if(!PathIsWritable(history_path)) {
LOG(ERROR) << __func__ << " " << history_path << " is not accessible."
<< " Please check full disk access permission.";
return false;
Expand Down
20 changes: 0 additions & 20 deletions chromium_src/chrome/common/importer/safari_importer_utils.mm

This file was deleted.

10 changes: 0 additions & 10 deletions chromium_src/chrome/utility/importer/importer_creator.cc

This file was deleted.

19 changes: 0 additions & 19 deletions chromium_src/chrome/utility/importer/safari_importer.h

This file was deleted.

12 changes: 0 additions & 12 deletions patches/chrome-utility-importer-safari_importer.h.patch

This file was deleted.

13 changes: 0 additions & 13 deletions utility/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@ source_set("utility") {
]
}

if (is_mac) {
sources += [
"importer/brave_safari_importer.mm",
"importer/brave_safari_importer.h",
]

deps += [
"//base",
"//sql",
"//url",
]
}

if (enable_tor) {
deps += [ "//brave/components/services/tor" ]
}
Expand Down
25 changes: 0 additions & 25 deletions utility/importer/brave_safari_importer.h

This file was deleted.

71 changes: 0 additions & 71 deletions utility/importer/brave_safari_importer.mm

This file was deleted.

0 comments on commit c65b0fd

Please sign in to comment.