-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Parse the FirstPartyTracker list provided by the `tracking-protection` extension. 2. On any request to Store data (Cookies, localStorage, sessionStorage, WebSQL, indexedDB) check if the requesting URL is in the tracker list. 3. Deny if the URL is found in the tracker list auditors: @bridiver
- Loading branch information
Showing
9 changed files
with
238 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* 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/. */ | ||
|
||
#include "brave/browser/renderer_host/brave_render_message_filter.h" | ||
|
||
#include "brave/browser/brave_browser_process_impl.h" | ||
#include "brave/components/brave_shields/browser/tracking_protection_service.h" | ||
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/common/render_messages.h" | ||
|
||
BraveRenderMessageFilter::BraveRenderMessageFilter(int render_process_id, | ||
Profile* profile) | ||
: ChromeRenderMessageFilter(render_process_id, profile), | ||
host_content_settings_map_(HostContentSettingsMapFactory::GetForProfile(profile)) { | ||
} | ||
|
||
BraveRenderMessageFilter::~BraveRenderMessageFilter() {} | ||
|
||
bool BraveRenderMessageFilter::OnMessageReceived(const IPC::Message& message) { | ||
bool handled = true; | ||
IPC_BEGIN_MESSAGE_MAP(BraveRenderMessageFilter, message) | ||
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase); | ||
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage); | ||
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB); | ||
IPC_MESSAGE_UNHANDLED(handled = false) | ||
IPC_END_MESSAGE_MAP() | ||
|
||
return ChromeRenderMessageFilter::OnMessageReceived(message); | ||
} | ||
|
||
void BraveRenderMessageFilter::OnAllowDatabase(int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
const base::string16& name, | ||
const base::string16& display_name, | ||
bool* allowed) { | ||
CHECK(g_brave_browser_process->tracking_protection_service()->IsInitialized()); | ||
*allowed = g_brave_browser_process->tracking_protection_service()->ShouldStoreState(host_content_settings_map_, | ||
origin_url, top_origin_url); | ||
|
||
if (*allowed) { | ||
ChromeRenderMessageFilter::OnAllowDatabase(render_frame_id, origin_url, top_origin_url, | ||
name, display_name, allowed); | ||
} | ||
} | ||
|
||
void BraveRenderMessageFilter::OnAllowDOMStorage(int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
bool local, | ||
bool* allowed) { | ||
CHECK(g_brave_browser_process->tracking_protection_service()->IsInitialized()); | ||
*allowed = g_brave_browser_process->tracking_protection_service()->ShouldStoreState(host_content_settings_map_, | ||
origin_url, top_origin_url); | ||
|
||
if (*allowed) { | ||
ChromeRenderMessageFilter::OnAllowDOMStorage(render_frame_id, origin_url, top_origin_url, | ||
local, allowed); | ||
} | ||
|
||
} | ||
|
||
void BraveRenderMessageFilter::OnAllowIndexedDB(int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
const base::string16& name, | ||
bool* allowed) { | ||
CHECK(g_brave_browser_process->tracking_protection_service()->IsInitialized()); | ||
*allowed = g_brave_browser_process->tracking_protection_service()->ShouldStoreState(host_content_settings_map_, | ||
origin_url, top_origin_url); | ||
|
||
if (*allowed) { | ||
ChromeRenderMessageFilter::OnAllowIndexedDB(render_frame_id, origin_url, top_origin_url, name, allowed); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* 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_BROWSER_RENDERER_HOST_BRAVE_RENDER_MESSAGE_FILTER_H_ | ||
#define BRAVE_BROWSER_RENDERER_HOST_BRAVE_RENDER_MESSAGE_FILTER_H_ | ||
|
||
#include "chrome/browser/renderer_host/chrome_render_message_filter.h" | ||
#include "content/public/browser/browser_message_filter.h" | ||
|
||
class HostContentSettingsMap; | ||
|
||
class BraveRenderMessageFilter : public ChromeRenderMessageFilter { | ||
public: | ||
using ChromeRenderMessageFilter::ChromeRenderMessageFilter; | ||
BraveRenderMessageFilter(int render_process_id, Profile* profile); | ||
bool OnMessageReceived(const IPC::Message& message) override; | ||
|
||
private: | ||
friend class base::DeleteHelper<BraveRenderMessageFilter>; | ||
|
||
~BraveRenderMessageFilter() override; | ||
|
||
void OnAllowDatabase(int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
const base::string16& name, | ||
const base::string16& display_name, | ||
bool* allowed); | ||
|
||
void OnAllowDOMStorage(int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
bool local, | ||
bool* allowed); | ||
|
||
void OnAllowIndexedDB(int render_frame_id, | ||
const GURL& origin_url, | ||
const GURL& top_origin_url, | ||
const base::string16& name, | ||
bool* allowed); | ||
|
||
HostContentSettingsMap *host_content_settings_map_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveRenderMessageFilter); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_RENDERER_HOST_BRAVE_RENDER_MESSAGE_FILTER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
patches/chrome-browser-renderer_host-chrome_render_message_filter.h.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.h b/chrome/browser/renderer_host/chrome_render_message_filter.h | ||
index e1ce2f28510360f9d3e5cefd5c0fdd74e48d61da..5972976ad1fc1b467ba830e7ddf048515a638c0e 100644 | ||
--- a/chrome/browser/renderer_host/chrome_render_message_filter.h | ||
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.h | ||
@@ -18,6 +18,7 @@ | ||
|
||
class GURL; | ||
class Profile; | ||
+class BraveRenderMessageFilter; | ||
|
||
namespace chrome_browser_net { | ||
class Predictor; | ||
@@ -47,6 +48,7 @@ class ChromeRenderMessageFilter : public content::BrowserMessageFilter { | ||
content::BrowserThread::ID* thread) override; | ||
|
||
private: | ||
+ friend class BraveRenderMessageFilter; | ||
friend class content::BrowserThread; | ||
friend class base::DeleteHelper<ChromeRenderMessageFilter>; | ||
|