Add a flag to site engagement feature
This commit is contained in:
parent
b7bad88837
commit
a48681f08c
1 changed files with 182 additions and 0 deletions
182
build/patches/Add-flag-to-disable-site-engagement.patch
Normal file
182
build/patches/Add-flag-to-disable-site-engagement.patch
Normal file
|
@ -0,0 +1,182 @@
|
|||
From: uazo <uazo@users.noreply.github.com>
|
||||
Date: Mon, 2 May 2022 11:48:03 +0000
|
||||
Subject: Add a flag to site engagement
|
||||
|
||||
---
|
||||
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
|
||||
@@ -134,6 +134,7 @@
|
||||
#include "components/security_state/core/security_state.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"
|
||||
@@ -8466,6 +8467,11 @@ const FeatureEntry kFeatureEntries[] = {
|
||||
flag_descriptions::kReduceUserAgentMinorVersionDescription, kOsAll,
|
||||
FEATURE_VALUE_TYPE(blink::features::kReduceUserAgentMinorVersion)},
|
||||
|
||||
+ {"site-engagement",
|
||||
+ flag_descriptions::kSiteEngagementName,
|
||||
+ flag_descriptions::kSiteEngagementDescription, kOsAll,
|
||||
+ FEATURE_VALUE_TYPE(site_engagement::features::kSiteEngagement)},
|
||||
+
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
{"enable-variable-refresh-rate",
|
||||
flag_descriptions::kEnableVariableRefreshRateName,
|
||||
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
|
||||
@@ -3019,6 +3019,11 @@ const char kReduceUserAgentMinorVersionDescription[] =
|
||||
"The Chrome version in the User-Agent string will be reported as "
|
||||
"Chrome/<major_version>.0.0.0.";
|
||||
|
||||
+const char kSiteEngagementName[] =
|
||||
+ "Enable site engagement feature";
|
||||
+const char kSiteEngagementDescription[] =
|
||||
+ "Site Engagement Service provides information about how engaged a user is with a origin.";
|
||||
+
|
||||
const char kWebSQLAccessName[] = "Allows access to WebSQL APIs";
|
||||
const char kWebSQLAccessDescription[] =
|
||||
"The WebSQL API is enabled by default, but can be disabled 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
|
||||
@@ -1731,6 +1731,9 @@ extern const char kDurableClientHintsCacheDescription[];
|
||||
extern const char kReduceUserAgentMinorVersionName[];
|
||||
extern const char kReduceUserAgentMinorVersionDescription[];
|
||||
|
||||
+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
|
||||
@@ -17,6 +17,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 "components/variations/variations_associated_data.h"
|
||||
@@ -277,6 +278,10 @@ void SiteEngagementScore::Commit() {
|
||||
if (!UpdateScoreDict(score_dict_.get()))
|
||||
return;
|
||||
|
||||
+ if (!base::FeatureList::IsEnabled(features::kSiteEngagement)) {
|
||||
+ score_dict_.reset();
|
||||
+ return;
|
||||
+ }
|
||||
settings_map_->SetWebsiteSettingDefaultScope(
|
||||
origin_, GURL(), ContentSettingsType::SITE_ENGAGEMENT,
|
||||
base::Value::FromUniquePtrValue(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
|
Loading…
Add table
Reference in a new issue