-
Notifications
You must be signed in to change notification settings - Fork 892
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 tor by group policy on Windows. #3692
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4608185
Add group policy for tor on Windows
simonhong d1a3794
Add browser tests for TorDisabled group policy
simonhong 104906f
Modify chrome branding in brave://management webui page
simonhong 6c86856
Disable and hide tor related commands
simonhong c072156
Don't register tor component if tor is disabled by gpo
simonhong 217f9c4
Fix android build failure due to zero length array
simonhong 336fe9f
Add tests cases to app menu test for tor disabled
simonhong a04ca93
Change group policy registry path on Win
simonhong 014d46f
Delete tor binaries if tor is disabled by gpo
simonhong 3c2d2b6
Move kTorDisabled prefs to local state.
simonhong 29c0084
Move some more codes into ENABLE_TOR build flag
simonhong 58d429d
Address review comments
simonhong 85bc3cb
Add brave policy definitions by scripts instead of modifying json
simonhong 8ff4423
Fix python script lint error
simonhong aca4e5c
Add some targets directly into deps list if it is used directly
simonhong 054fd5a
Fix unitest failure due to access null browser_process object
simonhong abb65fe
Add more missing deps
simonhong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,93 @@ | ||
/* Copyright (c) 2019 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/browser/tor/buildflags.h" | ||
#include "brave/common/pref_names.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/ui/browser.h" | ||
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "components/policy/core/browser/browser_policy_connector.h" | ||
#include "components/policy/core/common/mock_configuration_policy_provider.h" | ||
#include "components/policy/policy_constants.h" | ||
#include "components/prefs/pref_service.h" | ||
|
||
#if BUILDFLAG(ENABLE_TOR) | ||
#include "brave/browser/tor/tor_profile_service.h" | ||
#include "brave/common/tor/pref_names.h" | ||
#endif | ||
|
||
using testing::_; | ||
using testing::Return; | ||
using NoTorPolicyBrowserTest = InProcessBrowserTest; | ||
|
||
namespace policy { | ||
|
||
class BravePolicyTest : public InProcessBrowserTest { | ||
protected: | ||
BravePolicyTest() {} | ||
~BravePolicyTest() override {} | ||
|
||
void SetUpInProcessBrowserTestFixture() override { | ||
EXPECT_CALL(provider_, IsInitializationComplete(_)) | ||
.WillRepeatedly(Return(true)); | ||
BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); | ||
} | ||
|
||
MockConfigurationPolicyProvider provider_; | ||
}; | ||
|
||
#if BUILDFLAG(ENABLE_TOR) | ||
#if defined(OS_WIN) | ||
// This policy only exists on Windows. | ||
// Sets the tor policy before the browser is started. | ||
class TorDisabledPolicyBrowserTest : public BravePolicyTest { | ||
public: | ||
TorDisabledPolicyBrowserTest() {} | ||
~TorDisabledPolicyBrowserTest() override {} | ||
|
||
void SetUpInProcessBrowserTestFixture() override { | ||
BravePolicyTest::SetUpInProcessBrowserTestFixture(); | ||
|
||
PolicyMap policies; | ||
policies.Set(key::kTorDisabled, POLICY_LEVEL_MANDATORY, | ||
POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM, | ||
std::make_unique<base::Value>(true), nullptr); | ||
provider_.UpdateChromePolicy(policies); | ||
} | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(TorDisabledPolicyBrowserTest, TorDisabledPrefValueTest) { | ||
EXPECT_TRUE(tor::TorProfileService::IsTorDisabled()); | ||
} | ||
|
||
class TorEnabledPolicyBrowserTest : public BravePolicyTest { | ||
public: | ||
TorEnabledPolicyBrowserTest() {} | ||
~TorEnabledPolicyBrowserTest() override {} | ||
|
||
void SetUpInProcessBrowserTestFixture() override { | ||
BravePolicyTest::SetUpInProcessBrowserTestFixture(); | ||
|
||
PolicyMap policies; | ||
policies.Set(key::kTorDisabled, POLICY_LEVEL_MANDATORY, | ||
POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM, | ||
std::make_unique<base::Value>(false), nullptr); | ||
provider_.UpdateChromePolicy(policies); | ||
} | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(TorEnabledPolicyBrowserTest, TorDisabledPrefValueTest) { | ||
EXPECT_FALSE(tor::TorProfileService::IsTorDisabled()); | ||
} | ||
|
||
// W/o TorDisabled group policy, kTorDisabled pref value should be false. | ||
IN_PROC_BROWSER_TEST_F(NoTorPolicyBrowserTest, | ||
DefaultTorDisabledPrefValueTest) { | ||
EXPECT_FALSE(tor::TorProfileService::IsTorDisabled()); | ||
darkdh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
#endif // OS_WIN | ||
#endif // ENABLE_TOR | ||
|
||
} // namespace policy |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you may have some kind of rebase issue in here cc @darkdh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bridiver , I rebased this PR onto latest master yesterday.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the switch check
kDisableTorClientUpdaterExtension
? Current master still has that switch.The latest commit only added
AsTestingProfile
checkThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other conditions are moved to
BraveTorClientUpdater::Register()
. - 81bae87#diff-5293ed891460b117107c7923e61926efR127The intension of this refactoring is moving tor update specific logic to
BraveTorClientUpdater::Register()
likeBraveTorClientUpdater::Cleanup()
. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, sounds good but you forgot to remove this header 81bae87#diff-f7642300415fc6963490faca0750da8bL10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darkdh Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonhong can you also double-check that deps are removed/added for this file and the file it was added to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked whole files that touched in this PR by using below commands and added more missing deps except circular.
gn check out/Debug //brave/browser/extensions | grep brave_extension_management.cc
gn check out/Debug //brave/browser/extensions | brave_tor_client_updater.cc
gn check out/Debug //brave/test::brave_browser_tests | grep brave_policy_browsertest.cc
gn check out/Debug //brave/browser/tor | grep tor_profile_esrvice.cc
gn check out/Debug //brave/browser/ui | grep brave_browser_command_controller.cc
gn check out/Debug //brave/browser/ui | grep brave_app_menu_model.cc
gn check out/Debug //brave/test:brave_browser_tests | grep brave_app_menu_model_browsertest.cc
gn check out/Debug //brave/browser/ui | grep brave_profile_menu_view_helper.cc
and manually checks override files.