Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Add 'tor' partition with domain-partitioned storage
Browse files Browse the repository at this point in the history
Fix #468
  • Loading branch information
diracdeltas committed Jan 31, 2018
1 parent d6f9ad6 commit abece9d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions brave/browser/brave_browser_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ bool BraveBrowserContext::HasParentContext() {
return has_parent_;
}

bool BraveBrowserContext::IsTorContext() {
return partition() == "tor";
}

BraveBrowserContext* BraveBrowserContext::original_context() {
if (original_context_) {
return original_context_;
Expand Down
2 changes: 2 additions & 0 deletions brave/browser/brave_browser_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class BraveBrowserContext : public Profile {

bool HasParentContext();

bool IsTorContext();

// content::BrowserContext:
content::PermissionManager* GetPermissionManager() override;
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
Expand Down
8 changes: 8 additions & 0 deletions brave/browser/brave_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "base/lazy_instance.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "brave/browser/brave_browser_context.h"
#include "brave/browser/notifications/platform_notification_service_impl.h"
#include "brave/browser/password_manager/brave_password_manager_client.h"
#include "brave/grit/brave_resources.h"
Expand Down Expand Up @@ -277,6 +278,13 @@ void BraveContentBrowserClient::GetStoragePartitionConfigForSite(
}
#endif

BraveBrowserContext* profile =
BraveBrowserContext::FromBrowserContext(browser_context);
if (profile->IsTorContext()) {
*in_memory = profile->IsOffTheRecord();
*partition_domain = site.host();
}

// Assert that if |can_be_default| is false, the code above must have found a
// non-default partition. If this fails, the caller has a serious logic
// error about which StoragePartition they expect to be in and it is not
Expand Down

0 comments on commit abece9d

Please sign in to comment.