Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit acd8cb66 authored by Carmelo Messina's avatar Carmelo Messina
Browse files

Patches for 140 (final version)

parent d15b126d
Loading
Loading
Loading
Loading
+65 −112
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
 .../app/bookmarks/BookmarkActivity.java       |  31 ++
 .../native_page/NativePageFactory.java        |   9 +-
 chrome/browser/BUILD.gn                       |  11 +-
 .../bookmarks/android/bookmark_bridge.cc      | 266 ++++++++++++++++
 .../bookmarks/android/bookmark_bridge.cc      | 197 ++++++++++++
 .../bookmarks/android/bookmark_bridge.h       |  30 +-
 .../browser/bookmarks/BookmarkBridge.java     |  39 +++
 .../browser/bookmarks/BookmarkDelegate.java   |  10 +
@@ -36,9 +36,10 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
 chrome/browser/importer/profile_writer.h      |   6 +
 .../preferences/ChromePreferenceKeys.java     |   3 +
 .../strings/android_chrome_strings.grd        |  18 ++
 chrome/common/BUILD.gn                        |   3 +
 chrome/utility/BUILD.gn                       |   5 +
 chrome/utility/BUILD.gn                       |   7 +
 .../importer/bookmarks_file_importer.cc       |   4 +
 .../headless_select_file_dialog.cc            |   4 +
 .../content/content_bookmark_parser_utils.cc  |   3 +
 .../add-bookmark-import-export-actions.inc    |  12 +
 .../add-bookmark-import-export-actions.inc    |   4 +
 .../add-bookmark-import-export-actions.inc    |   1 +
@@ -50,7 +51,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 +
 39 files changed, 872 insertions(+), 24 deletions(-)
 40 files changed, 809 insertions(+), 24 deletions(-)
 create mode 100644 cromite_flags/chrome/browser/about_flags_cc/add-bookmark-import-export-actions.inc
 create mode 100644 cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/add-bookmark-import-export-actions.inc
 create mode 100644 cromite_flags/chrome/browser/flags/android/chrome_feature_list_h/add-bookmark-import-export-actions.inc
