Skip to content

Commit

Permalink
Merge pull request #624 from brave/disable_flash_in_tor
Browse files Browse the repository at this point in the history
Disable flash in Tor
  • Loading branch information
bbondy committed Oct 14, 2018
2 parents eccf41a + ef75855 commit 9aa3374
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "brave/components/brave_shields/common/brave_shield_constants.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/plugins/plugin_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/subresource_filter/chrome_subresource_filter_client.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model_delegate.h"
#include "chrome/grit/generated_resources.h"
Expand All @@ -25,15 +26,24 @@ BraveContentSettingPluginBubbleModel::BraveContentSettingPluginBubbleModel(
GURL url = web_contents->GetURL();
std::unique_ptr<base::Value> value =
map->GetWebsiteSetting(url, url, content_type(), std::string(), &info);

set_show_learn_more(true);

// Do not show "Run flash this time" and "Manage" button in Tor profile.
if (profile->IsTorProfile()) {
set_manage_text_style(ContentSettingBubbleModel::ManageTextStyle::kNone);
return;
}

// If the setting is not managed by the user, hide the "Manage" button.
if (info.source != content_settings::SETTING_SOURCE_USER)
set_manage_text_style(ContentSettingBubbleModel::ManageTextStyle::kNone);

set_custom_link(l10n_util::GetStringUTF16(IDS_BLOCKED_PLUGINS_LOAD_ALL));
set_custom_link_enabled(
web_contents &&
TabSpecificContentSettings::FromWebContents(web_contents)
->load_plugins_link_enabled());
set_show_learn_more(true);
}

void BraveContentSettingPluginBubbleModel::OnLearnMoreClicked() {
Expand Down
25 changes: 25 additions & 0 deletions chromium_src/chrome/browser/ui/page_info/page_info.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* 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 "content/public/browser/web_contents.h"
#include "chrome/browser/ui/page_info/page_info_ui.h"
#include "chrome/browser/profiles/profile.h"

namespace {

bool BraveShouldShowPermission(
const PageInfoUI::PermissionInfo& info,
content::WebContents* web_contents) {
if ((info.type == CONTENT_SETTINGS_TYPE_PLUGINS ||
info.type == CONTENT_SETTINGS_TYPE_GEOLOCATION) &&
Profile::FromBrowserContext(web_contents->GetBrowserContext())->IsTorProfile()) {
return false;
}

return true;
}

}

#include "../../../../../../chrome/browser/ui/page_info/page_info.cc"
14 changes: 11 additions & 3 deletions patches/chrome-browser-ui-page_info-page_info.cc.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
diff --git a/chrome/browser/ui/page_info/page_info.cc b/chrome/browser/ui/page_info/page_info.cc
index e7e7c5d1c2c0699f8892d4be90281c2bb7c7d1b9..1a6713c6604bab2f05d4d2de89a83f488e6be089 100644
index e7e7c5d1c2c0699f8892d4be90281c2bb7c7d1b9..91c46da0bddfcf3ea3e2b4bc587a26138d79a3c3 100644
--- a/chrome/browser/ui/page_info/page_info.cc
+++ b/chrome/browser/ui/page_info/page_info.cc
@@ -197,7 +197,7 @@ bool ShouldShowPermission(
@@ -152,6 +152,7 @@ bool ShouldShowPermission(
HostContentSettingsMap* content_settings,
content::WebContents* web_contents,
TabSpecificContentSettings* tab_specific_content_settings) {
+ if (!BraveShouldShowPermission(info, web_contents)) return false;
// Note |CONTENT_SETTINGS_TYPE_ADS| will show up regardless of its default
// value when it has been activated on the current origin.
if (info.type == CONTENT_SETTINGS_TYPE_ADS) {
@@ -197,7 +198,7 @@ bool ShouldShowPermission(
}
#endif

Expand All @@ -11,7 +19,7 @@ index e7e7c5d1c2c0699f8892d4be90281c2bb7c7d1b9..1a6713c6604bab2f05d4d2de89a83f48
// Autoplay is Android-only at the moment.
if (info.type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
return false;
@@ -1001,7 +1001,7 @@ void PageInfo::PresentSiteIdentity() {
@@ -1001,7 +1002,7 @@ void PageInfo::PresentSiteIdentity() {
std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() {
std::vector<ContentSettingsType> permission_list;
for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
Expand Down

0 comments on commit 9aa3374

Please sign in to comment.