fix whitespace errors and rebase with 87.0.4280.106
This commit is contained in:
parent
95ed35ee5f
commit
81a7beedae
1 changed files with 47 additions and 47 deletions
|
@ -1,4 +1,4 @@
|
|||
From: root <root@ubuntu.cabponte>
|
||||
From: uazo <uazo@users.noreply.github.com>
|
||||
Date: Wed, 16 Dec 2020 10:09:42 +0000
|
||||
Subject: User scripts (preview)
|
||||
|
||||
|
@ -248,7 +248,7 @@ diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/MainSe
|
|||
}
|
||||
+
|
||||
+ private void createBromitePreferences() {
|
||||
+ SettingsUtils.inflatePrefsAddon(this, "main_preferences_addon_",
|
||||
+ SettingsUtils.inflatePrefsAddon(this, "main_preferences_addon_",
|
||||
+ R.xml.class.getFields());
|
||||
+ }
|
||||
}
|
||||
|
@ -310,10 +310,10 @@ diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
|
|||
]
|
||||
deps += [ "//chrome/android/modules/dev_ui/provider:native" ]
|
||||
}
|
||||
+ deps += [
|
||||
+ deps += [
|
||||
+ "//components/user_scripts/common",
|
||||
+ "//components/user_scripts/browser",
|
||||
+ "//components/user_scripts/android",
|
||||
+ "//components/user_scripts/android",
|
||||
+ ]
|
||||
} else { #!is_android
|
||||
sources += [
|
||||
|
@ -329,21 +329,21 @@ 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"
|
||||
@@ -6231,6 +6232,10 @@ const FeatureEntry kFeatureEntries[] = {
|
||||
@@ -6253,6 +6254,10 @@ const FeatureEntry kFeatureEntries[] = {
|
||||
FEATURE_VALUE_TYPE(features::kUserDataSnapshot)},
|
||||
#endif
|
||||
|
||||
+ {"enable-user-scripts", flag_descriptions::kEnableUserScriptsName,
|
||||
+ flag_descriptions::kEnableUserScriptsDescription, kOsDesktop | kOsAndroid,
|
||||
+ FEATURE_VALUE_TYPE(user_scripts::features::kEnableUserScripts)},
|
||||
+
|
||||
+
|
||||
#if defined(OS_WIN)
|
||||
{"run-video-capture-service-in-browser",
|
||||
flag_descriptions::kRunVideoCaptureServiceInBrowserProcessName,
|
||||
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
|
||||
@@ -4681,6 +4681,11 @@ const char kUserDataSnapshotDescription[] =
|
||||
@@ -4684,6 +4684,11 @@ const char kUserDataSnapshotDescription[] =
|
||||
"update and restoring them after a version rollback.";
|
||||
#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
|
||||
|
||||
|
@ -483,7 +483,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
|
|||
#if BUILDFLAG(ENABLE_PLUGINS)
|
||||
new PepperHelper(render_frame);
|
||||
#endif
|
||||
@@ -1442,6 +1456,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentStart(
|
||||
@@ -1455,6 +1469,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentStart(
|
||||
render_frame);
|
||||
// |render_frame| might be dead by now.
|
||||
#endif
|
||||
|
@ -496,7 +496,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
|
|||
}
|
||||
|
||||
void ChromeContentRendererClient::RunScriptsAtDocumentEnd(
|
||||
@@ -1451,6 +1471,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentEnd(
|
||||
@@ -1464,6 +1484,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentEnd(
|
||||
render_frame);
|
||||
// |render_frame| might be dead by now.
|
||||
#endif
|
||||
|
@ -509,7 +509,7 @@ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer
|
|||
}
|
||||
|
||||
void ChromeContentRendererClient::RunScriptsAtDocumentIdle(
|
||||
@@ -1460,6 +1486,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentIdle(
|
||||
@@ -1473,6 +1499,12 @@ void ChromeContentRendererClient::RunScriptsAtDocumentIdle(
|
||||
render_frame);
|
||||
// |render_frame| might be dead by now.
|
||||
#endif
|
||||
|
@ -543,7 +543,7 @@ diff --git a/components/browser_ui/settings/android/java/src/org/chromium/compon
|
|||
return imageButton.getDrawable() == parentMenu.getOverflowIcon();
|
||||
}
|
||||
+
|
||||
+ public static PreferenceScreen inflatePrefsAddon(PreferenceFragmentCompat preferenceFragment,
|
||||
+ public static PreferenceScreen inflatePrefsAddon(PreferenceFragmentCompat preferenceFragment,
|
||||
+ String name,
|
||||
+ Field[] fields) {
|
||||
+ Resources resources = preferenceFragment.getResources();
|
||||
|
@ -619,7 +619,7 @@ new file mode 100755
|
|||
+}
|
||||
+
|
||||
+android_resources("java_resources") {
|
||||
+ sources = [
|
||||
+ sources = [
|
||||
+ "java/res/xml/main_preferences_addon_userscripts.xml",
|
||||
+ "java/res/xml/userscripts_preferences.xml",
|
||||
+ "java/res/layout/accept_script_item.xml",
|
||||
|
@ -861,7 +861,7 @@ new file mode 100755
|
|||
+++ b/components/user_scripts/android/java/res/xml/main_preferences_addon_userscripts.xml
|
||||
@@ -0,0 +1,29 @@
|
||||
+<?xml version="1.0" encoding="utf-8"?>
|
||||
+<!--
|
||||
+<!--
|
||||
+ This file is part of Bromite.
|
||||
+
|
||||
+ Bromite is free software: you can redistribute it and/or modify
|
||||
|
@ -921,7 +921,7 @@ new file mode 100644
|
|||
+ android:title="@string/scripts_disabled_description"
|
||||
+ app:allowDividerBelow="false"
|
||||
+ app:isPreferenceVisible="false"/>
|
||||
+
|
||||
+
|
||||
+ <org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
+ android:key="enabled_switch"
|
||||
+ android:title="@string/option_userscript_flag"
|
||||
|
@ -1623,7 +1623,7 @@ new file mode 100755
|
|||
+package org.chromium.components.user_scripts;
|
||||
+
|
||||
+import android.app.Activity;
|
||||
+import android.app.AlertDialog;
|
||||
+import android.app.AlertDialog;
|
||||
+import android.content.Context;
|
||||
+import android.content.Intent;
|
||||
+import android.content.DialogInterface;
|
||||
|
@ -1682,7 +1682,7 @@ new file mode 100755
|
|||
+ enabledSwitch.setEnabled(false);
|
||||
+ listPreference.setEnabled(false);
|
||||
+
|
||||
+ TextMessagePreference scripts_disabled_description =
|
||||
+ TextMessagePreference scripts_disabled_description =
|
||||
+ (TextMessagePreference) findPreference(PREF_SCRIPTS_DISABLED_DESCRIPTION);
|
||||
+ scripts_disabled_description.setVisible(true);
|
||||
+ }
|
||||
|
@ -1725,7 +1725,7 @@ new file mode 100755
|
|||
+ case DialogInterface.BUTTON_POSITIVE:
|
||||
+ UserScriptsBridge.TryToInstall(scriptToInstall);
|
||||
+ break;
|
||||
+
|
||||
+
|
||||
+ case DialogInterface.BUTTON_NEGATIVE:
|
||||
+ break;
|
||||
+ }
|
||||
|
@ -1830,7 +1830,7 @@ new file mode 100644
|
|||
+ content::BrowserContext* browser_context) override {
|
||||
+ user_scripts::ShouldRefreshUserScriptList(base::android::AttachCurrentThread());
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ void OnUserScriptLoaded(user_scripts::UserScriptLoader* loader,
|
||||
+ bool result, const std::string& error) override {
|
||||
+ user_scripts::OnUserScriptLoaded(base::android::AttachCurrentThread(),
|
||||
|
@ -1870,7 +1870,7 @@ new file mode 100644
|
|||
+ JNIEnv* env) {
|
||||
+ user_scripts::UserScriptsBrowserClient* client = GetUserScriptsBrowserClient();
|
||||
+ if (client == NULL) return ConvertUTF8ToJavaString(env, {});
|
||||
+
|
||||
+
|
||||
+ std::string json = client->GetPrefs()->GetScriptsInfo();
|
||||
+ return ConvertUTF8ToJavaString(env, json);
|
||||
+}
|
||||
|
@ -1880,7 +1880,7 @@ new file mode 100644
|
|||
+ const JavaParamRef<jstring>& jscript_key) {
|
||||
+ user_scripts::UserScriptsBrowserClient* client = GetUserScriptsBrowserClient();
|
||||
+ if (client == NULL) return;
|
||||
+
|
||||
+
|
||||
+ std::string script_key = base::android::ConvertJavaStringToUTF8(jscript_key);
|
||||
+ client->GetLoader()->RemoveScript(script_key);
|
||||
+}
|
||||
|
@ -1943,7 +1943,7 @@ new file mode 100644
|
|||
+
|
||||
+static void OnUserScriptLoaded(JNIEnv* env,
|
||||
+ bool result, const std::string& error) {
|
||||
+ base::android::ScopedJavaLocalRef<jstring> j_error =
|
||||
+ base::android::ScopedJavaLocalRef<jstring> j_error =
|
||||
+ base::android::ConvertUTF8ToJavaString(env, error);
|
||||
+
|
||||
+ Java_UserScriptsBridge_onUserScriptLoaded(env, result, j_error);
|
||||
|
@ -1986,7 +1986,7 @@ new file mode 100644
|
|||
+
|
||||
+} // namespace user_scripts
|
||||
+
|
||||
+#endif
|
||||
+#endif
|
||||
\ No newline at end of file
|
||||
diff --git a/components/user_scripts/browser/BUILD.gn b/components/user_scripts/browser/BUILD.gn
|
||||
new file mode 100755
|
||||
|
@ -2218,14 +2218,14 @@ new file mode 100755
|
|||
+
|
||||
+namespace {
|
||||
+
|
||||
+bool invalidChar(char c)
|
||||
+{
|
||||
+ return !(c>=0 && c <128);
|
||||
+bool invalidChar(char c)
|
||||
+{
|
||||
+ return !(c>=0 && c <128);
|
||||
+}
|
||||
+
|
||||
+void stripUnicode(std::string& str)
|
||||
+{
|
||||
+ str.erase(remove_if(str.begin(),str.end(), invalidChar), str.end());
|
||||
+void stripUnicode(std::string& str)
|
||||
+{
|
||||
+ str.erase(remove_if(str.begin(),str.end(), invalidChar), str.end());
|
||||
+}
|
||||
+
|
||||
+// Helper function to parse greasesmonkey headers
|
||||
|
@ -2420,7 +2420,7 @@ new file mode 100755
|
|||
+ LOG(INFO) << "Path " << path << " doesn't exists. Creating";
|
||||
+ base::File::Error error = base::File::FILE_OK;
|
||||
+ if( !base::CreateDirectoryAndGetError(path, &error) ) {
|
||||
+ LOG(INFO) <<
|
||||
+ LOG(INFO) <<
|
||||
+ "ERROR: failed to create directory: " << path
|
||||
+ << " with error code " << error;
|
||||
+ return false;
|
||||
|
@ -2446,7 +2446,7 @@ new file mode 100755
|
|||
+
|
||||
+ base::string16 error;
|
||||
+ if (LoadUserScriptFromFile(full_name, GURL(), userscript, &error)) {
|
||||
+ LOG(INFO) << "Found user script " << userscript->name() <<
|
||||
+ LOG(INFO) << "Found user script " << userscript->name() <<
|
||||
+ "-" << userscript->version() <<
|
||||
+ "-" << userscript->description();
|
||||
+ user_scripts->push_back(std::move(userscript));
|
||||
|
@ -2649,7 +2649,7 @@ new file mode 100755
|
|||
+ if (GetOrCreatePath(path)) {
|
||||
+ base::FilePath file = path.Append(script_id);
|
||||
+ if( base::DeleteFile(file) == false ) {
|
||||
+ LOG(INFO) <<
|
||||
+ LOG(INFO) <<
|
||||
+ "ERROR: failed to delete file : " << path;
|
||||
+ }
|
||||
+ }
|
||||
|
@ -2700,7 +2700,7 @@ new file mode 100755
|
|||
+ ui::SelectFileDialog::SELECT_OPEN_FILE,
|
||||
+ base::string16() /* dialog title*/, suggested_name, &allowed_file_info,
|
||||
+ 0 /* file type index */, std::string() /* default file extension */,
|
||||
+ nativeWindow,
|
||||
+ nativeWindow,
|
||||
+ &accept_types /* params */);
|
||||
+}
|
||||
+
|
||||
|
@ -2714,13 +2714,13 @@ new file mode 100755
|
|||
+ std::unique_ptr<UserScript> userscript(new UserScript());
|
||||
+ base::string16 error;
|
||||
+ bool result = LoadUserScriptFromFile(path, GURL(), userscript, &error);
|
||||
+
|
||||
+
|
||||
+ if(result) {
|
||||
+ if (display_name.empty() == false) {
|
||||
+ userscript->set_key(display_name);
|
||||
+ }
|
||||
+
|
||||
+ LOG(INFO) << "User Script Loaded " << userscript->name() <<
|
||||
+ LOG(INFO) << "User Script Loaded " << userscript->name() <<
|
||||
+ "-" << userscript->version() <<
|
||||
+ "-" << userscript->description();
|
||||
+ base::FilePath destination;
|
||||
|
@ -2755,10 +2755,10 @@ new file mode 100755
|
|||
+ GetUserScriptsFileTaskRunner()->PostTask(
|
||||
+ FROM_HERE,
|
||||
+ base::BindOnce(
|
||||
+ &LoadScriptFromPathOnFileTaskRunner,
|
||||
+ &LoadScriptFromPathOnFileTaskRunner,
|
||||
+ script_path, display_name,
|
||||
+ base::BindOnce(
|
||||
+ &UserScriptLoader::LoadScriptFromPathOnFileTaskRunnerCallback,
|
||||
+ &UserScriptLoader::LoadScriptFromPathOnFileTaskRunnerCallback,
|
||||
+ weak_factory_.GetWeakPtr()
|
||||
+ )
|
||||
+ ));
|
||||
|
@ -2898,7 +2898,7 @@ new file mode 100755
|
|||
+
|
||||
+ void RemoveScript(const std::string& script_id);
|
||||
+ void SetScriptEnabled(const std::string& script_id, bool is_enabled);
|
||||
+
|
||||
+
|
||||
+ void SelectAndAddScriptFromFile(ui::WindowAndroid* wa);
|
||||
+ void TryToInstall(const base::FilePath& script_path);
|
||||
+
|
||||
|
@ -3203,7 +3203,7 @@ new file mode 100644
|
|||
+
|
||||
+ std::unique_ptr<UserScriptsListPrefs::ScriptInfo> scriptInfo =
|
||||
+ UserScriptsPrefs::CreateScriptInfoFromPrefs(key);
|
||||
+
|
||||
+
|
||||
+ // add or update prefs
|
||||
+ scriptInfo->set_name(it->get()->name());
|
||||
+ scriptInfo->set_description(it->get()->description());
|
||||
|
@ -3213,7 +3213,7 @@ new file mode 100644
|
|||
+
|
||||
+ PrefUpdate update(prefs_, key, kUserScriptsList);
|
||||
+ base::DictionaryValue* script_dict = update.Get();
|
||||
+
|
||||
+
|
||||
+ script_dict->SetString(kScriptName, scriptInfo->name());
|
||||
+ script_dict->SetString(kScriptDescription, scriptInfo->description());
|
||||
+ script_dict->SetBoolean(kScriptIsEnabled, scriptInfo->enabled);
|
||||
|
@ -3234,7 +3234,7 @@ new file mode 100644
|
|||
+
|
||||
+ // remove script from prefs if no more present
|
||||
+ std::vector<std::string> all_scripts_to_remove;
|
||||
+ const base::DictionaryValue* dict =
|
||||
+ const base::DictionaryValue* dict =
|
||||
+ prefs_->GetDictionary(kUserScriptsList);
|
||||
+ for (base::DictionaryValue::Iterator script_it(*dict); !script_it.IsAtEnd();
|
||||
+ script_it.Advance()) {
|
||||
|
@ -3257,7 +3257,7 @@ new file mode 100644
|
|||
+std::string UserScriptsPrefs::GetScriptsInfo() {
|
||||
+ std::string json_string;
|
||||
+
|
||||
+ const base::DictionaryValue* dict =
|
||||
+ const base::DictionaryValue* dict =
|
||||
+ prefs_->GetDictionary(kUserScriptsList);
|
||||
+
|
||||
+ if (dict) {
|
||||
|
@ -3360,7 +3360,7 @@ new file mode 100644
|
|||
+ void SetEnabled(bool enabled);
|
||||
+
|
||||
+ void CompareWithPrefs(UserScriptList& user_scripts);
|
||||
+
|
||||
+
|
||||
+ std::string GetScriptsInfo();
|
||||
+ void RemoveScriptFromPrefs(const std::string& script_id);
|
||||
+ void SetScriptEnabled(const std::string& script_id, bool is_enabled);
|
||||
|
@ -3450,12 +3450,12 @@ new file mode 100755
|
|||
+void UserScriptsBrowserClient::SetProfile(content::BrowserContext* context) {
|
||||
+ browser_context_ = context;
|
||||
+
|
||||
+ prefs_ =
|
||||
+ prefs_ =
|
||||
+ std::make_unique<user_scripts::UserScriptsPrefs>(
|
||||
+ static_cast<Profile*>(context)->GetPrefs());
|
||||
+ static_cast<Profile*>(context)->GetPrefs());
|
||||
+
|
||||
+ userscript_loader_ =
|
||||
+ std::make_unique<user_scripts::UserScriptLoader>(browser_context_, prefs_.get());
|
||||
+ userscript_loader_ =
|
||||
+ std::make_unique<user_scripts::UserScriptLoader>(browser_context_, prefs_.get());
|
||||
+ userscript_loader_->SetReady(true);
|
||||
+}
|
||||
+
|
||||
|
@ -6055,7 +6055,7 @@ new file mode 100755
|
|||
+ void set_content(const base::StringPiece& content) {
|
||||
+ content_.assign(content.begin(), content.end());
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ const std::string& key() const { return key_; }
|
||||
+ void set_key(const std::string& key) {
|
||||
+ key_ = key;
|
||||
|
|
Loading…
Add table
Reference in a new issue