Merge pull request #830 from uazo/fix-828

Add random seed to TimezoneOverride patch
This commit is contained in:
Carl 2020-12-07 00:50:49 +01:00 committed by GitHub
commit 42ffe7b18a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,10 +39,10 @@ See also: https://github.com/bromite/bromite/wiki/TimezoneOverride
.../core/common/content_settings_types.h | 3 +
.../core/common/pref_names.cc | 3 +
.../content_settings/core/common/pref_names.h | 2 +
.../renderer/content_settings_agent_impl.cc | 88 ++++++++
.../renderer/content_settings_agent_impl.cc | 89 ++++++++
.../renderer/content_settings_agent_impl.h | 4 +
.../WebLayerSiteSettingsClient.java | 3 +
36 files changed, 713 insertions(+), 10 deletions(-)
36 files changed, 714 insertions(+), 10 deletions(-)
create mode 100755 components/browser_ui/site_settings/android/java/res/layout/time_zone_select_dialog.xml
create mode 100755 components/browser_ui/site_settings/android/java/res/layout/timezoneoverride_site_settings_preference.xml
create mode 100755 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/TimezoneOverrideSiteSettingsPreference.java
@ -1142,7 +1142,7 @@ diff --git a/components/content_settings/core/common/content_settings_mojom_trai
data.ReadPopupRedirectRules(&out->popup_redirect_rules) &&
- data.ReadMixedContentRules(&out->mixed_content_rules);
+ data.ReadMixedContentRules(&out->mixed_content_rules) &&
+ data.ReadTimezoneOverrideRules(&out->timezone_override_rules) &&
+ data.ReadTimezoneOverrideRules(&out->timezone_override_rules) &&
+ data.ReadTimezoneOverrideValue(&out->timezone_override_value);
}
@ -1206,15 +1206,18 @@ diff --git a/components/content_settings/core/common/pref_names.h b/components/c
diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc b/components/content_settings/renderer/content_settings_agent_impl.cc
--- a/components/content_settings/renderer/content_settings_agent_impl.cc
+++ b/components/content_settings/renderer/content_settings_agent_impl.cc
@@ -9,6 +9,7 @@
@@ -9,8 +9,10 @@
#include "base/bind.h"
#include "base/feature_list.h"
+#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
+#include "base/rand_util.h"
#include "components/content_settings/core/common/content_settings.h"
@@ -32,6 +33,10 @@
#include "components/content_settings/core/common/content_settings.mojom.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
@@ -32,6 +34,10 @@
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_view.h"
@ -1225,7 +1228,7 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc
#include "url/gurl.h"
#include "url/origin.h"
#include "url/url_constants.h"
@@ -45,6 +50,8 @@ using blink::WebURL;
@@ -45,6 +51,8 @@ using blink::WebURL;
using blink::WebView;
using content::DocumentState;
@ -1234,7 +1237,7 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc
namespace content_settings {
namespace {
@@ -377,6 +384,10 @@ bool ContentSettingsAgentImpl::AllowScript(bool enabled_per_settings) {
@@ -377,6 +385,10 @@ bool ContentSettingsAgentImpl::AllowScript(bool enabled_per_settings) {
allow = allow || IsWhitelistedForContentSettings();
cached_script_permissions_[frame] = allow;
@ -1245,7 +1248,7 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc
return allow;
}
@@ -509,4 +520,81 @@ bool ContentSettingsAgentImpl::IsWhitelistedForContentSettings() const {
@@ -509,4 +521,81 @@ bool ContentSettingsAgentImpl::IsWhitelistedForContentSettings() const {
return false;
}
@ -1287,7 +1290,7 @@ diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc
+ } else if (setting == CONTENT_SETTING_BLOCK) {
+ // timezone random
+ UErrorCode ec = U_ZERO_ERROR;
+ int32_t rawOffset = ((rand() % 24) - 12) * 3600 * 1000;
+ int32_t rawOffset = base::RandInt(-12, 11) * 3600 * 1000;
+ icu::StringEnumeration* timezones = icu::TimeZone::createEnumeration(
+ rawOffset); // Obtain timezones by GMT timezone offset
+ if (timezones) {