From 15fe961a6201fc4cf501598fcf8a20454e77a902 Mon Sep 17 00:00:00 2001 From: Carmelo Messina Date: Wed, 15 Nov 2023 14:40:37 +0100 Subject: [PATCH] #517 Fix bookmarks export on windows --- .../Add-bookmark-import-export-actions.patch | 16 +++++++--------- build/patches/Add-support-for-writing-URIs.patch | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/build/patches/Add-bookmark-import-export-actions.patch b/build/patches/Add-bookmark-import-export-actions.patch index 8177d4bc3..664a941d3 100644 --- a/build/patches/Add-bookmark-import-export-actions.patch +++ b/build/patches/Add-bookmark-import-export-actions.patch @@ -29,7 +29,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html chrome/browser/about_flags.cc | 8 + .../bookmarks/android/bookmark_bridge.cc | 283 ++++++++++++++++++ .../bookmarks/android/bookmark_bridge.h | 30 +- - .../browser/bookmarks/bookmark_html_writer.cc | 13 +- + .../browser/bookmarks/bookmark_html_writer.cc | 11 + .../dialogs/DownloadLocationCustomView.java | 8 +- .../DownloadLocationDialogCoordinator.java | 8 +- chrome/browser/flag_descriptions.cc | 5 + @@ -54,7 +54,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html ui/shell_dialogs/select_file_dialog_linux.cc | 4 + ui/shell_dialogs/select_file_dialog_linux.h | 2 + ui/shell_dialogs/select_file_dialog_win.cc | 5 + - 44 files changed, 923 insertions(+), 30 deletions(-) + 44 files changed, 922 insertions(+), 29 deletions(-) diff --git a/chrome/android/java/AndroidManifest.xml b/chrome/android/java/AndroidManifest.xml --- a/chrome/android/java/AndroidManifest.xml @@ -864,7 +864,7 @@ diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc -@@ -9847,6 +9847,14 @@ const FeatureEntry kFeatureEntries[] = { +@@ -9826,6 +9826,14 @@ const FeatureEntry kFeatureEntries[] = { FEATURE_VALUE_TYPE(features::kForceOffTextAutosizing)}, #endif @@ -1296,12 +1296,10 @@ diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/b #include "chrome/browser/bookmarks/bookmark_model_factory.h" #include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/profiles/profile.h" -@@ -228,8 +231,16 @@ class Writer : public base::RefCountedThreadSafe { - +@@ -229,7 +232,15 @@ class Writer : public base::RefCountedThreadSafe { // Opens the file, returning true on success. bool OpenFile() { -- int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE; -+ int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | base::File::FLAG_OPEN_TRUNCATED; + int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE; +#if BUILDFLAG(IS_ANDROID) + if (path_.IsContentUri()) { + file_ = std::make_unique(base::OpenContentUriForWrite(path_)); @@ -1384,7 +1382,7 @@ diff --git a/chrome/browser/download/android/java/src/org/chromium/chrome/browse diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc -@@ -7763,6 +7763,11 @@ const char kEnableBoundSessionCredentialsDescription[] = +@@ -7757,6 +7757,11 @@ const char kEnableBoundSessionCredentialsDescription[] = "prevent the usage of bound credentials outside of the user device."; #endif // BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS) @@ -1399,7 +1397,7 @@ diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descripti diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h -@@ -4496,6 +4496,9 @@ extern const char kEnableBoundSessionCredentialsName[]; +@@ -4493,6 +4493,9 @@ extern const char kEnableBoundSessionCredentialsName[]; extern const char kEnableBoundSessionCredentialsDescription[]; #endif // BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS) diff --git a/build/patches/Add-support-for-writing-URIs.patch b/build/patches/Add-support-for-writing-URIs.patch index a09f94648..9122d43c0 100644 --- a/build/patches/Add-support-for-writing-URIs.patch +++ b/build/patches/Add-support-for-writing-URIs.patch @@ -70,7 +70,7 @@ diff --git a/base/android/java/src/org/chromium/base/ContentUriUtils.java b/base + ContentResolver resolver = ContextUtils.getApplicationContext().getContentResolver(); + ContentProviderClient client = resolver.acquireContentProviderClient( + uri.getAuthority()); -+ ParcelFileDescriptor pfd = client.openFile(uri, "rw"); ++ ParcelFileDescriptor pfd = client.openFile(uri, "wt"); + int fd = pfd.detachFd(); + client.close(); + return fd;