-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement navigator.plugins farbling
- Loading branch information
1 parent
e80c245
commit 141bb28
Showing
4 changed files
with
80 additions
and
2 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
59 changes: 59 additions & 0 deletions
59
chromium_src/third_party/blink/renderer/modules/plugins/dom_plugin_array.cc
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,59 @@ | ||
/* 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/. */ | ||
|
||
#include "brave/third_party/blink/renderer/brave_farbling_constants.h" | ||
#include "third_party/blink/public/platform/web_content_settings_client.h" | ||
#include <random> | ||
|
||
#define BRAVE_DOM_PLUGINS_UPDATE_PLUGIN_DATA \ | ||
if (GetFrame() && GetFrame()->GetContentSettingsClient()) { \ | ||
switch (GetFrame()->GetContentSettingsClient()->GetBraveFarblingLevel()) { \ | ||
case BraveFarblingLevel::OFF: { \ | ||
break; \ | ||
} \ | ||
case BraveFarblingLevel::MAXIMUM: { \ | ||
dom_plugins_.clear(); \ | ||
U_FALLTHROUGH; \ | ||
} \ | ||
case BraveFarblingLevel::BALANCED: { \ | ||
for (unsigned index = 0; index < length(); index++) { \ | ||
dom_plugins_[index] = item(index); \ | ||
} \ | ||
auto* fake_plugin_info_1 = MakeGarbageCollected<PluginInfo>( \ | ||
brave::BraveSessionCache::From(*(GetFrame()->GetDocument())) \ | ||
.GenerateRandomString("PLUGIN_1_NAME", 8), \ | ||
brave::BraveSessionCache::From(*(GetFrame()->GetDocument())) \ | ||
.GenerateRandomString("PLUGIN_1_FILENAME", 16), \ | ||
brave::BraveSessionCache::From(*(GetFrame()->GetDocument())) \ | ||
.GenerateRandomString("PLUGIN_1_DESCRIPTION", 32), \ | ||
0, false); \ | ||
auto* fake_dom_plugin_1 = \ | ||
MakeGarbageCollected<DOMPlugin>(GetFrame(), *fake_plugin_info_1); \ | ||
dom_plugins_.push_back(fake_dom_plugin_1); \ | ||
auto* fake_plugin_info_2 = MakeGarbageCollected<PluginInfo>( \ | ||
brave::BraveSessionCache::From(*(GetFrame()->GetDocument())) \ | ||
.GenerateRandomString("PLUGIN_2_NAME", 7), \ | ||
brave::BraveSessionCache::From(*(GetFrame()->GetDocument())) \ | ||
.GenerateRandomString("PLUGIN_2_FILENAME", 15), \ | ||
brave::BraveSessionCache::From(*(GetFrame()->GetDocument())) \ | ||
.GenerateRandomString("PLUGIN_2_DESCRIPTION", 31), \ | ||
0, false); \ | ||
auto* fake_dom_plugin_2 = \ | ||
MakeGarbageCollected<DOMPlugin>(GetFrame(), *fake_plugin_info_2); \ | ||
dom_plugins_.push_back(fake_dom_plugin_2); \ | ||
std::mt19937_64 prng = \ | ||
brave::BraveSessionCache::From(*(GetFrame()->GetDocument())) \ | ||
.MakePseudoRandomGenerator(); \ | ||
std::shuffle(dom_plugins_.begin(), dom_plugins_.end(), prng); \ | ||
break; \ | ||
} \ | ||
default: \ | ||
NOTREACHED(); \ | ||
} \ | ||
} | ||
|
||
#include "../../../../../../third_party/blink/renderer/modules/plugins/dom_plugin_array.cc" | ||
|
||
#undef BRAVE_DOM_PLUGIN_ARRAY_GET_PLUGIN_DATA |
12 changes: 12 additions & 0 deletions
12
patches/third_party-blink-renderer-modules-plugins-dom_plugin_array.cc.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,12 @@ | ||
diff --git a/third_party/blink/renderer/modules/plugins/dom_plugin_array.cc b/third_party/blink/renderer/modules/plugins/dom_plugin_array.cc | ||
index 322e74880ddaa6c6c54f80f4f5f7ab0264631ffd..0c13152cb2f9ebd5bbf86955f50eab6909f05443 100644 | ||
--- a/third_party/blink/renderer/modules/plugins/dom_plugin_array.cc | ||
+++ b/third_party/blink/renderer/modules/plugins/dom_plugin_array.cc | ||
@@ -146,6 +146,7 @@ void DOMPluginArray::UpdatePluginData() { | ||
} | ||
} | ||
} | ||
+ BRAVE_DOM_PLUGINS_UPDATE_PLUGIN_DATA | ||
} | ||
|
||
void DOMPluginArray::ContextDestroyed() { |