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

Uplift Disable opening Tor options in guest window to 1.3.x #4189

Merged
merged 1 commit into from
Dec 10, 2019
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
13 changes: 13 additions & 0 deletions browser/profiles/profile_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/profiles/profile_manager.h"

#if BUILDFLAG(ENABLE_TOR)
#include "brave/browser/tor/tor_profile_service.h"
#endif

namespace brave {

namespace {
Expand Down Expand Up @@ -195,6 +199,15 @@ bool IsGuestProfile(content::BrowserContext* context) {
->IsGuestSession();
}

bool IsTorDisabledForProfile(Profile* profile) {
#if BUILDFLAG(ENABLE_TOR)
return tor::TorProfileService::IsTorDisabled() ||
profile->IsGuestSession();
#else
return true;
#endif
}

} // namespace brave

namespace chrome {
Expand Down
2 changes: 2 additions & 0 deletions browser/profiles/profile_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Profile* GetParentProfile(const base::FilePath& path);
// the guest profile by calling IsGuestSession and have to use this function.
bool IsGuestProfile(content::BrowserContext* profile);

bool IsTorDisabledForProfile(Profile* profile);

} // namespace brave

namespace chrome {
Expand Down
7 changes: 2 additions & 5 deletions browser/ui/brave_browser_command_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
#include "brave/components/brave_sync/switches.h"
#endif

#if BUILDFLAG(ENABLE_TOR)
#include "brave/browser/tor/tor_profile_service.h"
#endif

namespace {

bool IsBraveCommands(int id) {
Expand Down Expand Up @@ -145,7 +141,8 @@ void BraveBrowserCommandController::UpdateCommandForWebcompatReporter() {

void BraveBrowserCommandController::UpdateCommandForTor() {
#if BUILDFLAG(ENABLE_TOR)
const bool is_tor_enabled = !tor::TorProfileService::IsTorDisabled();
const bool is_tor_enabled =
!brave::IsTorDisabledForProfile(browser_->profile());
UpdateCommandEnabled(IDC_NEW_TOR_CONNECTION_FOR_SITE, is_tor_enabled);
UpdateCommandEnabled(IDC_NEW_OFFTHERECORD_WINDOW_TOR, is_tor_enabled);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ bool BraveRenderViewContextMenu::IsCommandIdEnabled(int id) const {
switch (id) {
case IDC_CONTENT_CONTEXT_OPENLINKTOR:
#if BUILDFLAG(ENABLE_TOR)
if (tor::TorProfileService::IsTorDisabled())
if (brave::IsTorDisabledForProfile(GetProfile()))
return false;

return params_.link_url.is_valid() &&
IsURLAllowedInIncognito(params_.link_url, browser_context_) &&
!brave::IsTorProfile(GetProfile());
Expand Down