@@ -268,7 +269,7 @@ diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
   configs += [
     "//build/config/compiler:wexit_time_destructors",
     "//build/config:precompiled_headers",
@@ -3697,8 +3706,6 @@ static_library("browser") {
@@ -3704,8 +3713,6 @@ static_library("browser") {
       "bookmarks/bookmark_expanded_state_tracker.h",
       "bookmarks/bookmark_expanded_state_tracker_factory.cc",
       "bookmarks/bookmark_expanded_state_tracker_factory.h",
@@ -280,19 +281,20 @@ diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
diff --git a/chrome/browser/bookmarks/android/bookmark_bridge.cc b/chrome/browser/bookmarks/android/bookmark_bridge.cc
--- a/chrome/browser/bookmarks/android/bookmark_bridge.cc
+++ b/chrome/browser/bookmarks/android/bookmark_bridge.cc
@@ -68,6 +68,27 @@
@@ -68,6 +68,28 @@
 #include "content/public/browser/web_contents.h"
 #include "url/gurl.h"
 
+#include "base/android/content_uri_utils.h"
+#include "base/android/path_utils.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/utility/importer/bookmark_html_reader.h"
+#include "chrome/browser/bookmarks/bookmark_html_writer.h"
+#include "chrome/browser/importer/profile_writer.h"
+#include "chrome/browser/platform_util.h"
+#include "chrome/browser/ui/chrome_select_file_policy.h"
+#include "components/user_data_importer/common/imported_bookmark_entry.h"
+#include "components/user_data_importer/content/content_bookmark_parser.h"
+#include "components/user_data_importer/content/content_bookmark_parser_utils.h"
+#include "chrome/common/url_constants.h"
+#include "components/favicon_base/favicon_usage_data.h"
+#include "components/search_engines/template_url.h"
@@ -308,65 +310,7 @@ diff --git a/chrome/browser/bookmarks/android/bookmark_bridge.cc b/chrome/browse
 // Must come after all headers that specialize FromJniType() / ToJniType().
 #include "chrome/browser/bookmarks/android/jni_headers/BookmarkBridge_jni.h"
 
@@ -86,6 +107,57 @@ using bookmarks::android::JavaBookmarkIdGetType;
 using content::BrowserThread;
 using power_bookmarks::PowerBookmarkMeta;
 
+namespace internal {
+
+// Returns true if |url| has a valid scheme that we allow to import. We
+// filter out the URL with a unsupported scheme.
+bool CanImportURL(const GURL& url) {
+  // The URL is not valid.
+  if (!url.is_valid())
+    return false;
+
+  // Filter out the URLs with unsupported schemes.
+  const char* const kInvalidSchemes[] = {"wyciwyg", "place"};
+  for (size_t i = 0; i < std::size(kInvalidSchemes); ++i) {
+    if (url.SchemeIs(kInvalidSchemes[i]))
+      return false;
+  }
+
+  // Check if |url| is about:blank.
+  if (url == url::kAboutBlankURL)
+    return true;
+
+  // If |url| starts with chrome:// or about:, check if it's one of the URLs
+  // that we support.
+  if (url.SchemeIs(content::kChromeUIScheme) ||
+      url.SchemeIs(url::kAboutScheme)) {
+    if (url.host_piece() == chrome::kChromeUIAboutHost)
+      return true;
+
+    GURL fixed_url(url_formatter::FixupURL(url.spec(), std::string()));
+    const base::span<const base::cstring_view> hosts = chrome::ChromeURLHosts();
+    for (const base::cstring_view host : hosts) {
+      if (fixed_url.DomainIs(host)) {
+        return true;
+      }
+    }
+
+    if (base::Contains(chrome::ChromeDebugURLs(), fixed_url.spec())) {
+      return true;
+    }
+
+    // If url has either chrome:// or about: schemes but wasn't found in the
+    // above lists, it means we don't support it, so we don't allow the user
+    // to import it.
+    return false;
+  }
+
+  // Otherwise, we assume the url has a valid (importable) scheme.
+  return true;
+}
+
+} // internal
+
 namespace {
 // The key used to connect the instance of the bookmark bridge to the bookmark
 // model.
@@ -296,6 +368,10 @@ BookmarkBridge::~BookmarkBridge() {
@@ -296,6 +318,10 @@ BookmarkBridge::~BookmarkBridge() {
   partner_bookmarks_shim_observation_.Reset();
   bookmark_model_observation_.Reset();
   profile_observation_.Reset();
@@ -377,7 +321,7 @@ diff --git a/chrome/browser/bookmarks/android/bookmark_bridge.cc b/chrome/browse
 }
 
 void BookmarkBridge::Destroy(JNIEnv* env) {
@@ -847,6 +923,196 @@ jint BookmarkBridge::GetTotalBookmarkCount(
@@ -847,6 +873,177 @@ jint BookmarkBridge::GetTotalBookmarkCount(
   return count;
 }
 
@@ -530,38 +474,19 @@ diff --git a/chrome/browser/bookmarks/android/bookmark_bridge.cc b/chrome/browse
+    return;
+
+  // the following import logic comes from BookmarksFileImporter class
+  std::vector<user_data_importer::ImportedBookmarkEntry> bookmarks;
+  std::vector<user_data_importer::SearchEngineInfo> search_engines;
+  favicon_base::FaviconUsageDataList favicons;
+
+  bookmark_html_reader::ImportBookmarksFile(
+      base::RepeatingCallback<bool(void)>(),
+      base::BindRepeating(internal::CanImportURL),
+      contents,
+      &bookmarks,
+      &search_engines,
+      &favicons);
+  user_data_importer::BookmarkParser::ParsedBookmarks parsed_bookmarks =
+      user_data_importer::ParseBookmarksUnsafe(contents);
+
+  auto *writer = new ProfileWriter(profile_);
+
+  if (!bookmarks.empty()) {
+  if (!parsed_bookmarks.bookmarks.empty()) {
+    // adding bookmarks will begin extensive changes to the model
+    writer->AddBookmarksWithModel(bookmark_model_, bookmarks, u"Imported");
+  }
+  if (!search_engines.empty()) {
+    TemplateURLService::OwnedTemplateURLVector owned_template_urls;
+    for (const auto& search_engine : search_engines) {
+      std::unique_ptr<TemplateURL> owned_template_url = CreateTemplateURL(
+          search_engine.url, search_engine.keyword, search_engine.display_name);
+      if (owned_template_url)
+        owned_template_urls.push_back(std::move(owned_template_url));
+    }
+    writer->AddKeywords(std::move(owned_template_urls), false);
+    writer->AddBookmarksWithModel(bookmark_model_, parsed_bookmarks.bookmarks, u"Imported");
+  }
+
+  std::stringstream message;
+  message << "Imported " << bookmarks.size() << " bookmarks and " <<
+		search_engines.size() << " search engines from " << path.MaybeAsASCII();
+  message << "Imported " << parsed_bookmarks.bookmarks.size() << " bookmarks " <<
+		" from " << path.MaybeAsASCII();
+  auto result = message.str();
+
+  select_file_dialog_->ShowToast(result);
@@ -987,7 +912,7 @@ diff --git a/chrome/browser/bookmarks/android/java/src/org/chromium/chrome/brows
+        // use the download ui and standard file saving
+        DownloadLocationDialogController controller = new DownloadLocationDialogController() {
+            @Override
+            public void onDownloadLocationDialogComplete(String returnedPath) {}
+            public void onDownloadLocationDialogComplete(String returnedPath, boolean didUserConfirm) {}
+
+            @Override
+            public void onDownloadLocationDialogCanceled() {}
@@ -1435,34 +1360,39 @@ diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chro
       <message name="IDS_NOTIFICATION_CATEGORY_VR" desc="Label for notifications in VR, within a list of notification categories. [CHAR_LIMIT=32]">
         Virtual Reality
       </message>
diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn
--- a/chrome/common/BUILD.gn
+++ b/chrome/common/BUILD.gn
@@ -339,6 +339,9 @@ static_library("common_lib") {
       "chrome_descriptors_android.h",
       "media/chrome_media_drm_bridge_client.cc",
       "media/chrome_media_drm_bridge_client.h",
+      ## Bromite dependencies for bookmark import functionality
+      "//components/user_data_importer/common/imported_bookmark_entry.cc",
+      "//components/user_data_importer/common/imported_bookmark_entry.h",
     ]
   } else {
     # Non-Android.
diff --git a/chrome/utility/BUILD.gn b/chrome/utility/BUILD.gn
--- a/chrome/utility/BUILD.gn
+++ b/chrome/utility/BUILD.gn
@@ -222,6 +222,11 @@ static_library("utility") {
@@ -222,6 +222,13 @@ static_library("utility") {
     deps += [ "//chrome/services/pdf:lib" ]
   }
 
+  if (is_android) {
+    sources += [
+    "importer/bookmark_html_reader.cc",
+    "importer/bookmark_html_reader.h",
+      "importer/bookmarks_file_importer.cc",
+      "importer/bookmarks_file_importer.h",
+    ]
+  }
+
   # NSS decryptor is not needed on ChromeOS.
   if (!is_chromeos && use_nss_certs) {
     sources += [
diff --git a/chrome/utility/importer/bookmarks_file_importer.cc b/chrome/utility/importer/bookmarks_file_importer.cc
--- a/chrome/utility/importer/bookmarks_file_importer.cc
+++ b/chrome/utility/importer/bookmarks_file_importer.cc
@@ -103,8 +103,12 @@ void BookmarksFileImporter::StartImport(
       user_data_importer::ParseBookmarksUnsafe(raw_html);
 
   if (!parsed_bookmarks.bookmarks.empty()) {
+#if BUILDFLAG(IS_ANDROID)
+    std::u16string first_folder_name;
+#else
     std::u16string first_folder_name =
         bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP);
+#endif
     std::erase_if(parsed_bookmarks.bookmarks,
                   [](user_data_importer::ImportedBookmarkEntry bookmark) {
                     return !internal::CanImportURL(bookmark.url);
diff --git a/components/headless/select_file_dialog/headless_select_file_dialog.cc b/components/headless/select_file_dialog/headless_select_file_dialog.cc
--- a/components/headless/select_file_dialog/headless_select_file_dialog.cc
+++ b/components/headless/select_file_dialog/headless_select_file_dialog.cc
@@ -1477,6 +1407,29 @@ diff --git a/components/headless/select_file_dialog/headless_select_file_dialog.
   SelectFileDialogCallback callback_;
 };
 
diff --git a/components/user_data_importer/content/content_bookmark_parser_utils.cc b/components/user_data_importer/content/content_bookmark_parser_utils.cc
--- a/components/user_data_importer/content/content_bookmark_parser_utils.cc
+++ b/components/user_data_importer/content/content_bookmark_parser_utils.cc
@@ -89,6 +89,7 @@ std::optional<base::Time> GetTimeAttribute(const std::string& attribute_list,
 
 // Given the URL of a page and a favicon data URL, adds an appropriate record
 // to the given favicon usage vector.
+[[maybe_unused]]
 void DataURLToFaviconUsage(const GURL& link_url,
                            const GURL& favicon_data,
                            favicon_base::FaviconUsageDataList* favicons) {
@@ -438,9 +439,11 @@ BookmarkParser::ParsedBookmarks ParseBookmarksUnsafe(
       }
       parsing_result.bookmarks.push_back(std::move(entry));
 
+#if !BUILDFLAG(IS_ANDROID)
       // Save the favicon. DataURLToFaviconUsage will handle the case where
       // there is no favicon.
       DataURLToFaviconUsage(url, favicon, &parsing_result.favicons);
+#endif
 
       continue;
     }
diff --git a/cromite_flags/chrome/browser/about_flags_cc/add-bookmark-import-export-actions.inc b/cromite_flags/chrome/browser/about_flags_cc/add-bookmark-import-export-actions.inc
new file mode 100644
--- /dev/null
+56 −4
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
 .../java/res/xml/privacy_preferences.xml      | 15 ++++++
 .../browser/LaunchIntentDispatcher.java       | 21 ++++++++
 .../CustomTabIntentDataProvider.java          |  4 +-
 .../customtabs/CustomTabsConnection.java      |  1 +
 .../CustomTabIntentDataProvider.java          | 22 ++++----
 .../customtabs/CustomTabsConnection.java      |  3 +-
 .../IncognitoCustomTabIntentDataProvider.java | 14 +++++
 .../privacy/settings/PrivacySettings.java     | 51 +++++++++++++++++++
 .../flags/android/chrome_feature_list.cc      |  2 +-
@@ -25,7 +25,7 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
 .../OriginVerifier.java                       |  5 ++
 .../core/common/language_experiments.cc       |  1 +
 .../add-custom-tab-intents-privacy-option.inc |  1 +
 13 files changed, 146 insertions(+), 3 deletions(-)
 13 files changed, 156 insertions(+), 13 deletions(-)
 create mode 100644 chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Add-custom-tab-intents-privacy-option.grdp
 create mode 100644 cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/add-custom-tab-intents-privacy-option.inc

@@ -109,6 +109,49 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/LaunchIntentDis
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
@@ -233,16 +233,16 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
 
     // Extra whose value is an array of ints that is supplied to
     // SyntheticTrialRegistry::RegisterExternalExperiments().
-    public static final String EXPERIMENT_IDS =
-            "org.chromium.chrome.browser.customtabs.AGA_EXPERIMENT_IDS";
+    // public static final String EXPERIMENT_IDS =
+    //         "org.chromium.chrome.browser.customtabs.AGA_EXPERIMENT_IDS";
 
     // These Extra Intent parameters allow an Intent to enable or disable a set of Features.
     // The set of Features that may be enabled or disabled is restricted by the code,
     // and initially only two Features may be enabled together, or disabled together.
-    public static final String EXPERIMENTS_ENABLE =
-            "org.chromium.chrome.browser.customtabs.EXPERIMENTS_ENABLE";
-    public static final String EXPERIMENTS_DISABLE =
-            "org.chromium.chrome.browser.customtabs.EXPERIMENTS_DISABLE";
+    // public static final String EXPERIMENTS_ENABLE =
+    //         "org.chromium.chrome.browser.customtabs.EXPERIMENTS_ENABLE";
+    // public static final String EXPERIMENTS_DISABLE =
+    //         "org.chromium.chrome.browser.customtabs.EXPERIMENTS_DISABLE";
 
     /**
      * Extra that, if set, makes the Custom Tab Activity's height to be x pixels, the Custom Tab
@@ -682,7 +682,7 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
                                 TrustedWebActivityIntentBuilder.EXTRA_SCREEN_ORIENTATION,
                                 ScreenOrientation.DEFAULT));
 
-        mGsaExperimentIds = IntentUtils.safeGetIntArrayExtra(intent, EXPERIMENT_IDS);
+        mGsaExperimentIds = null; //IntentUtils.safeGetIntArrayExtra(intent, EXPERIMENT_IDS);
 
         mBreakPointDp = getActivityBreakPointFromIntent(intent);
         mInitialActivityHeight = getInitialActivityHeightFromIntent(intent);
@@ -695,8 +695,8 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
                         intent, EXTRA_ACTIVITY_HEIGHT_RESIZE_BEHAVIOR, ACTIVITY_HEIGHT_DEFAULT);
         mIsPartialCustomTabFixedHeight = activityHeightResizeBehavior == ACTIVITY_HEIGHT_FIXED;
 
-        mInteractWithBackground = CustomTabsIntent.isBackgroundInteractionEnabled(intent);
-        if (IntentUtils.safeHasExtra(intent, EXTRA_ENABLE_BACKGROUND_INTERACTION)) {
+        mInteractWithBackground = false; // CustomTabsIntent.isBackgroundInteractionEnabled(intent);
+        if (((false)) && IntentUtils.safeHasExtra(intent, EXTRA_ENABLE_BACKGROUND_INTERACTION)) {
             @BackgroundInteractBehavior
             int backgroundInteractBehavior =
                     IntentUtils.safeGetIntExtra(
@@ -1267,7 +1267,9 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
     public @CustomTabProfileType int getCustomTabMode() {
         return AlwaysIncognitoLinkInterceptor.isAlwaysIncognito()
@@ -123,6 +166,15 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/Cust
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
@@ -780,7 +780,7 @@ public class CustomTabsConnection {
         ThreadUtils.assertOnUiThread();
         if (extras == null) return;
         int[] experimentIds =
-                IntentUtils.safeGetIntArray(extras, CustomTabIntentDataProvider.EXPERIMENT_IDS);
+                null; //IntentUtils.safeGetIntArray(extras, CustomTabIntentDataProvider.EXPERIMENT_IDS);
         if (experimentIds == null) return;
         // When ids are set through cct, they should not override existing ids.
         boolean override = false;
@@ -996,6 +996,7 @@ public class CustomTabsConnection {
         PostTask.postTask(
                 TaskTraits.UI_DEFAULT,
@@ -379,5 +431,5 @@ new file mode 100644
--- /dev/null
+++ b/cromite_flags/chrome/browser/flags/android/chrome_feature_list_cc/add-custom-tab-intents-privacy-option.inc
@@ -0,0 +1 @@
+SET_CROMITE_FEATURE_DISABLED(kCCTIntentFeatureOverrides);
+// explicitly empty
--
+42 −39

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser
                         TabUtils.setDrawableAndUpdateImageMatrix(thumbnail, result, thumbnailSize);
                     } else {
-                        thumbnail.setImageDrawable(null);
+                        TabListFaviconProvider.TabFavicon tabFavicon = model.get(TabProperties.FAVICON);
+                        TabFavicon tabFavicon = model.get(TabProperties.FAVICON);
+                        if (tabFavicon != null) {
+                            thumbnail.setScaleType(ImageView.ScaleType.CENTER);
+                            thumbnail.setImageDrawable(
@@ -199,7 +199,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/privacy/setting
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd
--- a/chrome/browser/ui/android/strings/android_chrome_strings.grd
+++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -6067,6 +6067,14 @@ To change this setting, <ph name="BEGIN_LINK">BEGIN_LINK</ph>delete the Chrome d
@@ -6194,6 +6194,14 @@ To change this setting, <ph name="BEGIN_LINK">BEGIN_LINK</ph>delete the Chrome d
         Your <ph name="FQDN">%1$s<ex>www.amazon.com</ex></ph> timer ran out. It'll start again tomorrow.
       </message>
 
+1 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ new file mode 100644
+           WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE,
+           WebsiteSettingsRegistry::ALL_PLATFORMS,
+           ContentSettingsInfo::INHERIT_IN_INCOGNITO,
+           ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS);
+           PermissionSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS);
+
+  content_settings::WebsiteSettingsRegistry::GetInstance()
+    ->GetMutable(ContentSettingsType::WEBGL)
Loading