LeOSium_webview/LeOS/patches/Add-site-engagement-flag.patch

187 lines
7.3 KiB
Diff
Raw Permalink Normal View History

2023-11-18 11:46:19 +01:00
From: uazo <uazo@users.noreply.github.com>
Date: Mon, 2 May 2022 11:48:03 +0000
Subject: Add site engagement flag
Disabled by default.
Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
chrome/browser/about_flags.cc | 6 ++++
chrome/browser/flag_descriptions.cc | 5 +++
chrome/browser/flag_descriptions.h | 3 ++
.../content/site_engagement_score.cc | 5 +++
components/site_engagement/core/BUILD.gn | 6 ++++
components/site_engagement/core/features.cc | 29 ++++++++++++++++
components/site_engagement/core/features.h | 34 +++++++++++++++++++
7 files changed, 88 insertions(+)
create mode 100644 components/site_engagement/core/features.cc
create mode 100644 components/site_engagement/core/features.h
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -148,6 +148,7 @@
#include "components/segmentation_platform/public/features.h"
#include "components/send_tab_to_self/features.h"
#include "components/services/heap_profiling/public/cpp/switches.h"
+#include "components/site_engagement/core/features.h"
#include "components/shared_highlighting/core/common/shared_highlighting_features.h"
#include "components/signin/core/browser/dice_account_reconcilor_delegate.h"
#include "components/signin/public/base/signin_buildflags.h"
@@ -9915,6 +9916,11 @@ const FeatureEntry kFeatureEntries[] = {
kLargeFaviconFromGoogleVariations,
"LargeFaviconFromGoogle")},
+ {"site-engagement",
+ flag_descriptions::kSiteEngagementName,
+ flag_descriptions::kSiteEngagementDescription, kOsAll,
+ FEATURE_VALUE_TYPE(site_engagement::features::kSiteEngagement)},
+
#if BUILDFLAG(IS_ANDROID)
{"force-off-text-autosizing",
flag_descriptions::kForceOffTextAutosizingName,
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
@@ -3820,6 +3820,11 @@ const char kSkipServiceWorkerFetchHandlerDescription[] =
"Skips starting the service worker and run the fetch handler if the fetch "
"handler is recognized as skippable.";
+const char kSiteEngagementName[] =
+ "Enable site engagement feature";
+const char kSiteEngagementDescription[] =
+ "Site Engagement Service provides information about how engaged a user is with a origin; this affects which NTP tiles are automatically created.";
+
const char kWebSQLAccessName[] = "Allows access to WebSQL APIs";
const char kWebSQLAccessDescription[] =
"The WebSQL API is disabled by default, but can be enabled here.";
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
@@ -2234,6 +2234,9 @@ extern const char kReduceAcceptLanguageDescription[];
extern const char kSkipServiceWorkerFetchHandlerName[];
extern const char kSkipServiceWorkerFetchHandlerDescription[];
+extern const char kSiteEngagementName[];
+extern const char kSiteEngagementDescription[];
+
extern const char kWebSQLAccessName[];
extern const char kWebSQLAccessDescription[];
diff --git a/components/site_engagement/content/site_engagement_score.cc b/components/site_engagement/content/site_engagement_score.cc
--- a/components/site_engagement/content/site_engagement_score.cc
+++ b/components/site_engagement/content/site_engagement_score.cc
@@ -18,6 +18,7 @@
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings_utils.h"
+#include "components/site_engagement/core/features.h"
#include "components/site_engagement/content/engagement_type.h"
#include "components/site_engagement/content/site_engagement_metrics.h"
#include "third_party/blink/public/mojom/site_engagement/site_engagement.mojom.h"
@@ -275,6 +276,10 @@ void SiteEngagementScore::Commit() {
if (!UpdateScoreDict(*score_dict_))
return;
+ if (!base::FeatureList::IsEnabled(features::kSiteEngagement)) {
+ score_dict_.reset();
+ return;
+ }
settings_map_->SetWebsiteSettingDefaultScope(
origin_, GURL(), ContentSettingsType::SITE_ENGAGEMENT,
base::Value(std::move(*score_dict_)));
diff --git a/components/site_engagement/core/BUILD.gn b/components/site_engagement/core/BUILD.gn
--- a/components/site_engagement/core/BUILD.gn
+++ b/components/site_engagement/core/BUILD.gn
@@ -4,8 +4,14 @@
static_library("core") {
sources = [
+ "features.cc",
+ "features.h",
"pref_names.cc",
"pref_names.h",
"site_engagement_score_provider.h",
]
+
+ deps = [
+ "//base",
+ ]
}
diff --git a/components/site_engagement/core/features.cc b/components/site_engagement/core/features.cc
new file mode 100644
--- /dev/null
+++ b/components/site_engagement/core/features.cc
@@ -0,0 +1,29 @@
+/*
+ This file is part of Bromite.
+
+ Bromite is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bromite is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bromite. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+#include "components/site_engagement/core/features.h"
+
+#include "base/feature_list.h"
+
+namespace site_engagement {
+namespace features {
+
+const base::Feature kSiteEngagement{"SiteEngagement",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
+} // namespace features
+} // namespace site_engagement
diff --git a/components/site_engagement/core/features.h b/components/site_engagement/core/features.h
new file mode 100644
--- /dev/null
+++ b/components/site_engagement/core/features.h
@@ -0,0 +1,34 @@
+/*
+ This file is part of Bromite.
+
+ Bromite is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bromite is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bromite. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+#ifndef SITE_ENGAGEMENT_CORE_FEATURES_H_
+#define SITE_ENGAGEMENT_CORE_FEATURES_H_
+
+#include <string>
+
+#include "base/feature_list.h"
+
+namespace site_engagement {
+namespace features {
+
+// Enable site engagement
+extern const base::Feature kSiteEngagement;
+
+} // namespace features
+} // namespace site_engagement
+
+#endif // SITE_ENGAGEMENT_CORE_FEATURES_H_
--
2.25.1