add prompt also after selecting file by ui, remove prefs addon patch, add commit message

This commit is contained in:
Carmelo Messina 2021-10-19 09:14:03 +02:00
parent 9765d4d994
commit 741d1d4e99
2 changed files with 119 additions and 221 deletions

View file

@ -1,113 +0,0 @@
From: uazo <uazo@users.noreply.github.com>
Date: Thu, 12 Aug 2021 08:08:56 +0000
Subject: Add support for prefs addon
---
.../chrome/browser/settings/MainSettings.java | 7 +++
chrome/android/proguard/main.flags | 7 +++
.../browser_ui/settings/SettingsUtils.java | 47 +++++++++++++++++++
3 files changed, 61 insertions(+)
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/MainSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/settings/MainSettings.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/settings/MainSettings.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/settings/MainSettings.java
@@ -115,6 +115,8 @@ public class MainSettings extends PreferenceFragmentCompat
private void createPreferences() {
SettingsUtils.addPreferencesFromResource(this, R.xml.main_preferences);
+ createBromitePreferences();
+
cachePreferences();
updatePasswordsPreference();
@@ -264,4 +266,9 @@ public class MainSettings extends PreferenceFragmentCompat
}
};
}
+
+ private void createBromitePreferences() {
+ SettingsUtils.inflatePrefsAddon(this, "main_preferences_addon_",
+ R.xml.class.getFields());
+ }
}
diff --git a/chrome/android/proguard/main.flags b/chrome/android/proguard/main.flags
--- a/chrome/android/proguard/main.flags
+++ b/chrome/android/proguard/main.flags
@@ -63,3 +63,10 @@
-keep,allowobfuscation public class ** extends org.chromium.chrome.browser.base.SplitCompat*$Impl {
public <init>();
}
+
+# Keep fields name for all R.xml
+# used in SettingsUtils.java
+# components/browser_ui/settings/android/java/src/org/chromium/components/browser_ui/settings
+-keepclassmembers class **.R$xml* {
+ public static <fields>;
+}
diff --git a/components/browser_ui/settings/android/java/src/org/chromium/components/browser_ui/settings/SettingsUtils.java b/components/browser_ui/settings/android/java/src/org/chromium/components/browser_ui/settings/SettingsUtils.java
--- a/components/browser_ui/settings/android/java/src/org/chromium/components/browser_ui/settings/SettingsUtils.java
+++ b/components/browser_ui/settings/android/java/src/org/chromium/components/browser_ui/settings/SettingsUtils.java
@@ -24,6 +24,12 @@ import androidx.preference.PreferenceFragmentCompat;
import org.chromium.base.ApiCompatibilityUtils;
+import org.chromium.base.Log;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.PreferenceManager;
+import android.content.res.Resources;
+import java.lang.reflect.Field;
+
/**
* A helper class for Settings.
*/
@@ -109,6 +115,47 @@ public class SettingsUtils {
return true;
}
+ public static PreferenceScreen inflatePrefsAddon(PreferenceFragmentCompat preferenceFragment,
+ String name,
+ Field[] fields) {
+ Resources resources = preferenceFragment.getResources();
+
+ for(int count=0; count < fields.length; count++) {
+ String assetName = fields[count].getName();
+ if (assetName.startsWith(name)) {
+ int resId = 0;
+ try {
+ resId = fields[count].getInt(null);
+ } catch (IllegalAccessException e) {
+ Log.e("settingsutils", "Error getting resource id", e);
+ }
+
+ if (resId != 0) {
+ try {
+ return SettingsUtils.inflatePreferencesFromResource(preferenceFragment, resId);
+ } catch (Throwable e) {
+ Log.e("settingsutils", "Error inflating from resource", e);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static PreferenceScreen inflatePreferencesFromResource(
+ PreferenceFragmentCompat preferenceFragment, @XmlRes int preferencesResId) {
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
+ try {
+ PreferenceManager preferenceManager = preferenceFragment.getPreferenceManager();
+ final PreferenceScreen xmlRoot = preferenceManager.inflateFromResource(
+ preferenceFragment.getContext(),
+ preferencesResId, preferenceFragment.getPreferenceScreen());
+ return xmlRoot;
+ } finally {
+ StrictMode.setThreadPolicy(oldPolicy);
+ }
+ }
+
/**
* There is no regular way to access the overflow button of an {@link ActionMenuView}.
* Checking whether a given view is an {@link ImageView} with the correct icon is an
--
2.17.1

View file

@ -1,14 +1,34 @@
From: uazo <uazo@users.noreply.github.com>
Date: Fri, 13 Aug 2021 17:10:47 +0000
Subject: Experimental user scripts support preview
needs
add-support-for-ISupportHelpAndFeedback.patch
Subject: Experimental user scripts support
Activate userscripts as in the desktop version
of chromium.
is possible to add them in two ways: by selecting
files from the picker in the settings or downloading
the scripts and opening it from downloads
(only if ends with .user.js)
new imported scripts are disabled by default: they
can be activated via the ui.
enabled headers are: name, version, description,
include, exclude, match, exclude_match (only http and
https), run-at (document-start, document-end,
document-idle), homepage, url_source
ui, among other things, allows you to see the source
of the script.
needs add-support-for-ISupportHelpAndFeedback.patch
see also: https://github.com/bromite/bromite/pull/857
---
chrome/android/BUILD.gn | 5 +
.../android/java/res/xml/main_preferences.xml | 5 +
.../chrome/browser/AfterStartupTaskUtils.java | 2 +
.../browser/download/DownloadUtils.java | 6 +
.../init/ProcessInitializationHandler.java | 3 +
chrome/android/java_sources.gni | 3 +
chrome/browser/BUILD.gn | 5 +
chrome/browser/about_flags.cc | 5 +
@ -28,7 +48,7 @@ add-support-for-ISupportHelpAndFeedback.patch
.../chrome_content_renderer_client.cc | 37 +
.../renderer/chrome_render_thread_observer.cc | 3 +
components/components_strings.grd | 1 +
components/user_scripts/android/BUILD.gn | 81 ++
components/user_scripts/android/BUILD.gn | 80 ++
.../java/res/layout/accept_script_item.xml | 160 ++++
.../java/res/layout/accept_script_list.xml | 10 +
.../java/res/layout/scripts_preference.xml | 40 +
@ -40,12 +60,12 @@ add-support-for-ISupportHelpAndFeedback.patch
.../components/user_scripts/ScriptInfo.java | 37 +
.../user_scripts/ScriptListBaseAdapter.java | 163 ++++
.../user_scripts/ScriptListPreference.java | 171 ++++
.../user_scripts/UserScriptsBridge.java | 178 ++++
.../user_scripts/UserScriptsPreferences.java | 139 +++
.../user_scripts/UserScriptsBridge.java | 200 +++++
.../user_scripts/UserScriptsPreferences.java | 116 +++
.../user_scripts/android/java_sources.gni | 18 +
.../android/user_scripts_bridge.cc | 174 ++++
.../android/user_scripts_bridge.cc | 173 ++++
.../android/user_scripts_bridge.h | 31 +
components/user_scripts/browser/BUILD.gn | 86 ++
components/user_scripts/browser/BUILD.gn | 83 ++
.../user_scripts/browser/file_task_runner.cc | 40 +
.../user_scripts/browser/file_task_runner.h | 34 +
.../browser/resources/browser_resources.grd | 14 +
@ -62,7 +82,7 @@ add-support-for-ISupportHelpAndFeedback.patch
.../user_scripts/browser/user_script_prefs.h | 62 ++
.../browser/userscripts_browser_client.cc | 78 ++
.../browser/userscripts_browser_client.h | 62 ++
components/user_scripts/common/BUILD.gn | 52 ++
components/user_scripts/common/BUILD.gn | 49 ++
components/user_scripts/common/constants.h | 21 +
components/user_scripts/common/error_utils.cc | 54 ++
components/user_scripts/common/error_utils.h | 24 +
@ -102,7 +122,7 @@ add-support-for-ISupportHelpAndFeedback.patch
.../user_scripts/renderer/scripts_run_info.cc | 31 +
.../user_scripts/renderer/scripts_run_info.h | 70 ++
.../renderer/user_script_injector.cc | 228 +++++
.../renderer/user_script_injector.h | 86 ++
.../renderer/user_script_injector.h | 87 ++
.../user_scripts/renderer/user_script_set.cc | 259 ++++++
.../user_scripts/renderer/user_script_set.h | 102 +++
.../renderer/user_script_set_manager.cc | 77 ++
@ -115,7 +135,7 @@ add-support-for-ISupportHelpAndFeedback.patch
.../renderer/web_ui_injection_host.h | 28 +
.../strings/userscripts_strings.grdp | 55 ++
tools/gritsettings/resource_ids.spec | 6 +
110 files changed, 9437 insertions(+), 2 deletions(-)
110 files changed, 9430 insertions(+), 2 deletions(-)
create mode 100755 components/user_scripts/android/BUILD.gn
create mode 100644 components/user_scripts/android/java/res/layout/accept_script_item.xml
create mode 100644 components/user_scripts/android/java/res/layout/accept_script_list.xml
@ -206,7 +226,7 @@ add-support-for-ISupportHelpAndFeedback.patch
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
--- a/chrome/android/BUILD.gn
+++ b/chrome/android/BUILD.gn
@@ -247,6 +247,10 @@ android_resources("chrome_app_java_resources") {
@@ -252,6 +252,10 @@ android_resources("chrome_app_java_resources") {
"//third_party/androidx:androidx_preference_preference_java",
"//third_party/androidx:androidx_recyclerview_recyclerview_java",
]
@ -217,7 +237,7 @@ diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
}
if (enable_vr) {
@@ -505,6 +509,7 @@ android_library("chrome_java") {
@@ -513,6 +517,7 @@ android_library("chrome_java") {
"//components/ukm/android:java",
"//components/url_formatter/android:url_formatter_java",
"//components/user_prefs/android:java",
@ -228,7 +248,7 @@ diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
diff --git a/chrome/android/java/res/xml/main_preferences.xml b/chrome/android/java/res/xml/main_preferences.xml
--- a/chrome/android/java/res/xml/main_preferences.xml
+++ b/chrome/android/java/res/xml/main_preferences.xml
@@ -80,6 +80,11 @@
@@ -86,6 +86,11 @@
android:key="useragent_settings"
android:order="20"
android:title="@string/prefs_useragent_settings"/>
@ -240,29 +260,10 @@ diff --git a/chrome/android/java/res/xml/main_preferences.xml b/chrome/android/j
<Preference
android:fragment="org.chromium.chrome.browser.language.settings.LanguageSettings"
android:key="languages"
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/AfterStartupTaskUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/AfterStartupTaskUtils.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/AfterStartupTaskUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/AfterStartupTaskUtils.java
@@ -4,6 +4,7 @@
package org.chromium.chrome.browser;
import org.chromium.base.annotations.NativeMethods;
+import org.chromium.chrome.browser.user_scripts.UserScriptsUtils;
/**
* JNI call glue for AfterStartupTaskUtils in C++.
@@ -17,6 +18,7 @@ public final class AfterStartupTaskUtils {
* to run and newly posted tasks will no longer be deferred.
*/
public static void setStartupComplete() {
+ UserScriptsUtils.Initialize();
AfterStartupTaskUtilsJni.get().setStartupComplete();
}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
@@ -62,6 +62,7 @@ import org.chromium.content_public.browser.BrowserStartupController;
@@ -63,6 +63,7 @@ import org.chromium.content_public.browser.BrowserStartupController;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.widget.Toast;
@ -270,7 +271,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/Downlo
import java.io.File;
@@ -393,6 +394,11 @@ public class DownloadUtils {
@@ -400,6 +401,11 @@ public class DownloadUtils {
public static boolean openFile(String filePath, String mimeType, String downloadGuid,
OTRProfileID otrProfileID, String originalUrl, String referrer,
@DownloadOpenSource int source, Context context) {
@ -282,6 +283,26 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/Downlo
DownloadMetrics.recordDownloadOpen(source, mimeType);
DownloadManagerService service = DownloadManagerService.getDownloadManagerService();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/init/ProcessInitializationHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/init/ProcessInitializationHandler.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/init/ProcessInitializationHandler.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/init/ProcessInitializationHandler.java
@@ -113,6 +113,8 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
+import org.chromium.chrome.browser.user_scripts.UserScriptsUtils;
+
/**
* Handles the initialization dependences of the browser process. This is meant to handle the
* initialization that is not tied to any particular Activity, and the logic that should only be
@@ -293,6 +295,7 @@ public class ProcessInitializationHandler {
DefaultBrowserInfo.initBrowserFetcher();
+ UserScriptsUtils.Initialize();
AfterStartupTaskUtils.setStartupComplete();
PartnerBrowserCustomizations.getInstance().setOnInitializeAsyncFinished(
diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni
--- a/chrome/android/java_sources.gni
+++ b/chrome/android/java_sources.gni
@ -302,7 +323,7 @@ diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -3359,6 +3359,11 @@ static_library("browser") {
@@ -3410,6 +3410,11 @@ static_library("browser") {
]
deps += [ "//chrome/android/modules/dev_ui/provider:native" ]
}
@ -325,7 +346,7 @@ diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
#include "components/version_info/version_info.h"
#include "components/viz/common/features.h"
#include "components/viz/common/switches.h"
@@ -6514,6 +6515,10 @@ const FeatureEntry kFeatureEntries[] = {
@@ -6387,6 +6388,10 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(features::kUserDataSnapshot)},
#endif
@ -339,7 +360,7 @@ diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -4478,7 +4478,8 @@ ChromeContentBrowserClient::CreateURLLoaderThrottles(
@@ -4475,7 +4475,8 @@ ChromeContentBrowserClient::CreateURLLoaderThrottles(
chrome::mojom::DynamicParams dynamic_params = {
profile->GetPrefs()->GetBoolean(prefs::kForceGoogleSafeSearch),
profile->GetPrefs()->GetInteger(prefs::kForceYouTubeRestrict),
@ -352,7 +373,7 @@ diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/ch
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
@@ -5439,6 +5439,11 @@ const char kUserDataSnapshotDescription[] =
@@ -5239,6 +5239,11 @@ const char kUserDataSnapshotDescription[] =
"update and restoring them after a version rollback.";
#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
@ -367,7 +388,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
@@ -3168,6 +3168,9 @@ extern const char kUserDataSnapshotName[];
@@ -3046,6 +3046,9 @@ extern const char kUserDataSnapshotName[];
extern const char kUserDataSnapshotDescription[];
#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
@ -388,7 +409,7 @@ diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browse
#else // defined(OS_ANDROID)
#include "chrome/browser/accessibility/live_caption_controller.h"
#include "chrome/browser/cart/cart_service.h"
@@ -1132,6 +1133,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
@@ -1148,6 +1149,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
translate::TranslatePrefs::RegisterProfilePrefs(registry);
omnibox::RegisterProfilePrefs(registry);
ZeroSuggestProvider::RegisterProfilePrefs(registry);
@ -410,7 +431,7 @@ diff --git a/chrome/browser/profiles/BUILD.gn b/chrome/browser/profiles/BUILD.gn
diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
--- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
+++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
@@ -207,6 +207,8 @@
@@ -212,6 +212,8 @@
#include "chrome/browser/ui/cocoa/screentime/screentime_features.h"
#endif
@ -419,7 +440,7 @@ diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
namespace chrome {
void AddProfilesExtraParts(ChromeBrowserMainParts* main_parts) {
@@ -489,6 +491,7 @@ void ChromeBrowserMainExtraPartsProfiles::
@@ -503,6 +505,7 @@ void ChromeBrowserMainExtraPartsProfiles::
#endif
WebDataServiceFactory::GetInstance();
webrtc_event_logging::WebRtcEventLogManagerKeyedServiceFactory::GetInstance();
@ -465,7 +486,7 @@ diff --git a/chrome/browser/profiles/renderer_updater.cc b/chrome/browser/profil
namespace {
#if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -74,6 +76,7 @@ RendererUpdater::RendererUpdater(Profile* profile) : profile_(profile) {
@@ -75,6 +77,7 @@ RendererUpdater::RendererUpdater(Profile* profile) : profile_(profile) {
force_google_safesearch_.Init(prefs::kForceGoogleSafeSearch, pref_service);
force_youtube_restrict_.Init(prefs::kForceYouTubeRestrict, pref_service);
allowed_domains_for_apps_.Init(prefs::kAllowedDomainsForApps, pref_service);
@ -473,7 +494,7 @@ diff --git a/chrome/browser/profiles/renderer_updater.cc b/chrome/browser/profil
pref_change_registrar_.Init(pref_service);
pref_change_registrar_.Add(
@@ -88,6 +91,10 @@ RendererUpdater::RendererUpdater(Profile* profile) : profile_(profile) {
@@ -89,6 +92,10 @@ RendererUpdater::RendererUpdater(Profile* profile) : profile_(profile) {
prefs::kAllowedDomainsForApps,
base::BindRepeating(&RendererUpdater::UpdateAllRenderers,
base::Unretained(this)));
@ -484,7 +505,7 @@ diff --git a/chrome/browser/profiles/renderer_updater.cc b/chrome/browser/profil
}
RendererUpdater::~RendererUpdater() {
@@ -221,5 +228,6 @@ void RendererUpdater::UpdateRenderer(
@@ -223,5 +230,6 @@ void RendererUpdater::UpdateRenderer(
->SetConfiguration(chrome::mojom::DynamicParams::New(
force_google_safesearch_.GetValue(),
force_youtube_restrict_.GetValue(),
@ -506,7 +527,7 @@ diff --git a/chrome/browser/profiles/renderer_updater.h b/chrome/browser/profile
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -85,6 +85,7 @@
@@ -84,6 +84,7 @@
#include "components/security_interstitials/content/urls.h"
#include "components/signin/public/base/signin_buildflags.h"
#include "components/site_engagement/content/site_engagement_service.h"
@ -514,7 +535,7 @@ diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrom
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/content_client.h"
@@ -645,6 +646,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
@@ -650,6 +651,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<UserActionsUI>;
if (url.host_piece() == chrome::kChromeUIVersionHost)
return &NewWebUI<VersionUI>;
@ -526,7 +547,7 @@ diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrom
diff --git a/chrome/chrome_paks.gni b/chrome/chrome_paks.gni
--- a/chrome/chrome_paks.gni
+++ b/chrome/chrome_paks.gni
@@ -104,6 +104,7 @@ template("chrome_extra_paks") {
@@ -105,6 +105,7 @@ template("chrome_extra_paks") {
"$root_gen_dir/third_party/blink/public/resources/inspector_overlay_resources.pak",
"$root_gen_dir/ui/resources/webui_generated_resources.pak",
"$root_gen_dir/ui/resources/webui_resources.pak",
@ -534,7 +555,7 @@ diff --git a/chrome/chrome_paks.gni b/chrome/chrome_paks.gni
]
deps = [
"//base/tracing/protos:chrome_track_event_resources",
@@ -119,6 +120,7 @@ template("chrome_extra_paks") {
@@ -120,6 +121,7 @@ template("chrome_extra_paks") {
"//third_party/blink/public:devtools_inspector_resources",
"//third_party/blink/public:resources",
"//ui/resources",
@ -556,10 +577,10 @@ diff --git a/chrome/common/renderer_configuration.mojom b/chrome/common/renderer
diff --git a/chrome/renderer/BUILD.gn b/chrome/renderer/BUILD.gn
--- a/chrome/renderer/BUILD.gn
+++ b/chrome/renderer/BUILD.gn
@@ -169,6 +169,7 @@ static_library("renderer") {
"//components/feed:buildflags",
@@ -171,6 +171,7 @@ static_library("renderer") {
"//components/feed:feature_list",
"//components/feed/content/renderer:feed_renderer",
"//components/history_clusters/core",
+ "//components/user_scripts/renderer",
"//components/network_hints/renderer",
"//components/no_state_prefetch/common",
@ -567,7 +588,7 @@ diff --git a/chrome/renderer/BUILD.gn b/chrome/renderer/BUILD.gn
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -250,6 +250,9 @@
@@ -251,6 +251,9 @@
#include "chrome/renderer/supervised_user/supervised_user_error_page_controller_delegate_impl.h"
#endif
@ -577,7 +598,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
using autofill::AutofillAgent;
using autofill::AutofillAssistantAgent;
using autofill::PasswordAutofillAgent;
@@ -404,6 +407,12 @@ void ChromeContentRendererClient::RenderThreadStarted() {
@@ -405,6 +408,12 @@ void ChromeContentRendererClient::RenderThreadStarted() {
WebString::FromASCII(extensions::kExtensionScheme));
#endif
@ -590,7 +611,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
#if BUILDFLAG(ENABLE_SPELLCHECK)
if (!spellcheck_)
InitSpellCheck();
@@ -540,6 +549,13 @@ void ChromeContentRendererClient::RenderFrameCreated(
@@ -541,6 +550,13 @@ void ChromeContentRendererClient::RenderFrameCreated(
render_frame, registry);
#endif
@ -604,7 +625,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
#if BUILDFLAG(ENABLE_PLUGINS)
new PepperHelper(render_frame);
#endif
@@ -1527,7 +1543,14 @@ void ChromeContentRendererClient::RunScriptsAtDocumentStart(
@@ -1533,7 +1549,14 @@ void ChromeContentRendererClient::RunScriptsAtDocumentStart(
ChromeExtensionsRendererClient::GetInstance()->RunScriptsAtDocumentStart(
render_frame);
// |render_frame| might be dead by now.
@ -619,7 +640,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
}
void ChromeContentRendererClient::RunScriptsAtDocumentEnd(
@@ -1536,7 +1559,14 @@ void ChromeContentRendererClient::RunScriptsAtDocumentEnd(
@@ -1542,7 +1565,14 @@ void ChromeContentRendererClient::RunScriptsAtDocumentEnd(
ChromeExtensionsRendererClient::GetInstance()->RunScriptsAtDocumentEnd(
render_frame);
// |render_frame| might be dead by now.
@ -634,7 +655,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
}
void ChromeContentRendererClient::RunScriptsAtDocumentIdle(
@@ -1545,7 +1575,14 @@ void ChromeContentRendererClient::RunScriptsAtDocumentIdle(
@@ -1551,7 +1581,14 @@ void ChromeContentRendererClient::RunScriptsAtDocumentIdle(
ChromeExtensionsRendererClient::GetInstance()->RunScriptsAtDocumentIdle(
render_frame);
// |render_frame| might be dead by now.
@ -684,7 +705,7 @@ diff --git a/components/user_scripts/android/BUILD.gn b/components/user_scripts/
new file mode 100755
--- /dev/null
+++ b/components/user_scripts/android/BUILD.gn
@@ -0,0 +1,81 @@
@@ -0,0 +1,80 @@
+# This file is part of Bromite.
+
+# Bromite is free software: you can redistribute it and/or modify
@ -761,7 +782,6 @@ new file mode 100755
+ ":user_scripts_jni_headers",
+ "//base",
+ "//components/user_scripts/browser",
+ "//components/embedder_support/android:browser_context",
+ "//components/permissions",
+ "//content/public/browser",
+ ]
@ -1653,7 +1673,7 @@ diff --git a/components/user_scripts/android/java/src/org/chromium/components/us
new file mode 100644
--- /dev/null
+++ b/components/user_scripts/android/java/src/org/chromium/components/user_scripts/UserScriptsBridge.java
@@ -0,0 +1,178 @@
@@ -0,0 +1,200 @@
+/*
+ This file is part of Bromite.
+
@ -1685,6 +1705,8 @@ new file mode 100644
+import android.content.Intent;
+import android.net.Uri;
+import androidx.annotation.Nullable;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
@ -1746,14 +1768,34 @@ new file mode 100644
+ public void onIntentCompleted(WindowAndroid window, int resultCode, Intent data) {
+ if (data == null) return;
+ Uri filePath = data.getData();
+ UserScriptsBridgeJni.get().tryToInstall(filePath.toString());
+ TryToInstall(context, filePath.toString());
+ }
+ },
+ null);
+ }
+
+ public static void TryToInstall(String ScriptFullPath) {
+ UserScriptsBridgeJni.get().tryToInstall(ScriptFullPath);
+ public static void TryToInstall(Context context, String ScriptFullPath) {
+ DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ switch (which){
+ case DialogInterface.BUTTON_POSITIVE:
+ UserScriptsBridgeJni.get().tryToInstall(ScriptFullPath);
+ break;
+
+ case DialogInterface.BUTTON_NEGATIVE:
+ break;
+ }
+ }
+ };
+
+ String message = context.getString(R.string.ask_to_install, ScriptFullPath);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setMessage(message)
+ .setPositiveButton(context.getString(R.string.yes), dialogClickListener)
+ .setNegativeButton(context.getString(R.string.no), dialogClickListener)
+ .show();
+ }
+
+ public static List<ScriptInfo> getUserScriptItems() {
@ -1832,12 +1874,11 @@ new file mode 100644
+ }
+
+}
\ No newline at end of file
diff --git a/components/user_scripts/android/java/src/org/chromium/components/user_scripts/UserScriptsPreferences.java b/components/user_scripts/android/java/src/org/chromium/components/user_scripts/UserScriptsPreferences.java
new file mode 100755
--- /dev/null
+++ b/components/user_scripts/android/java/src/org/chromium/components/user_scripts/UserScriptsPreferences.java
@@ -0,0 +1,139 @@
@@ -0,0 +1,116 @@
+/*
+ This file is part of Bromite.
+
@ -1858,10 +1899,8 @@ new file mode 100755
+package org.chromium.components.user_scripts;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.Intent;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.provider.Browser;
+import android.net.Uri;
@ -1952,28 +1991,7 @@ new file mode 100755
+
+ String scriptToInstall = (String)getArguments().getSerializable(EXTRA_SCRIPT_FILE);
+ if (scriptToInstall != null) {
+ DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ switch (which){
+ case DialogInterface.BUTTON_POSITIVE:
+ UserScriptsBridge.TryToInstall(scriptToInstall);
+ break;
+
+ case DialogInterface.BUTTON_NEGATIVE:
+ break;
+ }
+ }
+ };
+
+ Context context = getContext();
+ String message = context.getString(R.string.ask_to_install, scriptToInstall);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setMessage(message)
+ .setPositiveButton(context.getString(R.string.yes), dialogClickListener)
+ .setNegativeButton(context.getString(R.string.no), dialogClickListener)
+ .show();
+ UserScriptsBridge.TryToInstall(getContext(), scriptToInstall);
+ }
+ }
+}
@ -2004,7 +2022,7 @@ diff --git a/components/user_scripts/android/user_scripts_bridge.cc b/components
new file mode 100644
--- /dev/null
+++ b/components/user_scripts/android/user_scripts_bridge.cc
@@ -0,0 +1,174 @@
@@ -0,0 +1,173 @@
+/*
+ This file is part of Bromite.
+
@ -2034,7 +2052,6 @@ new file mode 100644
+#include "base/android/jni_array.h"
+#include "base/android/jni_string.h"
+#include "base/android/scoped_java_ref.h"
+#include "components/embedder_support/android/browser_context/browser_context_handle.h"
+#include "ui/android/window_android.h"
+
+#include "components/user_scripts/android/user_scripts_jni_headers/UserScriptsBridge_jni.h"
@ -2179,7 +2196,6 @@ new file mode 100644
+}
+
+}
\ No newline at end of file
diff --git a/components/user_scripts/android/user_scripts_bridge.h b/components/user_scripts/android/user_scripts_bridge.h
new file mode 100644
--- /dev/null
@ -2221,7 +2237,7 @@ diff --git a/components/user_scripts/browser/BUILD.gn b/components/user_scripts/
new file mode 100755
--- /dev/null
+++ b/components/user_scripts/browser/BUILD.gn
@@ -0,0 +1,86 @@
@@ -0,0 +1,83 @@
+# This file is part of Bromite.
+
+# Bromite is free software: you can redistribute it and/or modify
@ -2288,9 +2304,6 @@ new file mode 100755
+
+ configs += [
+ "//build/config:precompiled_headers",
+
+ # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
+ "//build/config/compiler:no_size_t_to_int_warning",
+ "//build/config/compiler:wexit_time_destructors",
+ ]
+}
@ -3772,16 +3785,16 @@ new file mode 100644
+ const std::string& key,
+ int64_t* value) {
+ DCHECK(dict);
+ std::string value_str;
+ if (!dict->GetStringWithoutPathExpansion(key, &value_str)) {
+ const std::string* value_str = dict->FindStringKey(key);
+ if (!value_str) {
+ VLOG(2) << "Can't find key in local pref dictionary. Invalid key: " << key
+ << ".";
+ return false;
+ }
+
+ if (!base::StringToInt64(value_str, value)) {
+ if (!base::StringToInt64(*value_str, value)) {
+ VLOG(2) << "Can't change string to int64_t. Invalid string value: "
+ << value_str << ".";
+ << *value_str << ".";
+ return false;
+ }
+
@ -4186,7 +4199,7 @@ diff --git a/components/user_scripts/common/BUILD.gn b/components/user_scripts/c
new file mode 100755
--- /dev/null
+++ b/components/user_scripts/common/BUILD.gn
@@ -0,0 +1,52 @@
@@ -0,0 +1,49 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
@ -4218,9 +4231,6 @@ new file mode 100755
+
+ configs += [
+ "//build/config:precompiled_headers",
+
+ # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
+ "//build/config/compiler:no_size_t_to_int_warning",
+ "//build/config/compiler:wexit_time_destructors",
+ ]
+
@ -9458,7 +9468,7 @@ diff --git a/components/user_scripts/renderer/user_script_injector.h b/component
new file mode 100755
--- /dev/null
+++ b/components/user_scripts/renderer/user_script_injector.h
@@ -0,0 +1,86 @@
@@ -0,0 +1,87 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
@ -9470,6 +9480,7 @@ new file mode 100755
+#include <string>
+
+#include "base/macros.h"
+#include "base/values.h"
+#include "base/scoped_observation.h"
+#include "../common/user_script.h"
+#include "script_injection.h"
@ -10458,7 +10469,7 @@ new file mode 100755
diff --git a/tools/gritsettings/resource_ids.spec b/tools/gritsettings/resource_ids.spec
--- a/tools/gritsettings/resource_ids.spec
+++ b/tools/gritsettings/resource_ids.spec
@@ -536,6 +536,12 @@
@@ -556,6 +556,12 @@
"components/autofill/core/browser/autofill_address_rewriter_resources.grd":{
"includes": [2880]
},