Skip to content

Commit

Permalink
WIP: Toss cookies and other browsing data for New Tor Identity.
Browse files Browse the repository at this point in the history
  • Loading branch information
riastradh-brave committed May 11, 2019
1 parent aba18b1 commit 5a536b4
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions browser/ui/browser_commands.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/ui/browser_commands.h"

#include <utility>

#include "brave/browser/tor/tor_profile_service.h"
#include "brave/browser/tor/tor_profile_service_factory.h"
#include "chrome/browser/profiles/profile.h"
Expand All @@ -13,17 +16,38 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"

using content::BrowserThread;
using content::NavigationController;
using content::WebContents;

namespace {
void NewTorIdentityCallback(WebContents* current_tab) {
void NewTorIdentityCallbackDone(WebContents* current_tab) {
NavigationController& controller = current_tab->GetController();
controller.Reload(content::ReloadType::BYPASSING_CACHE, true);
}

void NewTorIdentityCallback(WebContents* current_tab) {
auto* context = current_tab->GetBrowserContext();
auto* site = current_tab->GetSiteInstance();
auto* partition =
content::BrowserContext::GetStoragePartition(context, site);
auto cookie_delete_filter = network::mojom::CookieDeletionFilter::New();
// Delete all cookies, irrespective of persistence status.
cookie_delete_filter->session_control =
network::mojom::CookieDeletionSessionControl::IGNORE_CONTROL;
partition->ClearData(
content::StoragePartition::REMOVE_DATA_MASK_ALL,
content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
content::StoragePartition::OriginMatcherFunction(),
std::move(cookie_delete_filter),
/*perform_cleanup*/ true,
/*begin*/ base::Time(), // beginning of time
/*end*/ base::Time::Max(), // end of time
base::Bind(&NewTorIdentityCallbackDone, current_tab));
}
} // namespace

namespace brave {
Expand Down

0 comments on commit 5a536b4

Please sign in to comment.