46
46
#include " content/public/browser/notification_source.h"
47
47
#include " content/public/browser/browser_thread.h"
48
48
#include " content/public/browser/dom_storage_context.h"
49
+ #include " content/public/browser/site_instance.h"
49
50
#include " content/public/browser/storage_partition.h"
50
51
#include " crypto/random.h"
51
52
#include " extensions/browser/pref_names.h"
@@ -345,7 +346,8 @@ BraveBrowserContext::CreateRequestContextForStoragePartition(
345
346
std::move (request_interceptors));
346
347
StoragePartitionDescriptor descriptor (partition_path, in_memory);
347
348
url_request_context_getter_map_[descriptor] = url_request_context_getter;
348
- TorSetProxy (url_request_context_getter, partition_path);
349
+ TorSetProxy (url_request_context_getter, partition_path,
350
+ base::Bind (&base::DoNothing));
349
351
return url_request_context_getter;
350
352
} else {
351
353
return nullptr ;
@@ -429,7 +431,7 @@ void BraveBrowserContext::UpdateDefaultZoomLevel() {
429
431
430
432
void BraveBrowserContext::TorSetProxy (
431
433
brightray::URLRequestContextGetter* url_request_context_getter,
432
- const base::FilePath partition_path) {
434
+ const base::FilePath partition_path, const base::Closure& callback ) {
433
435
if (!url_request_context_getter || !isolated_storage_)
434
436
return ;
435
437
if (!tor_proxy_.empty () && GURL (tor_proxy_).is_valid ()) {
@@ -452,6 +454,8 @@ void BraveBrowserContext::TorSetProxy(
452
454
proxy_service->ResetConfigService (base::WrapUnique (
453
455
new net::ProxyConfigServiceFixed (config)));
454
456
proxy_service->ForceReloadProxyConfig ();
457
+ if (callback)
458
+ callback.Run ();
455
459
}
456
460
}
457
461
@@ -740,8 +744,10 @@ void BraveBrowserContext::SetExitType(ExitType exit_type) {
740
744
}
741
745
}
742
746
743
- void BraveBrowserContext::SetTorNewIdentity (const GURL& origin) {
744
- const std::string host = origin.host ();
747
+ void BraveBrowserContext::SetTorNewIdentity (const GURL& url,
748
+ const base::Closure& callback) {
749
+ GURL site_url (content::SiteInstance::GetSiteForURL (this , url));
750
+ const std::string host = site_url.host ();
745
751
base::FilePath partition_path = this ->GetPath ().Append (
746
752
content::StoragePartitionImplMap::GetStoragePartitionPath (host, host));
747
753
brightray::URLRequestContextGetter* url_request_context_getter;
@@ -752,7 +758,7 @@ void BraveBrowserContext::SetTorNewIdentity(const GURL& origin) {
752
758
url_request_context_getter = (iter->second ).get ();
753
759
else
754
760
return ;
755
- TorSetProxy (url_request_context_getter, partition_path);
761
+ TorSetProxy (url_request_context_getter, partition_path, callback );
756
762
}
757
763
758
764
scoped_refptr<base::SequencedTaskRunner>
0 commit comments