diff --git a/chromium_src/chrome/browser/profiles/renderer_updater.cc b/chromium_src/chrome/browser/profiles/renderer_updater.cc new file mode 100644 index 00000000000..2e926435b46 --- /dev/null +++ b/chromium_src/chrome/browser/profiles/renderer_updater.cc @@ -0,0 +1,28 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_RENDERER_UPDATER_H_ +#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_RENDERER_UPDATER_H_ + +#define BRAVE_GET_GUEST_VIEW_DEFAULT_CONTENT_SETTING_RULES \ + rules->fingerprinting_rules.push_back(ContentSettingPatternSource( \ + ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), \ + base::Value::FromUniquePtrValue( \ + content_settings::ContentSettingToValue(CONTENT_SETTING_ALLOW)), \ + std::string(), incognito)); \ + rules->farbling_rules.push_back(ContentSettingPatternSource( \ + ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), \ + base::Value::FromUniquePtrValue( \ + content_settings::ContentSettingToValue(CONTENT_SETTING_DEFAULT)), \ + std::string(), incognito)); \ + rules->brave_shields_rules.push_back(ContentSettingPatternSource( \ + ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), \ + base::Value::FromUniquePtrValue( \ + content_settings::ContentSettingToValue(CONTENT_SETTING_ALLOW)), \ + std::string(), incognito)); + +#include "../../../../../chrome/browser/profiles/renderer_updater.cc" + +#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_PROFILES_RENDERER_UPDATER_H_ diff --git a/chromium_src/third_party/blink/public/platform/web_content_settings_client.h b/chromium_src/third_party/blink/public/platform/web_content_settings_client.h index 9a80b32cf32..506ca7c9e11 100644 --- a/chromium_src/third_party/blink/public/platform/web_content_settings_client.h +++ b/chromium_src/third_party/blink/public/platform/web_content_settings_client.h @@ -6,7 +6,7 @@ #ifndef BRAVE_CHROMIUM_SRC_THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_CONTENT_SETTINGS_CLIENT_H_ #define BRAVE_CHROMIUM_SRC_THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_CONTENT_SETTINGS_CLIENT_H_ -#include "brave/common/brave_farbling_constants.h" +#include "brave/third_party/blink/renderer/brave_farbling_constants.h" #define BRAVE_WEB_CONTENT_SETTINGS_CLIENT_H \ virtual bool AllowAutoplay(bool default_value) { return default_value; } \ diff --git a/chromium_src/third_party/blink/renderer/core/dom/document.cc b/chromium_src/third_party/blink/renderer/core/dom/document.cc index 7c79e680ace..b72375027e4 100644 --- a/chromium_src/third_party/blink/renderer/core/dom/document.cc +++ b/chromium_src/third_party/blink/renderer/core/dom/document.cc @@ -6,9 +6,10 @@ #include "third_party/blink/renderer/core/dom/document.h" #include "base/strings/string_number_conversions.h" -#include "brave/renderer/brave_content_settings_agent_impl_farbling_helper.h" +#include "brave/third_party/blink/renderer/brave_farbling_constants.h" #include "crypto/hmac.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" +#include "third_party/blink/public/platform/web_content_settings_client.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/frame/local_frame.h" @@ -60,9 +61,10 @@ double BraveSessionCache::GetFudgeFactor() { scoped_refptr BraveSessionCache::PerturbPixels( blink::LocalFrame* frame, scoped_refptr image_bitmap) { - if (!frame) + if (!frame || !frame->GetContentSettingsClient()) { return image_bitmap; - switch (GetBraveFarblingLevel(frame)) { + } + switch (frame->GetContentSettingsClient()->GetBraveFarblingLevel()) { case BraveFarblingLevel::OFF: break; case BraveFarblingLevel::BALANCED: { diff --git a/common/BUILD.gn b/common/BUILD.gn index 4360587d735..724893bf048 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -53,7 +53,6 @@ source_set("common") { "brave_content_client.h", "brave_features.cc", "brave_features.h", - "brave_farbling_constants.h", "brave_isolated_worlds.h", "brave_paths.cc", "brave_paths.h", diff --git a/patches/chrome-browser-profiles-renderer_updater.cc.patch b/patches/chrome-browser-profiles-renderer_updater.cc.patch index 9b16d3c2f72..449e05fe913 100644 --- a/patches/chrome-browser-profiles-renderer_updater.cc.patch +++ b/patches/chrome-browser-profiles-renderer_updater.cc.patch @@ -1,26 +1,12 @@ diff --git a/chrome/browser/profiles/renderer_updater.cc b/chrome/browser/profiles/renderer_updater.cc -index ce50c9ee3f9290b50b4a5704e8eec9dc91db3082..f25cc28043eae41f88f8dc273e98ba6181fc589c 100644 +index ce50c9ee3f9290b50b4a5704e8eec9dc91db3082..5f39cd1420b433ca5321b18dfc6a3cdc5d2c8128 100644 --- a/chrome/browser/profiles/renderer_updater.cc +++ b/chrome/browser/profiles/renderer_updater.cc -@@ -55,6 +55,21 @@ void GetGuestViewDefaultContentSettingRules( +@@ -55,6 +55,7 @@ void GetGuestViewDefaultContentSettingRules( base::Value::FromUniquePtrValue( content_settings::ContentSettingToValue(CONTENT_SETTING_BLOCK)), std::string(), incognito)); -+ rules->fingerprinting_rules.push_back(ContentSettingPatternSource( -+ ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), -+ base::Value::FromUniquePtrValue( -+ content_settings::ContentSettingToValue(CONTENT_SETTING_ALLOW)), -+ std::string(), incognito)); -+ rules->farbling_rules.push_back(ContentSettingPatternSource( -+ ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), -+ base::Value::FromUniquePtrValue( -+ content_settings::ContentSettingToValue(CONTENT_SETTING_DEFAULT)), -+ std::string(), incognito)); -+ rules->brave_shields_rules.push_back(ContentSettingPatternSource( -+ ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), -+ base::Value::FromUniquePtrValue( -+ content_settings::ContentSettingToValue(CONTENT_SETTING_ALLOW)), -+ std::string(), incognito)); ++ BRAVE_GET_GUEST_VIEW_DEFAULT_CONTENT_SETTING_RULES } #endif // BUILDFLAG(ENABLE_EXTENSIONS) diff --git a/renderer/brave_content_settings_agent_impl.h b/renderer/brave_content_settings_agent_impl.h index 4b3ced610b9..4c6af4556a2 100644 --- a/renderer/brave_content_settings_agent_impl.h +++ b/renderer/brave_content_settings_agent_impl.h @@ -10,7 +10,7 @@ #include #include "base/strings/string16.h" -#include "brave/common/brave_farbling_constants.h" +#include "brave/third_party/blink/renderer/brave_farbling_constants.h" #include "chrome/renderer/content_settings_agent_impl.h" #include "components/content_settings/core/common/content_settings.h" #include "components/content_settings/core/common/content_settings_types.h" diff --git a/renderer/brave_content_settings_agent_impl_farbling_helper.h b/renderer/brave_content_settings_agent_impl_farbling_helper.h deleted file mode 100644 index dfaa3a33f44..00000000000 --- a/renderer/brave_content_settings_agent_impl_farbling_helper.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2019 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef BRAVE_RENDERER_BRAVE_CONTENT_SETTINGS_AGENT_IMPL_FARBLING_HELPER_H_ -#define BRAVE_RENDERER_BRAVE_CONTENT_SETTINGS_AGENT_IMPL_FARBLING_HELPER_H_ - -#include "brave/common/brave_farbling_constants.h" -#include "third_party/blink/renderer/core/dom/document.h" -#include "third_party/blink/public/platform/web_content_settings_client.h" -#include "third_party/blink/renderer/core/frame/local_dom_window.h" -#include "third_party/blink/renderer/core/frame/local_frame.h" -#include "third_party/blink/renderer/platform/bindings/script_state.h" - -static BraveFarblingLevel GetBraveFarblingLevel(blink::LocalFrame* frame) { - if (!frame || !frame->GetContentSettingsClient()) { - return BraveFarblingLevel::OFF; - } - - return frame->GetContentSettingsClient()->GetBraveFarblingLevel(); -} - -#endif // BRAVE_RENDERER_BRAVE_CONTENT_SETTINGS_AGENT_IMPL_FARBLING_HELPER_H_ diff --git a/third_party/blink/renderer/BUILD.gn b/third_party/blink/renderer/BUILD.gn index fa663f9c3c5..41aac3e9858 100644 --- a/third_party/blink/renderer/BUILD.gn +++ b/third_party/blink/renderer/BUILD.gn @@ -4,8 +4,11 @@ # You can obtain one at http://mozilla.org/MPL/2.0/. source_set("renderer") { + sources = [ + "brave_farbling_constants.h", + ] + deps = [ "//brave/components/brave_drm:brave_drm_blink", ] } - diff --git a/common/brave_farbling_constants.h b/third_party/blink/renderer/brave_farbling_constants.h similarity index 61% rename from common/brave_farbling_constants.h rename to third_party/blink/renderer/brave_farbling_constants.h index 98045e0b448..2452b788a23 100644 --- a/common/brave_farbling_constants.h +++ b/third_party/blink/renderer/brave_farbling_constants.h @@ -3,8 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef BRAVE_COMMON_BRAVE_FARBLING_CONSTANTS_H_ -#define BRAVE_COMMON_BRAVE_FARBLING_CONSTANTS_H_ +#ifndef BRAVE_THIRD_PARTY_BLINK_RENDERER_BRAVE_FARBLING_CONSTANTS_H_ +#define BRAVE_THIRD_PARTY_BLINK_RENDERER_BRAVE_FARBLING_CONSTANTS_H_ enum BraveFarblingLevel { BALANCED = 0, @@ -12,4 +12,4 @@ enum BraveFarblingLevel { MAXIMUM }; -#endif // BRAVE_COMMON_BRAVE_FARBLING_CONSTANTS_H_ +#endif // BRAVE_THIRD_PARTY_BLINK_RENDERER_BRAVE_FARBLING_CONSTANTS_H_