Cleaned up dont-track-me patch
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
commit 431f63c24d7ab7bf5aeb4594b1b2f4ebc5c6fef9
|
||||
commit 81b64b60677c8b13c41647600a63e9c2a0563f67
|
||||
Author: csagan5 <32685696+csagan5@users.noreply.github.com>
|
||||
Date: Thu Oct 26 13:39:30 2017 +0200
|
||||
|
||||
@@ -17,7 +17,7 @@ index 93f080f..2df8d30 100644
|
||||
"trustedtypes/TrustedHTML.h",
|
||||
"trustedtypes/TrustedScriptURL.cpp",
|
||||
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
|
||||
index b7c5748..54e3c7a 100644
|
||||
index b7c5748..4978c84 100644
|
||||
--- a/third_party/WebKit/Source/core/dom/Document.cpp
|
||||
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
|
||||
@@ -218,6 +218,7 @@
|
||||
@@ -28,7 +28,7 @@ index b7c5748..54e3c7a 100644
|
||||
#include "platform/CrossThreadFunctional.h"
|
||||
#include "platform/DateComponents.h"
|
||||
#include "platform/EventDispatchForbiddenScope.h"
|
||||
@@ -5825,8 +5826,29 @@ void Document::FinishedParsing() {
|
||||
@@ -5825,8 +5826,24 @@ void Document::FinishedParsing() {
|
||||
fetcher_->ClearResourcesFromPreviousFetcher();
|
||||
}
|
||||
|
||||
@@ -43,35 +43,17 @@ index b7c5748..54e3c7a 100644
|
||||
+ if (origin) {
|
||||
+ WTF::String domain = origin->Domain();
|
||||
+ size_t pos = domain.Find(".google.");
|
||||
+ IsGoogle = (pos != WTF::kNotFound) && (domain.length() - pos - 8 < 4);
|
||||
+ LOG(INFO) << "BRM: is this is a google page " << domain << " " << IsGoogle;
|
||||
+ }
|
||||
+
|
||||
+ auto* bodyElement = body();
|
||||
+ if (IsGoogle && bodyElement) {
|
||||
+ LOG(INFO) << "BRM: appending google page payload in head";
|
||||
+ HTMLScriptElement* e = HTMLScriptElement::Create(*this, false);
|
||||
+ e->setText(DONT_TRACK_ME_JS);
|
||||
+ bodyElement->AppendChild(e);
|
||||
+ } else {
|
||||
+ LOG(INFO) << "BRM: ignoring page";
|
||||
+ auto* bodyElement = body();
|
||||
+ if (bodyElement && (pos != WTF::kNotFound) && (domain.length() - pos - 8 < 4)) {
|
||||
+ LOG(INFO) << "BRM: injecting dont-track-me Javascript payload";
|
||||
+ HTMLScriptElement* e = HTMLScriptElement::Create(*this, false);
|
||||
+ e->setText(DONT_TRACK_ME_JS);
|
||||
+ bodyElement->AppendChild(e);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
void Document::ElementDataCacheClearTimerFired(TimerBase*) {
|
||||
diff --git a/third_party/WebKit/Source/core/dom/Document.h b/third_party/WebKit/Source/core/dom/Document.h
|
||||
index f2f8fc2..755826f 100644
|
||||
--- a/third_party/WebKit/Source/core/dom/Document.h
|
||||
+++ b/third_party/WebKit/Source/core/dom/Document.h
|
||||
@@ -1392,6 +1392,8 @@ class CORE_EXPORT Document : public ContainerNode,
|
||||
ukm::UkmRecorder* UkmRecorder();
|
||||
int64_t UkmSourceID() const;
|
||||
|
||||
+ bool IsGoogle;
|
||||
+
|
||||
protected:
|
||||
Document(const DocumentInit&, DocumentClassFlags = kDefaultDocumentClass);
|
||||
|
||||
diff --git a/third_party/WebKit/Source/core/dom/extensions/dont-track-me.h b/third_party/WebKit/Source/core/dom/extensions/dont-track-me.h
|
||||
new file mode 100644
|
||||
index 0000000..11abff3
|
||||
|
||||
Reference in New Issue
Block a user