|
@@ -1,5 +1,5 @@
|
|
|
From: uazo <uazo@users.noreply.github.com>
|
|
|
-Date: Sat, 20 Mar 2021 09:37:12 +0000
|
|
|
+Date: Mon, 17 May 2021 13:06:13 +0000
|
|
|
Subject: Experimental user scripts support preview
|
|
|
needs
|
|
|
add-support-for-ISupportHelpAndFeedback.patch
|
|
@@ -29,7 +29,7 @@ add-support-for-prefs-addon.patch
|
|
|
.../android/java/res/values/dimens.xml | 11 +
|
|
|
.../main_preferences_addon_userscripts.xml | 29 +
|
|
|
.../java/res/xml/userscripts_preferences.xml | 40 +
|
|
|
- .../user_scripts/UserScriptsUtils.java | 78 ++
|
|
|
+ .../user_scripts/UserScriptsUtils.java | 79 ++
|
|
|
.../user_scripts/FragmentWindowAndroid.java | 68 ++
|
|
|
.../user_scripts/IUserScriptsUtils.java | 22 +
|
|
|
.../components/user_scripts/ScriptInfo.java | 33 +
|
|
@@ -60,7 +60,7 @@ add-support-for-prefs-addon.patch
|
|
|
components/user_scripts/common/BUILD.gn | 52 ++
|
|
|
components/user_scripts/common/constants.h | 21 +
|
|
|
components/user_scripts/common/error_utils.cc | 54 ++
|
|
|
- components/user_scripts/common/error_utils.h | 25 +
|
|
|
+ components/user_scripts/common/error_utils.h | 24 +
|
|
|
.../common/extension_message_generator.cc | 29 +
|
|
|
.../common/extension_message_generator.h | 11 +
|
|
|
.../user_scripts/common/extension_messages.cc | 40 +
|
|
@@ -202,7 +202,7 @@ add-support-for-prefs-addon.patch
|
|
|
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
|
|
|
--- a/chrome/android/BUILD.gn
|
|
|
+++ b/chrome/android/BUILD.gn
|
|
|
-@@ -236,6 +236,9 @@ android_resources("chrome_app_java_resources") {
|
|
|
+@@ -239,6 +239,9 @@ android_resources("chrome_app_java_resources") {
|
|
|
"//third_party/androidx:androidx_preference_preference_java",
|
|
|
"//third_party/androidx:androidx_recyclerview_recyclerview_java",
|
|
|
]
|
|
@@ -212,8 +212,8 @@ diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
|
|
|
}
|
|
|
|
|
|
if (enable_vr) {
|
|
|
-@@ -465,6 +468,7 @@ android_library("chrome_java") {
|
|
|
- "//components/translate/core/common:translate_infobar_event_enum_java",
|
|
|
+@@ -477,6 +480,7 @@ android_library("chrome_java") {
|
|
|
+ "//components/ukm/android:java",
|
|
|
"//components/url_formatter/android:url_formatter_java",
|
|
|
"//components/user_prefs/android:java",
|
|
|
+ "//components/user_scripts/android:java",
|
|
@@ -250,17 +250,17 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/Downlo
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
-@@ -382,6 +383,11 @@ public class DownloadUtils {
|
|
|
+@@ -374,6 +375,11 @@ public class DownloadUtils {
|
|
|
Context context = ContextUtils.getApplicationContext();
|
|
|
DownloadManagerService service = DownloadManagerService.getDownloadManagerService();
|
|
|
|
|
|
+ if (UserScriptsUtils.getInstance().openFile(filePath, mimeType, downloadGuid,
|
|
|
-+ isOffTheRecord, originalUrl, referrer)) {
|
|
|
++ originalUrl, referrer)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
// Check if Chrome should open the file itself.
|
|
|
- if (service.isDownloadOpenableInBrowser(isOffTheRecord, mimeType)) {
|
|
|
+ if (service.isDownloadOpenableInBrowser(mimeType)) {
|
|
|
// Share URIs use the content:// scheme when able, which looks bad when displayed
|
|
|
diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni
|
|
|
--- a/chrome/android/java_sources.gni
|
|
@@ -282,7 +282,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
|
|
|
-@@ -3377,6 +3377,11 @@ static_library("browser") {
|
|
|
+@@ -3345,6 +3345,11 @@ static_library("browser") {
|
|
|
]
|
|
|
deps += [ "//chrome/android/modules/dev_ui/provider:native" ]
|
|
|
}
|
|
@@ -305,7 +305,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"
|
|
|
-@@ -6502,6 +6503,14 @@ const FeatureEntry kFeatureEntries[] = {
|
|
|
+@@ -6455,6 +6456,14 @@ const FeatureEntry kFeatureEntries[] = {
|
|
|
FEATURE_VALUE_TYPE(features::kUserDataSnapshot)},
|
|
|
#endif
|
|
|
|
|
@@ -323,7 +323,7 @@ diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
|
|
|
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
|
|
|
-@@ -5094,6 +5094,16 @@ const char kUserDataSnapshotDescription[] =
|
|
|
+@@ -5149,6 +5149,16 @@ const char kUserDataSnapshotDescription[] =
|
|
|
"update and restoring them after a version rollback.";
|
|
|
#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
|
|
|
|
|
@@ -343,7 +343,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
|
|
|
-@@ -2995,6 +2995,11 @@ extern const char kUserDataSnapshotName[];
|
|
|
+@@ -3014,6 +3014,11 @@ extern const char kUserDataSnapshotName[];
|
|
|
extern const char kUserDataSnapshotDescription[];
|
|
|
#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
|
|
|
|
|
@@ -366,7 +366,7 @@ diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browse
|
|
|
#else // defined(OS_ANDROID)
|
|
|
#include "chrome/browser/accessibility/caption_controller.h"
|
|
|
#include "chrome/browser/cart/cart_service.h"
|
|
|
-@@ -969,6 +970,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
|
|
|
+@@ -977,6 +978,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
|
|
|
translate::TranslatePrefs::RegisterProfilePrefs(registry);
|
|
|
omnibox::RegisterProfilePrefs(registry);
|
|
|
ZeroSuggestProvider::RegisterProfilePrefs(registry);
|
|
@@ -377,8 +377,8 @@ diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browse
|
|
|
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
|
|
|
-@@ -200,6 +200,8 @@
|
|
|
- #include "chrome/browser/lacros/cert_db_initializer_factory.h"
|
|
|
+@@ -205,6 +205,8 @@
|
|
|
+ #include "chrome/browser/ui/cocoa/screentime/screentime_features.h"
|
|
|
#endif
|
|
|
|
|
|
+#include "components/user_scripts/browser/userscripts_browser_client.h"
|
|
@@ -386,7 +386,7 @@ diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
|
|
|
namespace chrome {
|
|
|
|
|
|
void AddProfilesExtraParts(ChromeBrowserMainParts* main_parts) {
|
|
|
-@@ -460,6 +462,7 @@ void ChromeBrowserMainExtraPartsProfiles::
|
|
|
+@@ -472,6 +474,7 @@ void ChromeBrowserMainExtraPartsProfiles::
|
|
|
#endif
|
|
|
WebDataServiceFactory::GetInstance();
|
|
|
webrtc_event_logging::WebRtcEventLogManagerKeyedServiceFactory::GetInstance();
|
|
@@ -397,7 +397,7 @@ diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
|
|
|
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
|
|
|
--- a/chrome/browser/profiles/profile_manager.cc
|
|
|
+++ b/chrome/browser/profiles/profile_manager.cc
|
|
|
-@@ -112,6 +112,8 @@
|
|
|
+@@ -113,6 +113,8 @@
|
|
|
#include "extensions/common/manifest.h"
|
|
|
#endif
|
|
|
|
|
@@ -406,7 +406,7 @@ diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profile
|
|
|
#if BUILDFLAG(ENABLE_SESSION_SERVICE)
|
|
|
#include "chrome/browser/sessions/session_service_factory.h"
|
|
|
#endif
|
|
|
-@@ -1465,6 +1467,13 @@ void ProfileManager::DoFinalInitForServices(Profile* profile,
|
|
|
+@@ -1517,6 +1519,13 @@ void ProfileManager::DoFinalInitForServices(Profile* profile,
|
|
|
}
|
|
|
|
|
|
#endif
|
|
@@ -423,7 +423,7 @@ diff --git a/chrome/browser/profiles/profile_manager.cc 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
|
|
|
-@@ -84,6 +84,7 @@
|
|
|
+@@ -83,6 +83,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"
|
|
@@ -431,7 +431,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"
|
|
|
-@@ -588,6 +589,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
|
|
|
+@@ -606,6 +607,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
|
|
|
return &NewWebUI<UserActionsUI>;
|
|
|
if (url.host_piece() == chrome::kChromeUIVersionHost)
|
|
|
return &NewWebUI<VersionUI>;
|
|
@@ -462,7 +462,7 @@ diff --git a/chrome/chrome_paks.gni b/chrome/chrome_paks.gni
|
|
|
diff --git a/chrome/renderer/BUILD.gn b/chrome/renderer/BUILD.gn
|
|
|
--- a/chrome/renderer/BUILD.gn
|
|
|
+++ b/chrome/renderer/BUILD.gn
|
|
|
-@@ -163,6 +163,7 @@ static_library("renderer") {
|
|
|
+@@ -164,6 +164,7 @@ static_library("renderer") {
|
|
|
"//components/contextual_search/content:renderer",
|
|
|
"//components/data_reduction_proxy/core/common",
|
|
|
"//components/dom_distiller/content/renderer",
|
|
@@ -473,7 +473,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
|
|
|
-@@ -168,6 +168,8 @@
|
|
|
+@@ -169,6 +169,8 @@
|
|
|
#include "chrome/renderer/sandbox_status_extension_android.h"
|
|
|
#include "components/continuous_search/renderer/search_result_extractor_impl.h" // nogncheck
|
|
|
#include "components/embedder_support/android/common/url_constants.h"
|
|
@@ -482,7 +482,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
|
|
|
#else
|
|
|
#include "chrome/renderer/cart/commerce_hint_agent.h"
|
|
|
#include "chrome/renderer/media/chrome_speech_recognition_client.h"
|
|
|
-@@ -363,6 +365,12 @@ void ChromeContentRendererClient::RenderThreadStarted() {
|
|
|
+@@ -368,6 +370,12 @@ void ChromeContentRendererClient::RenderThreadStarted() {
|
|
|
ChromeExtensionsRendererClient::GetInstance()->RenderThreadStarted();
|
|
|
#endif
|
|
|
|
|
@@ -495,7 +495,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
|
|
|
#if BUILDFLAG(ENABLE_SPELLCHECK)
|
|
|
if (!spellcheck_)
|
|
|
InitSpellCheck();
|
|
|
-@@ -493,6 +501,13 @@ void ChromeContentRendererClient::RenderFrameCreated(
|
|
|
+@@ -498,6 +506,13 @@ void ChromeContentRendererClient::RenderFrameCreated(
|
|
|
render_frame, registry);
|
|
|
#endif
|
|
|
|
|
@@ -509,7 +509,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
|
|
|
#if BUILDFLAG(ENABLE_PLUGINS)
|
|
|
new PepperHelper(render_frame);
|
|
|
#endif
|
|
|
-@@ -1455,6 +1470,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentStart(
|
|
|
+@@ -1469,6 +1484,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentStart(
|
|
|
render_frame);
|
|
|
// |render_frame| might be dead by now.
|
|
|
#endif
|
|
@@ -522,7 +522,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
|
|
|
}
|
|
|
|
|
|
void ChromeContentRendererClient::RunScriptsAtDocumentEnd(
|
|
|
-@@ -1464,6 +1485,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentEnd(
|
|
|
+@@ -1478,6 +1499,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentEnd(
|
|
|
render_frame);
|
|
|
// |render_frame| might be dead by now.
|
|
|
#endif
|
|
@@ -535,7 +535,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
|
|
|
}
|
|
|
|
|
|
void ChromeContentRendererClient::RunScriptsAtDocumentIdle(
|
|
|
-@@ -1473,6 +1500,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentIdle(
|
|
|
+@@ -1487,6 +1514,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentIdle(
|
|
|
render_frame);
|
|
|
// |render_frame| might be dead by now.
|
|
|
#endif
|
|
@@ -551,7 +551,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
|
|
|
diff --git a/components/components_strings.grd b/components/components_strings.grd
|
|
|
--- a/components/components_strings.grd
|
|
|
+++ b/components/components_strings.grd
|
|
|
-@@ -327,6 +327,7 @@
|
|
|
+@@ -330,6 +330,7 @@
|
|
|
<part file="undo_strings.grdp" />
|
|
|
<part file="version_ui_strings.grdp" />
|
|
|
<part file="webapps_strings.grdp" />
|
|
@@ -887,7 +887,7 @@ diff --git a/components/user_scripts/android/java/src/org/chromium/chrome/browse
|
|
|
new file mode 100755
|
|
|
--- /dev/null
|
|
|
+++ b/components/user_scripts/android/java/src/org/chromium/chrome/browser/user_scripts/UserScriptsUtils.java
|
|
|
-@@ -0,0 +1,78 @@
|
|
|
+@@ -0,0 +1,79 @@
|
|
|
+/*
|
|
|
+ This file is part of Bromite.
|
|
|
+
|
|
@@ -939,9 +939,10 @@ new file mode 100755
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean openFile(String filePath, String mimeType, String downloadGuid,
|
|
|
-+ boolean isOffTheRecord, String originalUrl, String referrer) {
|
|
|
++ String originalUrl, String referrer) {
|
|
|
+ if (UserScriptsBridge.isUserEnabled() == false) return false;
|
|
|
+
|
|
|
++ // todo: check if is a ContentUriUtils.isContentUri(filePath)
|
|
|
+ if (filePath.toUpperCase().endsWith(".USER.JS") == false) return false;
|
|
|
+
|
|
|
+ Context context = ContextUtils.getApplicationContext();
|
|
@@ -2724,7 +2725,7 @@ new file mode 100755
|
|
|
+bool LoadUserScriptFromFile(
|
|
|
+ const base::FilePath& user_script_path, const GURL& original_url,
|
|
|
+ std::unique_ptr<UserScript>& script,
|
|
|
-+ base::string16* error) {
|
|
|
++ std::u16string* error) {
|
|
|
+
|
|
|
+ std::string script_key = user_script_path.BaseName().value();
|
|
|
+
|
|
@@ -2824,7 +2825,7 @@ new file mode 100755
|
|
|
+ while (full_name = dir_enum.Next(), !full_name.empty()) {
|
|
|
+ std::unique_ptr<UserScript> userscript(new UserScript());
|
|
|
+
|
|
|
-+ base::string16 error;
|
|
|
++ std::u16string error;
|
|
|
+ if (LoadUserScriptFromFile(full_name, GURL(), userscript, &error)) {
|
|
|
+ if (base::FeatureList::IsEnabled(features::kEnableLoggingUserScripts))
|
|
|
+ LOG(INFO) << "UserScriptLoader: Found user script " << userscript->name() <<
|
|
@@ -3078,14 +3079,14 @@ new file mode 100755
|
|
|
+ ui::SelectFileDialog::FileTypeInfo::ANY_PATH;
|
|
|
+ base::FilePath suggested_name;
|
|
|
+
|
|
|
-+ std::vector<base::string16> types;
|
|
|
++ std::vector<std::u16string> types;
|
|
|
+ types.push_back(base::ASCIIToUTF16("*/*")); /*= java SelectFileDialog.ALL_TYPES*/
|
|
|
-+ std::pair<std::vector<base::string16>, bool> accept_types = std::make_pair(
|
|
|
++ std::pair<std::vector<std::u16string>, bool> accept_types = std::make_pair(
|
|
|
+ types, false /*use_media_capture*/);
|
|
|
+
|
|
|
+ dialog_->SelectFile(
|
|
|
+ ui::SelectFileDialog::SELECT_OPEN_FILE,
|
|
|
-+ base::string16() /* dialog title*/, suggested_name, &allowed_file_info,
|
|
|
++ std::u16string() /* dialog title*/, suggested_name, &allowed_file_info,
|
|
|
+ 0 /* file type index */, std::string() /* default file extension */,
|
|
|
+ nativeWindow,
|
|
|
+ &accept_types /* params */);
|
|
@@ -3099,7 +3100,7 @@ new file mode 100755
|
|
|
+ DCHECK(GetUserScriptsFileTaskRunner()->RunsTasksInCurrentSequence());
|
|
|
+
|
|
|
+ std::unique_ptr<UserScript> userscript(new UserScript());
|
|
|
-+ base::string16 error;
|
|
|
++ std::u16string error;
|
|
|
+ bool result = LoadUserScriptFromFile(path, GURL(), userscript, &error);
|
|
|
+
|
|
|
+ if(result) {
|
|
@@ -3135,7 +3136,7 @@ new file mode 100755
|
|
|
+}
|
|
|
+
|
|
|
+void UserScriptLoader::TryToInstall(const base::FilePath& script_path) {
|
|
|
-+ base::string16 file_display_name;
|
|
|
++ std::u16string file_display_name;
|
|
|
+ base::MaybeGetFileDisplayName(script_path, &file_display_name);
|
|
|
+
|
|
|
+ std::string display_name = script_path.BaseName().value();
|
|
@@ -4092,7 +4093,7 @@ diff --git a/components/user_scripts/common/error_utils.h b/components/user_scri
|
|
|
new file mode 100755
|
|
|
--- /dev/null
|
|
|
+++ b/components/user_scripts/common/error_utils.h
|
|
|
-@@ -0,0 +1,25 @@
|
|
|
+@@ -0,0 +1,24 @@
|
|
|
+// Copyright (c) 2011 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.
|
|
@@ -4102,7 +4103,6 @@ new file mode 100755
|
|
|
+
|
|
|
+#include <string>
|
|
|
+
|
|
|
-+#include "base/strings/string16.h"
|
|
|
+#include "base/strings/string_piece.h"
|
|
|
+
|
|
|
+namespace user_scripts {
|
|
@@ -10168,7 +10168,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
|
|
|
-@@ -464,6 +464,12 @@
|
|
|
+@@ -475,6 +475,12 @@
|
|
|
"components/autofill/core/browser/autofill_address_rewriter_resources.grd":{
|
|
|
"includes": [2880]
|
|
|
},
|