Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable flash in Tor #624

Merged
merged 1 commit into from
Oct 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corresponding issue just said about blocking plugin.
Do we also want to hide location info in page info bubble?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional cuz location permission is blocked in tor.

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