Remove brave/browser/profiles deps for brave/browser/tor
This commit is contained in:
@@ -27,6 +27,8 @@ source_set("tor") {
|
||||
deps = [
|
||||
"//base",
|
||||
"//brave/browser/translate/buildflags",
|
||||
"//brave/common:pref_names",
|
||||
"//brave/components/brave_webtorrent/browser/buildflags",
|
||||
"//brave/components/tor",
|
||||
"//brave/components/tor:pref_names",
|
||||
"//chrome/common",
|
||||
@@ -58,7 +60,6 @@ source_set("unit_tests") {
|
||||
deps = [
|
||||
"//base",
|
||||
"//base/test:test_support",
|
||||
"//brave/browser/profiles",
|
||||
"//brave/browser/tor",
|
||||
"//brave/components/tor",
|
||||
"//chrome/test:test_support",
|
||||
@@ -84,7 +85,6 @@ source_set("browser_tests") {
|
||||
"//base",
|
||||
"//brave/app:brave_generated_resources_grit",
|
||||
"//brave/browser:browser_process",
|
||||
"//brave/browser/profiles",
|
||||
"//brave/browser/tor",
|
||||
"//brave/browser/ui",
|
||||
"//brave/common",
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/browser/tor/tor_profile_service_factory.h"
|
||||
#include "brave/browser/ui/browser_commands.h"
|
||||
#include "brave/browser/ui/views/location_bar/brave_location_bar_view.h"
|
||||
@@ -105,7 +104,7 @@ IN_PROC_BROWSER_TEST_F(OnionLocationNavigationThrottleBrowserTest,
|
||||
BrowserList* browser_list = BrowserList::GetInstance();
|
||||
ui_test_utils::NavigateToURL(browser(), GURL("https://brave.com"));
|
||||
EXPECT_EQ(1U, browser_list->size());
|
||||
ASSERT_FALSE(brave::IsTorProfile(browser_list->get(0)->profile()));
|
||||
ASSERT_FALSE(browser_list->get(0)->profile()->IsTor());
|
||||
|
||||
content::WindowedNotificationObserver tor_browser_creation_observer(
|
||||
chrome::NOTIFICATION_BROWSER_OPENED,
|
||||
@@ -113,7 +112,7 @@ IN_PROC_BROWSER_TEST_F(OnionLocationNavigationThrottleBrowserTest,
|
||||
ui_test_utils::NavigateToURL(browser(), GURL(kTestOnionURL));
|
||||
tor_browser_creation_observer.Wait();
|
||||
EXPECT_EQ(2U, browser_list->size());
|
||||
ASSERT_TRUE(brave::IsTorProfile(browser_list->get(1)->profile()));
|
||||
ASSERT_TRUE(browser_list->get(1)->profile()->IsTor());
|
||||
content::WebContents* web_contents =
|
||||
browser_list->get(1)->tab_strip_model()->GetActiveWebContents();
|
||||
EXPECT_EQ(web_contents->GetURL(), GURL(kTestOnionURL));
|
||||
@@ -142,7 +141,7 @@ IN_PROC_BROWSER_TEST_F(OnionLocationNavigationThrottleBrowserTest,
|
||||
BrowserList* browser_list = BrowserList::GetInstance();
|
||||
EXPECT_EQ(2U, browser_list->size());
|
||||
Browser* tor_browser = browser_list->get(1);
|
||||
ASSERT_TRUE(brave::IsTorProfile(tor_browser->profile()));
|
||||
ASSERT_TRUE(tor_browser->profile()->IsTor());
|
||||
web_contents = tor_browser->tab_strip_model()->GetActiveWebContents();
|
||||
EXPECT_EQ(web_contents->GetURL(), GURL(kTestOnionURL));
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <utility>
|
||||
|
||||
#include "base/test/bind_test_util.h"
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/browser/tor/tor_profile_manager.h"
|
||||
#include "brave/browser/tor/tor_profile_service_factory.h"
|
||||
#include "brave/components/tor/tor_navigation_throttle.h"
|
||||
@@ -78,14 +77,14 @@ TEST_F(TorNavigationThrottleUnitTest, Instantiation) {
|
||||
std::unique_ptr<TorNavigationThrottle> throttle =
|
||||
TorNavigationThrottle::MaybeCreateThrottleFor(
|
||||
&test_handle, tor_profile_service(),
|
||||
brave::IsTorProfile(tor_web_contents()->GetBrowserContext()));
|
||||
tor_web_contents()->GetBrowserContext()->IsTor());
|
||||
EXPECT_TRUE(throttle != nullptr);
|
||||
|
||||
content::MockNavigationHandle test_handle2(web_contents());
|
||||
std::unique_ptr<TorNavigationThrottle> throttle2 =
|
||||
TorNavigationThrottle::MaybeCreateThrottleFor(
|
||||
&test_handle2, nullptr,
|
||||
brave::IsTorProfile(web_contents()->GetBrowserContext()));
|
||||
web_contents()->GetBrowserContext()->IsTor());
|
||||
EXPECT_TRUE(throttle2 == nullptr);
|
||||
}
|
||||
|
||||
@@ -95,7 +94,7 @@ TEST_F(TorNavigationThrottleUnitTest, WhitelistedScheme) {
|
||||
std::unique_ptr<TorNavigationThrottle> throttle =
|
||||
TorNavigationThrottle::MaybeCreateThrottleFor(
|
||||
&test_handle, tor_profile_service(),
|
||||
brave::IsTorProfile(tor_web_contents()->GetBrowserContext()));
|
||||
tor_web_contents()->GetBrowserContext()->IsTor());
|
||||
GURL url("http://www.example.com");
|
||||
test_handle.set_url(url);
|
||||
EXPECT_EQ(NavigationThrottle::PROCEED, throttle->WillStartRequest().action())
|
||||
@@ -131,7 +130,7 @@ TEST_F(TorNavigationThrottleUnitTest, BlockedScheme) {
|
||||
std::unique_ptr<TorNavigationThrottle> throttle =
|
||||
TorNavigationThrottle::MaybeCreateThrottleFor(
|
||||
&test_handle, tor_profile_service(),
|
||||
brave::IsTorProfile(tor_web_contents()->GetBrowserContext()));
|
||||
tor_web_contents()->GetBrowserContext()->IsTor());
|
||||
GURL url("ftp://ftp.example.com");
|
||||
test_handle.set_url(url);
|
||||
EXPECT_EQ(NavigationThrottle::BLOCK_REQUEST,
|
||||
@@ -156,7 +155,7 @@ TEST_F(TorNavigationThrottleUnitTest, DeferUntilTorProcessLaunched) {
|
||||
std::unique_ptr<TorNavigationThrottle> throttle =
|
||||
TorNavigationThrottle::MaybeCreateThrottleFor(
|
||||
&test_handle, tor_profile_service(),
|
||||
brave::IsTorProfile(tor_web_contents()->GetBrowserContext()));
|
||||
tor_web_contents()->GetBrowserContext()->IsTor());
|
||||
bool was_navigation_resumed = false;
|
||||
throttle->set_resume_callback_for_testing(
|
||||
base::BindLambdaForTesting([&]() { was_navigation_resumed = true; }));
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "base/path_service.h"
|
||||
#include "brave/browser/brave_browser_process_impl.h"
|
||||
#include "brave/browser/brave_rewards/rewards_service_factory.h"
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/browser/tor/tor_profile_manager.h"
|
||||
#include "brave/common/brave_paths.h"
|
||||
#include "brave/components/brave_ads/browser/ads_service_factory.h"
|
||||
@@ -101,7 +100,7 @@ IN_PROC_BROWSER_TEST_F(TorProfileManagerTest,
|
||||
parent_bookmark_model->AddURL(root, 0, title, url1);
|
||||
|
||||
Profile* tor_profile = SwitchToTorProfile(parent_profile);
|
||||
ASSERT_TRUE(brave::IsTorProfile(tor_profile));
|
||||
ASSERT_TRUE(tor_profile->IsTor());
|
||||
EXPECT_TRUE(tor_profile->IsOffTheRecord());
|
||||
EXPECT_EQ(tor_profile->GetOriginalProfile(), parent_profile);
|
||||
|
||||
@@ -142,7 +141,7 @@ IN_PROC_BROWSER_TEST_F(TorProfileManagerTest,
|
||||
|
||||
Profile* tor_profile = SwitchToTorProfile(parent_profile);
|
||||
EXPECT_EQ(tor_profile->GetOriginalProfile(), parent_profile);
|
||||
ASSERT_TRUE(brave::IsTorProfile(tor_profile));
|
||||
ASSERT_TRUE(tor_profile->IsTor());
|
||||
EXPECT_TRUE(tor_profile->IsOffTheRecord());
|
||||
|
||||
EXPECT_EQ(brave_rewards::RewardsServiceFactory::GetForProfile(tor_profile),
|
||||
@@ -166,7 +165,7 @@ IN_PROC_BROWSER_TEST_F(TorProfileManagerTest, SwitchToTorProfileInheritPrefs) {
|
||||
EXPECT_TRUE(parent_prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar));
|
||||
|
||||
Profile* tor_profile = SwitchToTorProfile(parent_profile);
|
||||
ASSERT_TRUE(brave::IsTorProfile(tor_profile));
|
||||
ASSERT_TRUE(tor_profile->IsTor());
|
||||
EXPECT_TRUE(tor_profile->IsOffTheRecord());
|
||||
EXPECT_EQ(tor_profile->GetOriginalProfile(), parent_profile);
|
||||
|
||||
@@ -194,7 +193,7 @@ IN_PROC_BROWSER_TEST_F(TorProfileManagerTest,
|
||||
CONTENT_SETTING_BLOCK);
|
||||
|
||||
Profile* tor_profile = SwitchToTorProfile(parent_profile);
|
||||
ASSERT_TRUE(brave::IsTorProfile(tor_profile));
|
||||
ASSERT_TRUE(tor_profile->IsTor());
|
||||
EXPECT_TRUE(tor_profile->IsOffTheRecord());
|
||||
EXPECT_EQ(tor_profile->GetOriginalProfile(), parent_profile);
|
||||
|
||||
@@ -263,7 +262,7 @@ IN_PROC_BROWSER_TEST_F(TorProfileManagerExtensionTest,
|
||||
parent_extension_prefs->SetIsIncognitoEnabled(id, true);
|
||||
|
||||
Profile* tor_profile = SwitchToTorProfile(parent_profile);
|
||||
ASSERT_TRUE(brave::IsTorProfile(tor_profile));
|
||||
ASSERT_TRUE(tor_profile->IsTor());
|
||||
EXPECT_TRUE(tor_profile->IsOffTheRecord());
|
||||
EXPECT_EQ(tor_profile->GetOriginalProfile(), parent_profile);
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "base/path_service.h"
|
||||
#include "brave/browser/brave_browser_process_impl.h"
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/components/tor/pref_names.h"
|
||||
#include "brave/components/tor/tor_profile_service_impl.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
@@ -60,8 +59,6 @@ TorProfileServiceFactory::~TorProfileServiceFactory() {}
|
||||
|
||||
KeyedService* TorProfileServiceFactory::BuildServiceInstanceFor(
|
||||
content::BrowserContext* context) const {
|
||||
if (!brave::IsTorProfile(context))
|
||||
return nullptr;
|
||||
base::FilePath user_data_dir;
|
||||
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
|
||||
DCHECK(!user_data_dir.empty());
|
||||
@@ -78,7 +75,8 @@ KeyedService* TorProfileServiceFactory::BuildServiceInstanceFor(
|
||||
|
||||
content::BrowserContext* TorProfileServiceFactory::GetBrowserContextToUse(
|
||||
content::BrowserContext* context) const {
|
||||
// Not shared with our dummy regular Tor profile because we want to trigger
|
||||
// LaunchTor when a new Tor window is created.
|
||||
// Only grant service for tor context
|
||||
if (!context->IsTor())
|
||||
return nullptr;
|
||||
return context;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user