change install message + add homepage support + make url clickable

This commit is contained in:
Carmelo Messina 2021-06-24 14:42:35 +02:00
parent 8c16413839
commit e65cfb40ec
3 changed files with 72 additions and 51 deletions

View file

@ -1,6 +1,6 @@
From: uazo <uazo@users.noreply.github.com>
Date: Mon, 17 May 2021 12:30:12 +0000
Subject: add-support-for-ISupportHelpAndFeedback.patch
Date: Tue, 15 Jun 2021 12:37:58 +0000
Subject: add-support-for-ISupportHelpAndFeedback
---
.../chrome/browser/settings/SettingsActivity.java | 10 +++++++---
@ -30,15 +30,17 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/Settin
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
@@ -171,4 +171,8 @@ public class SettingsUtils {
StrictMode.setThreadPolicy(oldPolicy);
@@ -45,6 +45,10 @@ public class SettingsUtils {
}
}
+
+ public interface ISupportHelpAndFeedback {
+ void onHelpAndFeebackPressed();
+ }
}
+
/**
* Returns a view tree observer to show the shadow if and only if the view is scrolled.
* @param view The view whose scroll will be detected to determine the shadow's visibility.
--
2.17.1

View file

@ -1,12 +1,12 @@
From: uazo <uazo@users.noreply.github.com>
Date: Mon, 17 May 2021 12:28:11 +0000
Date: Tue, 15 Jun 2021 12:41:22 +0000
Subject: Add support for prefs addon
---
.../chrome/browser/settings/MainSettings.java | 7 +++
chrome/android/proguard/main.flags | 7 +++
.../browser_ui/settings/SettingsUtils.java | 45 +++++++++++++++++++
3 files changed, 59 insertions(+)
.../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
@ -60,7 +60,7 @@ diff --git a/components/browser_ui/settings/android/java/src/org/chromium/compon
/**
* A helper class for Settings.
*/
@@ -126,4 +132,43 @@ public class SettingsUtils {
@@ -130,4 +136,45 @@ public class SettingsUtils {
ImageView imageButton = (ImageView) button;
return imageButton.getDrawable() == parentMenu.getOverflowIcon();
}
@ -76,7 +76,9 @@ diff --git a/components/browser_ui/settings/android/java/src/org/chromium/compon
+ int resId = 0;
+ try {
+ resId = fields[count].getInt(null);
+ } catch (IllegalAccessException e) {}
+ } catch (IllegalAccessException e) {
+ Log.e("settingsutils", "Error getting resource id", e);
+ }
+
+ if (resId != 0) {
+ try {

View file

@ -1,5 +1,5 @@
From: uazo <uazo@users.noreply.github.com>
Date: Mon, 17 May 2021 13:06:13 +0000
Date: Thu, 24 Jun 2021 12:33:20 +0000
Subject: Experimental user scripts support preview
needs
add-support-for-ISupportHelpAndFeedback.patch
@ -29,7 +29,7 @@ add-support-for-prefs-addon.patch
.../renderer/chrome_render_thread_observer.cc | 3 +
components/components_strings.grd | 1 +
components/user_scripts/android/BUILD.gn | 82 ++
.../java/res/layout/accept_script_item.xml | 141 +++
.../java/res/layout/accept_script_item.xml | 160 ++++
.../java/res/layout/accept_script_list.xml | 10 +
.../java/res/layout/scripts_preference.xml | 40 +
.../android/java/res/values/dimens.xml | 11 +
@ -39,10 +39,10 @@ add-support-for-prefs-addon.patch
.../user_scripts/FragmentWindowAndroid.java | 68 ++
.../user_scripts/IUserScriptsUtils.java | 22 +
.../components/user_scripts/ScriptInfo.java | 37 +
.../user_scripts/ScriptListBaseAdapter.java | 161 ++++
.../user_scripts/ScriptListPreference.java | 179 ++++
.../user_scripts/ScriptListBaseAdapter.java | 163 ++++
.../user_scripts/ScriptListPreference.java | 171 ++++
.../user_scripts/UserScriptsBridge.java | 178 ++++
.../user_scripts/UserScriptsPreferences.java | 140 +++
.../user_scripts/UserScriptsPreferences.java | 139 +++
.../user_scripts/android/java_sources.gni | 18 +
.../android/user_scripts_bridge.cc | 174 ++++
.../android/user_scripts_bridge.h | 31 +
@ -55,11 +55,11 @@ add-support-for-prefs-addon.patch
.../user-script-ui/user-scripts-ui.js | 9 +
.../browser/ui/user_scripts_ui.cc | 148 ++++
.../user_scripts/browser/ui/user_scripts_ui.h | 39 +
.../browser/user_script_loader.cc | 717 ++++++++++++++++
.../browser/user_script_loader.cc | 719 ++++++++++++++++
.../user_scripts/browser/user_script_loader.h | 171 ++++
.../browser/user_script_pref_info.cc | 34 +
.../browser/user_script_pref_info.h | 72 ++
.../user_scripts/browser/user_script_prefs.cc | 275 ++++++
.../user_scripts/browser/user_script_prefs.cc | 276 ++++++
.../user_scripts/browser/user_script_prefs.h | 62 ++
.../browser/userscripts_browser_client.cc | 78 ++
.../browser/userscripts_browser_client.h | 62 ++
@ -114,9 +114,9 @@ add-support-for-prefs-addon.patch
.../renderer/user_scripts_renderer_client.h | 36 +
.../renderer/web_ui_injection_host.cc | 40 +
.../renderer/web_ui_injection_host.h | 28 +
.../strings/userscripts_strings.grdp | 53 ++
.../strings/userscripts_strings.grdp | 55 ++
tools/gritsettings/resource_ids.spec | 6 +
110 files changed, 9424 insertions(+), 2 deletions(-)
110 files changed, 9441 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
@ -257,7 +257,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/Downlo
import java.io.File;
@@ -374,6 +375,12 @@ public class DownloadUtils {
@@ -380,6 +381,12 @@ public class DownloadUtils {
Context context = ContextUtils.getApplicationContext();
DownloadManagerService service = DownloadManagerService.getDownloadManagerService();
@ -313,7 +313,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"
@@ -6455,6 +6456,10 @@ const FeatureEntry kFeatureEntries[] = {
@@ -6479,6 +6480,10 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(features::kUserDataSnapshot)},
#endif
@ -340,7 +340,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
@@ -5149,6 +5149,11 @@ const char kUserDataSnapshotDescription[] =
@@ -5156,6 +5156,11 @@ const char kUserDataSnapshotDescription[] =
"update and restoring them after a version rollback.";
#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
@ -355,7 +355,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
@@ -3014,6 +3014,9 @@ extern const char kUserDataSnapshotName[];
@@ -3017,6 +3017,9 @@ extern const char kUserDataSnapshotName[];
extern const char kUserDataSnapshotDescription[];
#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
@ -758,7 +758,7 @@ diff --git a/components/user_scripts/android/java/res/layout/accept_script_item.
new file mode 100644
--- /dev/null
+++ b/components/user_scripts/android/java/res/layout/accept_script_item.xml
@@ -0,0 +1,141 @@
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 2017 The Chromium Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style license that can be
@ -851,11 +851,30 @@ new file mode 100644
+
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/url"
+ <LinearLayout
+ android:id="@+id/url_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/PreferenceSummary" />
+ android:layout_weight="1"
+ android:layout_gravity="center_vertical" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingEnd="5dp"
+ style="@style/PreferenceSummary"
+ android:text="@string/scripts_item_url"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/url"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:autoLink="web"
+ android:focusable="true"
+ android:linksClickable="true" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
@ -1290,7 +1309,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/ScriptListBaseAdapter.java
@@ -0,0 +1,161 @@
@@ -0,0 +1,163 @@
+/*
+ This file is part of Bromite.
+
@ -1354,6 +1373,7 @@ new file mode 100644
+ private Switch mSwitch;
+ private ChromeImageView mIcon;
+ private LinearLayout mErrorLayout;
+ private LinearLayout mUrlContainer;
+
+ private ListMenuButton mMoreButton;
+
@ -1368,6 +1388,7 @@ new file mode 100644
+ mVersion = view.findViewById(R.id.version);
+ mFile = view.findViewById(R.id.file);
+ mUrl = view.findViewById(R.id.url);
+ mUrlContainer = view.findViewById(R.id.url_container);
+ mError = view.findViewById(R.id.error);
+ mIcon = view.findViewById(R.id.icon);
+ mErrorLayout = view.findViewById(R.id.error_layout);
@ -1394,7 +1415,7 @@ new file mode 100644
+
+ mUrl.setVisibility(View.VISIBLE);
+ if (item.UrlSource == null || item.UrlSource.isEmpty()) {
+ mUrl.setVisibility(View.GONE);
+ mUrlContainer.setVisibility(View.GONE);
+ }
+ mErrorLayout.setVisibility(View.VISIBLE);
+ if (item.ParserError == null || item.ParserError.isEmpty()) {
@ -1456,7 +1477,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/ScriptListPreference.java
@@ -0,0 +1,179 @@
@@ -0,0 +1,171 @@
+/*
+ This file is part of Bromite.
+
@ -1529,8 +1550,6 @@ new file mode 100644
+ ModelList menuItems = new ModelList();
+
+ menuItems.add(buildMenuListItem(R.string.remove, 0, 0, true));
+ menuItems.add(buildMenuListItem(R.string.scripts_open_url, 0, 0, info.UrlSource != null &&
+ info.UrlSource.isEmpty() == false));
+ menuItems.add(buildMenuListItem(R.string.scripts_view_source, 0, 0,
+ info.ParserError == null || info.ParserError.isEmpty()));
+
@ -1540,12 +1559,6 @@ new file mode 100644
+ UserScriptsBridge.RemoveScript(info.Key);
+ } else if (textId == R.string.scripts_view_source) {
+ UserScriptsBridge.getUtils().openSourceFile(info.Key);
+ } else if (textId == R.string.scripts_open_url) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(info.UrlSource));
+ intent.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName());
+ intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
+ intent.setPackage(mContext.getPackageName());
+ mContext.startActivity(intent);
+ }
+ };
+ ((ScriptInfoRowViewHolder) holder)
@ -1825,7 +1838,7 @@ diff --git a/components/user_scripts/android/java/src/org/chromium/components/us
new file mode 100755
--- /dev/null
+++ b/components/user_scripts/android/java/src/org/chromium/components/user_scripts/UserScriptsPreferences.java
@@ -0,0 +1,140 @@
@@ -0,0 +1,139 @@
+/*
+ This file is part of Bromite.
+
@ -1955,8 +1968,7 @@ new file mode 100755
+ };
+
+ Context context = getContext();
+ String message = context.getString(R.string.ask_to_install) + " " +
+ scriptToInstall;
+ String message = context.getString(R.string.ask_to_install, scriptToInstall);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setMessage(message)
@ -2662,7 +2674,7 @@ diff --git a/components/user_scripts/browser/user_script_loader.cc b/components/
new file mode 100755
--- /dev/null
+++ b/components/user_scripts/browser/user_script_loader.cc
@@ -0,0 +1,717 @@
@@ -0,0 +1,719 @@
+/*
+ This file is part of Bromite.
+
@ -2747,6 +2759,7 @@ new file mode 100755
+static const base::StringPiece kRunAtDocumentEndValue("document-end");
+static const base::StringPiece kRunAtDocumentIdleValue("document-idle");
+static const base::StringPiece kUrlSourceDeclaration("// @url");
+static const base::StringPiece kUrlHomePageDeclaration("// @homepage");
+
+// internal use
+static const base::StringPiece kParserError("// @error");
@ -2855,7 +2868,8 @@ new file mode 100755
+ error_message = "Invalid RunAtDeclaration " + value;
+ return false;
+ }
+ } else if (GetDeclarationValue(line, kUrlSourceDeclaration, &value)) {
+ } else if (GetDeclarationValue(line, kUrlSourceDeclaration, &value) ||
+ GetDeclarationValue(line, kUrlHomePageDeclaration, &value)) {
+ script->set_url_source(value);
+ } else if (GetDeclarationValue(line, kParserError, &value)) {
+ script->set_parser_error(value);
@ -3678,7 +3692,7 @@ diff --git a/components/user_scripts/browser/user_script_prefs.cc b/components/u
new file mode 100644
--- /dev/null
+++ b/components/user_scripts/browser/user_script_prefs.cc
@@ -0,0 +1,275 @@
@@ -0,0 +1,276 @@
+/*
+ This file is part of Bromite.
+
@ -3836,6 +3850,7 @@ new file mode 100644
+ scriptInfo->set_description(it->get()->description());
+ scriptInfo->set_version(it->get()->version());
+ scriptInfo->set_file_path(it->get()->file_path());
+ scriptInfo->set_url_source(it->get()->url_source());
+ scriptInfo->set_parser_error(it->get()->parser_error());
+ scriptInfo->force_disabled = (it->get()->force_disabled());
+
@ -10384,7 +10399,7 @@ diff --git a/components/user_scripts/strings/userscripts_strings.grdp b/componen
new file mode 100755
--- /dev/null
+++ b/components/user_scripts/strings/userscripts_strings.grdp
@@ -0,0 +1,53 @@
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<grit-part>
+
@ -10410,7 +10425,7 @@ new file mode 100755
+ Add script
+ </message>
+ <message name="IDS_SCRIPTS_LIST_DESCRIPTION" desc="." formatter_data="android_java">
+ Experimental support for Greasemonkey-style user scripts. Use at your own risk.
+ Experimental support for Greasemonkey-style user scripts.
+ </message>
+
+ <message name="IDS_SCRIPTS_ITEM_VERSION" desc="." formatter_data="android_java">
@ -10419,16 +10434,18 @@ new file mode 100755
+ <message name="IDS_SCRIPTS_ITEM_FILENAME" desc="." formatter_data="android_java">
+ File:
+ </message>
+ <message name="IDS_SCRIPTS_ITEM_URL" desc="." formatter_data="android_java">
+ Url:
+ </message>
+
+ <message name="IDS_SCRIPTS_VIEW_SOURCE" desc=". [CHAR-LIMIT=32]" formatter_data="android_java">
+ View source
+ </message>
+ <message name="IDS_SCRIPTS_OPEN_URL" desc=". [CHAR-LIMIT=32]" formatter_data="android_java">
+ Open Url
+ </message>
+
+ <message name="IDS_ASK_TO_INSTALL" desc=". [CHAR-LIMIT=32]" formatter_data="android_java">
+ Do you want to install
+ Only install user scripts that you have verified are secure, user scripts can steal your credentials and data.
+
+Do you want to install <ph name="FILE">%s</ph>?
+ </message>
+ <message name="IDS_YES" desc=". [CHAR-LIMIT=32]" formatter_data="android_java">
+ Yes